Rails 3 Capybara Error

I am trying to get Capybara to work with rails 3 (and the test module), but when I try to run rake test:integration , I get the error message: ArgumentError: @request must be an ActionDispatch::Request

Test :

 require 'integration_test_helper' class UserNotesTest < ActionDispatch::IntegrationTest test "User should login" do user = Factory.create(:user) visit '/login' assert_response :success fill_in 'user_email', :with => user.email fill_in 'user_password', :with => user.password click_button 'Sign in' assert_redirect_to notes_path end end 

integration_test_helper:

 require 'test_helper' require 'capybara/rails' module ActionDispatch class IntegrationTest include Capybara end end 

I'm not quite sure what is going wrong ...

+6
ruby-on-rails ruby-on-rails-3 testing testunit
source share
1 answer

This was a problem when capybara did not assign anything to the @request variable after visit .

One solution is to use built-in rail methods, i.e.

 get '/login' assert_response :success 

In rspec, I use statements on page , not @request .

There is a discussion here .

+3
source share

All Articles