Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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