On Sep 2, 6:06 am, Stephen Eley wrote: > Why isn't current_user available to your controller specs? If you > defined it in ApplicationController, and your controller inherits from > that, then it's just another method on your controller. You may or > may not want to stub it for convenience, to return a mock or a factory > model, but it should be accessible either way.
Thanks for the insight. After poking around a little with debugger I can see that the controller has access to current_user, but the spec tests do not. So I copied the helper methods into a module and included them in the spec_helper. Now the tests have access to current_user. However, I still can't seem to get a should_receive expectation work for the build method without mocking everything out. Any ideas on what I'm missing. describe FollowsController do before(:each) do @user = User.make login_as(@user) end describe "POST create" do it "should build a follow" do current_user.follows.should_receive(:build) post :create, :followed_id => "999" end end end Spec::Mocks::MockExpectationError in 'FollowsController POST create should build a follow' expected :build with (any args) once, but received it 0 times _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users