[rspec-devel] Should controller specs fail if you don't make a request?
zach.dennis at gmail.com
Thu Apr 10 21:05:07 EDT 2008
On Wed, Apr 9, 2008 at 11:44 PM, Pat Maddox <pergesu at gmail.com> wrote:
> A friend of mine just IMed me asking why his spec didn't pass. It looked
> describe FooController, "POST create" do
> it "should build a new Foo" do
> Foo.should_receive(:new).and_return @mock_foo
> 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.
+1.... controllers aren't intended to be used outside the context of a
request anyways -- even filters -- so I don't think it would be to invasive
for a controller spec,
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the rspec-devel