6

I'm trying to get Capybara to work with rails 3 (and test unit) but when I try to run rake test:integration I get an error:ArgumentError: @request must be an ActionDispatch::Request

The 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 really sure whats going wrong...

4

1 回答 1

3

这是 capybara@request之后没有为变量分配任何东西的问题visit

一种解决方案是使用 rails 内置方法,即

get '/login'
assert_response :success

在 rspec 中,我使用断言page而不是@request.

这里有一些讨论。

于 2011-08-10T00:32:50.333 回答