Last active
June 27, 2018 08:56
-
-
Save andriy-baran/528bd08dcdb1165960c952718f7a5711 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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