DEfusion
2010-Mar-26 11:16 UTC
[rspec-users] RSpec 2.0.0.beta.4 stubbing rails controller method issue
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).
David Chelimsky
2010-Mar-26 11:21 UTC
[rspec-users] RSpec 2.0.0.beta.4 stubbing rails controller method issue
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. Thanks!