On 10/15/07, Steve <[EMAIL PROTECTED]> wrote: > I'm trying to write some tests for the ApplicationController as shared > tests that can be run in all of my other controller tests, but am getting > a nil.rewrite error. Below is what I have... > > describe AccountController do > it_should_behave_like 'Application controller' > end > > describe 'Application controller', :shared => true do > > it 'should fail require_login check if not logged in' do > User.current = nil > controller.require_login.should be_false > response.should redirect_to(:controller => 'account', :action => 'logon')
You get responses (i.e. the response object in the spec) from actions using get, post, put, delete, not by calling methods directly on the controller. Part of the problem is that you're trying to spec something that already exists. Developing spec-first, you wouldn't likely end up with this problem because this method would have appeared because you refactored it out of an existing action, which was already spec'd. To be honest, I'm not quite sure how to spec this. One way would be to set a message expectation for the call to redirect_to: controller.should_receive(:redirect_to) controller.require_login Anybody else have any ideas? _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users