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

David Chelimsky dchelimsky at gmail.com
Fri Mar 26 07:21:26 EDT 2010

On Mar 26, 2010, at 6:16 AM, DEfusion wrote:

> 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).

Controller specs are currently built on rails integration test behaviour. We're going to change that so it's built on rails functional test behaviour and that will solve your issue, but I'm not sure when that will happen. Definitely before final releases of both rspec-2 and rails-3, but there are lots of priorities being juggled in both projects.

Please feel free to raise rspec-2 issues in the appropriate repo in github. In this case: http://github.com/rspec/rspec-rails/issues.


More information about the rspec-users mailing list