[rspec-users] RSpec 2.0.0.beta.4 stubbing rails controller method issue

DEfusion david.spurr at gmail.com
Fri Mar 26 07:16:56 EDT 2010


I'm trying to stub a controller method using RSpec 2.0.0.beta.4 and
Rails 3 and whenever I attempt to do it I get an error, e.g.

controller.stub!(:current_host).and_return(Factory.build(:host))
post :create

Results in:

    Failure/Error: post :create
    can't convert nil into String
    # (eval):3:in `post'


Removing the stub doesn't cause the error and the post is fails as
expected. In fact even trying to dump the controller before the post
causes this error (as I wasn't sure if it was still controller or had
been moved to an instance variable).


More information about the rspec-users mailing list