This is my controller code
controller code :-
def test
image= Image.new(params)
image.save
image.rest_service
end
Model
def rest_service
RestClient.post('i am here')
end
it 'should return json with response code 200' do
post '/orders/test', { order: {agreement_id: '101}}.to_json, get_headers(:private)
expect(last_response.status).to eq(200)
end
Problem
I have to stub rest_service request ,through webmock . but not sure where and how to add code
it 'should return json with response code 200' do
stub_request(:post, 'i am here').to_return(:body => 'mocked response')
post('/orders/test', { order: {agreement_id: '101}}.to_json, get_headers(:private))
expect(last_response.status).to eq(200)
end