1

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

Ismael Abreu
  • 16,443
  • 6
  • 61
  • 75
Awais
  • 1,803
  • 22
  • 26
  • possible duplicate of [How do you POST to a URL in Capybara?](http://stackoverflow.com/questions/4084212/how-do-you-post-to-a-url-in-capybara) – Peter Alfvin Jun 27 '14 at 14:06
  • i tried this code but same issue sucks :( rack_test_session_wrapper = Capybara.current_session.driver rack_test_session_wrapper.submit :post, your_path, nil – Awais Jun 27 '14 at 17:54

0 Answers0