rspecを使用して(変更されたrestful_authentication認証ソリューションを使用して)current_userのメソッドをスタブ化しようとしています。コントローラの仕様でこのメソッドにアクセスする方法が完全にわかりません。current_user自体は機能しません。最初にコントローラー自体を入手する必要がありますか?どうすればよいですか?
を使用してrails 2.3.5
、rspec 1.3.0
rspec-rails 1.3.2
# my_controller_spec.rb
require 'spec_helper'
describe MyController do
let(:foos){ # some array of foos }
it "fetches foos of current user" do
current_user.should_receive(:foos).and_return(foos)
get :show
end
end
生産する
NoMethodError in 'ChallengesController fetches foos of current user'
undefined method `current_user' for #<Spec::Rails::Example::ControllerExampleGroup::Subclass_1::Subclass_1::Subclass_2::Subclass_2:0x7194b2f4>