Rails 3 水豚错误
我试图让 Capybara 使用 Rails 3(和测试单元),但是当我尝试运行 rake test:integration
时,我收到错误:ArgumentError: @request 必须是 ActionDispatch ::要求
测试:
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 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...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是水豚在
visit
后未向@request
变量分配任何内容的问题。一种解决方案是使用rails内置方法,即
在rspec中,我在
page
上使用断言,而不是@request
。这里有一些讨论。
This has been a problem with capybara not assigning anything to the
@request
variable aftervisit
.One solution is to use the rails built-in methods, i.e.
In rspec, i use assertions on
page
rather than@request
.There is some discussion here.