[rspec-devel] Should controller specs fail if you don't make a request?
Zach Dennis
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
> 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.
>
+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,
--
Zach Dennis
http://www.continuousthinking.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-devel/attachments/20080410/17d5ddbc/attachment.html
More information about the rspec-devel
mailing list