Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 在测试失败的视图中使用CanCanCan_Ruby_Ruby On Rails 3_Rspec_Cancancan - Fatal编程技术网

Ruby 在测试失败的视图中使用CanCanCan

Ruby 在测试失败的视图中使用CanCanCan,ruby,ruby-on-rails-3,rspec,cancancan,Ruby,Ruby On Rails 3,Rspec,Cancancan,嗨,我有一个具有以下能力的项目: can :set_to_user, Post 我的一个观点是: <div class: "btn btn-primary #{disable_button(!(can_set_to_user))}> 我不确定是什么原因导致了这种情况,但任何帮助都会很好Warden::Proxy用于当前用户和用户登录?方法。 您必须在视图规范中存根这些方法才能使其正常工作: let(:user) { FactoryGirl.create :user } bef

嗨,我有一个具有以下能力的项目:

 can :set_to_user, Post
我的一个观点是:

<div class: "btn btn-primary #{disable_button(!(can_set_to_user))}>

我不确定是什么原因导致了这种情况,但任何帮助都会很好

Warden::Proxy
用于
当前用户
用户登录?
方法。 您必须在视图规范中存根这些方法才能使其正常工作:

let(:user) { FactoryGirl.create :user }

before(:example) do
  allow(view).to receive(:current_user).and_return(user)
  allow(view).to receive(:user_signed_in?).and_return(!!user)
end

let(:user) { FactoryGirl.create :user }

before(:example) do
  allow(view).to receive(:current_user).and_return(user)
  allow(view).to receive(:user_signed_in?).and_return(!!user)
end