升级后的 Rails 和 rspec 现在测试未通过

发布于 2024-12-11 12:18:18 字数 1501 浏览 0 评论 0原文

我不太明白为什么这些测试突然没有通过:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文