gpt4 book ai didi

ruby-on-rails - 检查用户是否已在设计中注销

转载 作者:数据小太阳 更新时间:2023-10-29 06:45:58 26 4
gpt4 key购买 nike

我正在尝试检查管理员是否在 Rspec 测试中注销。但是通常的signed_in?从 rspec 中看不到方法,它不是 RSpec Devise Helpers 的一部分。

这就是我所拥有的

before (:each) do
@admin = FactoryGirl.create(:administrator)
sign_in @admin
end


it "should allow the admin to sign out" do
sign_out @admin
#@admin.should be_nil
#@admin.signed_in?.should be_false
administrator_signed_in?.should be_false
end

有没有其他方法可以检查管理员的 session ,看看他是否真的登录了?

最佳答案

it "should have a current_user" do
subject.current_user.should_not be_nil
end

发现于 https://github.com/plataformatec/devise/wiki/How-To:-Controllers-and-Views-tests-with-Rails-3-%28and-rspec%29

关于ruby-on-rails - 检查用户是否已在设计中注销,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11159401/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com