Skip to content

Instantly share code, notes, and snippets.

@andriy-baran
Last active June 27, 2018 08:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andriy-baran/528bd08dcdb1165960c952718f7a5711 to your computer and use it in GitHub Desktop.
Save andriy-baran/528bd08dcdb1165960c952718f7a5711 to your computer and use it in GitHub Desktop.
include_context 'api session'
let(:path) { "/api/v1/#{order_id}/line" }
let(:order_id) { 456 }
context 'when do some complex things' do
let(:order) { FactoryBot.create(:order) }
let(:order_id) { order.id }
let(:item) { LineItem.last }
let(:valid_params) do
{
name: 'product 1',
price: 1.14
}
end
let(:valid_response) do
{
id: order_id,
items: [
{
name: item.name,
price: item.price.to_s
}
]
}
end
it 'does something special' do
allow(ExternalService).to receive(:get_info)
expect(ExternalService).to receive(:get_info)
expect { do_post }.to change { LineItem.count }.by(1)
assert_200_json_response_object
expect(order.reload.line_items).to eq [item]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment