Ruby on rails 如何使用已登录的Desive用户?集成测试中的方法?

Ruby on rails 如何使用已登录的Desive用户?集成测试中的方法?,ruby-on-rails,devise,Ruby On Rails,Devise,当我在集成测试中有assert user\u signed\u in?时,它会说该方法未定义。有没有一种方法可以在我的测试中使用这种方法?我使用的是rails 4和Desive的最新版本。这是我的测试文件: require 'test_helper' class UsersSignupTest < ActionDispatch::IntegrationTest test "valid signup information" do get new_user_registratio

当我在集成测试中有
assert user\u signed\u in?
时,它会说该方法未定义。有没有一种方法可以在我的测试中使用这种方法?我使用的是rails 4和Desive的最新版本。这是我的测试文件:

require 'test_helper'

class UsersSignupTest < ActionDispatch::IntegrationTest

test "valid signup information" do
    get new_user_registration_path
    assert_difference 'User.count', 1 do
      post_via_redirect user_registration_path, 
                                     user: { first_name: "Example",
                                             last_name:  "User",
                                             email:      "user@example.org",
                                             password:              "password",
                                             password_confirmation: "password" }
    end
    assert_template 'activities/index'
    assert user_signed_in?
  end
需要“测试助手”
类UsersSignupTest
用户登录的
方法包含在集成测试中不可用的
设计::控制器::助手
模块中,因此您无法使用该模块

您可以选择模拟此方法(这将无法真正满足您的测试需求),或者通过查找仅在用户登录时才会呈现的页面内容(例如
注销
链接或
成功登录
消息)来测试用户是否已登录


对于控制器测试,您可以使用designe test helpers
include designe::TestHelpers
,它为您公开了一个
登录
注销
方法,更多信息请访问Gem主页

我们需要更多信息。请阅读有关如何创建最小、完整和可验证示例的建议:抱歉,已修复