[rspec-devel] Should controller specs fail if you don't make a request?

Ben Mabey ben at benmabey.com
Thu Apr 10 18:59:01 EDT 2008


Pat Maddox wrote:
> A friend of mine just IMed me asking why his spec didn't pass.  It looked like
>
> describe FooController, "POST create" do
>   it "should build a new Foo" do
>     Foo.should_receive(:new).and_return @mock_foo
>   end
> end
>
> I looked at the spec for a second, then looked at the implementation
> and it looked fine (he's retrofitting specs on).  Looked back at the
> spec and realized that he never actually made a request.
>
> So here's my question: should controller specs fail if no request is
> made?  I have NEVER written a controller spec in which I didn't
> _intend_ to make a request, though I have forgotten to make a request
> plenty of times.
>
> I had planned to just implement an expectation error if no request is
> made.  But there's a small chance that that's too invasive.  I highly
> doubt it though.  Does anyone have specs that would incorrectly fail
> as a result of this change?  Please show code if you do.
>
> Pat
> _______________________________________________
> rspec-devel mailing list
> rspec-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-devel
>   
I think that is a great idea Pat.  I have been bitten by this and I have 
helped many people with the same problem.  Someone on #rspec today was 
actually actually complaining about this very thing.

I can't think of a single example of how this change would cause 
anything to fail incorrectly.

Thanks,
Ben


More information about the rspec-devel mailing list