Ruby on rails 使用RSpec功能规范测试设备登录时出现无效电子邮件或密码错误
我一直收到无效的电子邮件或密码。当我尝试测试使用Desive实现的登录时,RSpec特性测试中出现错误 规范/特征/在规范rb中签字 spec/factories/users.rbRuby on rails 使用RSpec功能规范测试设备登录时出现无效电子邮件或密码错误,ruby-on-rails,rspec,capybara,Ruby On Rails,Rspec,Capybara,我一直收到无效的电子邮件或密码。当我尝试测试使用Desive实现的登录时,RSpec特性测试中出现错误 规范/特征/在规范rb中签字 spec/factories/users.rb 我已经验证了用户已保存到DB中,并且sing in正在开发中。我相信在您创建用户记录后,字段密码不再具有其原始值。因此,尝试,而不是 fill_in 'Password', with: user.password 使用 fill_in 'Password', with: '12345678' 编辑 你需要打电话确
我已经验证了用户已保存到DB中,并且sing in正在开发中。我相信在您创建用户记录后,字段密码不再具有其原始值。因此,尝试,而不是
fill_in 'Password', with: user.password
使用
fill_in 'Password', with: '12345678'
编辑
你需要打电话确认!在用户记录上,按如下方式更新工厂:
FactoryGirl.define do
factory :user do
email 'user@mail.com'
password '12345678'
password_confirmation '12345678'
factory :admin do
email 'admin@mail.com'
end
ignore { confirm_user true }
after(:build) do |object, evaluator|
object.skip_confirmation! if evaluator.confirm_user
end
end
end
describe "the signin process", :type => :feature do
before :each do
User.make(:email => 'user@example.com', :password => 'caplin')
end
it "signs me in" do
visit '/sessions/new'
within("#session") do
fill_in 'Login', :with => 'user@example.com'
fill_in 'Password', :with => 'password'
end
click_link 'Sign in'
expect(page).to have_content 'Success'
end
end
如果您需要在另一个测试中创建用户而不进行确认,您可以调用create:user,confirm\u user:false我相信在您创建用户记录后,字段密码不再具有其原始值。因此,尝试,而不是
fill_in 'Password', with: user.password
使用
fill_in 'Password', with: '12345678'
编辑
你需要打电话确认!在用户记录上,按如下方式更新工厂:
FactoryGirl.define do
factory :user do
email 'user@mail.com'
password '12345678'
password_confirmation '12345678'
factory :admin do
email 'admin@mail.com'
end
ignore { confirm_user true }
after(:build) do |object, evaluator|
object.skip_confirmation! if evaluator.confirm_user
end
end
end
describe "the signin process", :type => :feature do
before :each do
User.make(:email => 'user@example.com', :password => 'caplin')
end
it "signs me in" do
visit '/sessions/new'
within("#session") do
fill_in 'Login', :with => 'user@example.com'
fill_in 'Password', :with => 'password'
end
click_link 'Sign in'
expect(page).to have_content 'Success'
end
end
如果您需要在另一个测试中创建用户而不进行确认,可以调用create:user,confirm\u user:false您可以像这样更新规范:
FactoryGirl.define do
factory :user do
email 'user@mail.com'
password '12345678'
password_confirmation '12345678'
factory :admin do
email 'admin@mail.com'
end
ignore { confirm_user true }
after(:build) do |object, evaluator|
object.skip_confirmation! if evaluator.confirm_user
end
end
end
describe "the signin process", :type => :feature do
before :each do
User.make(:email => 'user@example.com', :password => 'caplin')
end
it "signs me in" do
visit '/sessions/new'
within("#session") do
fill_in 'Login', :with => 'user@example.com'
fill_in 'Password', :with => 'password'
end
click_link 'Sign in'
expect(page).to have_content 'Success'
end
end
您可以像这样更新规格:
FactoryGirl.define do
factory :user do
email 'user@mail.com'
password '12345678'
password_confirmation '12345678'
factory :admin do
email 'admin@mail.com'
end
ignore { confirm_user true }
after(:build) do |object, evaluator|
object.skip_confirmation! if evaluator.confirm_user
end
end
end
describe "the signin process", :type => :feature do
before :each do
User.make(:email => 'user@example.com', :password => 'caplin')
end
it "signs me in" do
visit '/sessions/new'
within("#session") do
fill_in 'Login', :with => 'user@example.com'
fill_in 'Password', :with => 'password'
end
click_link 'Sign in'
expect(page).to have_content 'Success'
end
end
实际上我也有同样的问题 这对我有帮助 我必须将此文件添加到我的支持文件夹中
实际上我也有同样的问题 这对我有帮助 我必须将此文件添加到我的支持文件夹中
你用水豚来做这个吗。。?是的,我正在使用水豚与poltergeist。您是否在您的rspec帮助中包含此要求“水豚/rspec”,并且水豚显然没有问题。其他的测试通过了,capybara DSL工作得很好。你用capybara做这个吗。。?是的,我正在使用水豚与poltergeist。您是否在您的rspec帮助中包含此要求“水豚/rspec”,并且水豚显然没有问题。其他测试通过,水豚DSL工作正常。User.make应该怎么做?你认为User.create吗?如果是这样的话,我已经试过了,但它不能解决我的问题。不管怎样,我想使用工厂女孩。User.make应该怎么做?你认为User.create吗?如果是这样的话,我已经试过了,但它不能解决我的问题。不管怎样,我想用工厂女孩。不幸的是,这也没用。我没有使用Desive的可确认模块,所以在用户创建后不需要确认用户。所以我不知道。对不起,不幸的是,这也没用。我没有使用Desive的可确认模块,所以在用户创建后不需要确认用户。所以我不知道。对不起,这对我很有帮助!这对我很有帮助!