Rails Capybara Problems
|
从Webrat切换到Capybara后,我试图使测试正常工作。当我尝试登录该应用程序时,尽管仅使用Factory_girl在Factory中创建了用户,但仍收到“无效的用户名/密码”错误。以我的理解,用户应该坚持使用整个灯具,对吗?
factory.rb:
Factory.define :user do |user|
user.firstname \"Test\"
user.lastname \"Test\"
user.email \"test@test.com\"
user.password \"testtest\"
user.password_confirmation \"testtest\"
end
layout_links.spec.rb:
describe \"LayoutLinks\" do
before(:each) do
wrong_user = Factory(:user)
integration_sign_in(wrong_user)
end
it \"should have a dashboard page\" do
get \'/dashboard\'
page.should have_css(\'h1\', :text => \"Navigation#dashboard\")
end
spec_helper.rb
def integration_sign_in(user)
visit signin_path
fill_in :email, :with => user.email
fill_in :password, :with => user.password
click_button \"Sign in\"
puts page.body
end
在spec_helper.rb中还包含以下内容:
config.use_transactional_fixtures =否
config.before(:suite) do
DatabaseCleaner.strategy = :truncation
end
config.before(:each) do
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
用户是否应该坚持并成功使用“ 4”功能?我仍然可以通过开发环境中的浏览器正确登录,该浏览器具有一个用户,并且该迁移在迁移之前登录已与webrat一起正常使用,因此我不确定该怎么想。谢谢!
更新:会话似乎无法正确进入服务器。在服务器上,当我在会话中检查电子邮件和密码的值时,这些值不正确:
puts \"Post Email: \" + params[:session][:email]
puts \"Post Password: \" + params[:session][:password]
email变量具有password变量,而password变量没有值。为什么会这样呢?客户端集成测试正确映射了字段:
fill_in :email, :with => user.email
fill_in :password, :with => user.password
我该如何进一步测试?谢谢。
没有找到相关结果
已邀请:
2 个回复
篮肥炼皖
而使用符号失败
雇砰