I am writing Request spec with capybara and having trouble to hit post URL, here is my code
context 'discounts in api', js: true do
let(:user) { Fabricate(:user, activated: true) }
let(:api_token) { user.api_token }
let(:discount) { Fabricate(:discount_coupon, code: 'Test_Dc', global: true) }
it 'should be able to add discount coupon' do
visit api_url_for("/v1/discount_coupons/#{discount.id}/add", api_token)
save_screenshot("tmp/capybara/screenshot-#{Time::now.strftime('%Y%m%d%H%M%S%N')}.png")
save_and_open_page
expect(response).to have_text('true')
end
end
but it fails for post request, is there any way to hit post url with capybara ?
my form data is only need api_token. and "api_url_for
" just a helper to go at
http://api.mydomain:3000