升级后的 Rails 和 rspec 现在测试未通过
我不太明白为什么这些测试突然没有通过:
Failure/Error: @user = test_sign_in(Factory(:user))
NoMethodError:
undefined method `test_sign_in' for #<RSpec::Core::ExampleGroup::Nested_3::Nested_1::Nested_2:0x00000100a908e8>
有很多测试在 test_sign_in 上失败,然后另一个测试失败:
1) SessionsController POST 'create' with valid email and password should sign the user in
Failure/Error: controller.should be_signed_in
NoMethodError:
undefined method `authenticate?' for nil:NilClass
# ./spec/controllers/sessions_controller_spec.rb:51:in `block (4 levels) in <top (required)>'
2) SessionsController DELETE 'destroy' should sign a user out
Failure/Error: controller.should_not be_signed_in
NoMethodError:
undefined method `authenticate?' for nil:NilClass
# ./spec/controllers/sessions_controller_spec.rb:66:in `block (3 levels) in <top (required)>'
3) UsersController POST 'create' success should sign the user in
Failure/Error: controller.should be_signed_in
NoMethodError:
undefined method `authenticate?' for nil:NilClass
# ./spec/controllers/users_controller_spec.rb:171:in `block (4 levels) in <top (required)>'
4) Users sign in/out success should sign a user in and out
Failure/Error: controller.should be_signed_in
expected signed_in? to return true, got false
# ./spec/requests/users_spec.rb:68:in `block (4 levels) in <top (required)>'
I can't quite figure out why these tests aren't passing all of a sudden:
Failure/Error: @user = test_sign_in(Factory(:user))
NoMethodError:
undefined method `test_sign_in' for #<RSpec::Core::ExampleGroup::Nested_3::Nested_1::Nested_2:0x00000100a908e8>
There are a bunch that fail on test_sign_in and then another test that fails:
1) SessionsController POST 'create' with valid email and password should sign the user in
Failure/Error: controller.should be_signed_in
NoMethodError:
undefined method `authenticate?' for nil:NilClass
# ./spec/controllers/sessions_controller_spec.rb:51:in `block (4 levels) in <top (required)>'
2) SessionsController DELETE 'destroy' should sign a user out
Failure/Error: controller.should_not be_signed_in
NoMethodError:
undefined method `authenticate?' for nil:NilClass
# ./spec/controllers/sessions_controller_spec.rb:66:in `block (3 levels) in <top (required)>'
3) UsersController POST 'create' success should sign the user in
Failure/Error: controller.should be_signed_in
NoMethodError:
undefined method `authenticate?' for nil:NilClass
# ./spec/controllers/users_controller_spec.rb:171:in `block (4 levels) in <top (required)>'
4) Users sign in/out success should sign a user in and out
Failure/Error: controller.should be_signed_in
expected signed_in? to return true, got false
# ./spec/requests/users_spec.rb:68:in `block (4 levels) in <top (required)>'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论