[rspec-users] How do BOTH these examples pass?
Ashley Moran
ashley.moran at patchspace.co.uk
Wed Oct 1 09:26:06 EDT 2008
On 1 Oct 2008, at 14:11, Mikel Lindsaar wrote:
> Changing it to:
>
> def rss
> rss_body =
> begin
> @uri.read
> ::RSS::Parser.parse(rss_body, false)
> rescue OpenURI::HTTPError => e
> nil
> end
> end
Ah don't worry, that's what my real code does. The code I posted was
mid-refactoring.
> Should pass your specs.
It's academic really, but this code:
> def rss
> rss_body =
> begin
> @uri.read
> rescue OpenURI::HTTPError => e
> nil
> end
>
> ::RSS::Parser.parse(rss_body, false)
> end
*does* pass the specs, both the one that says parse should be called,
and the one that say it shouldn't! But why? I'm prepared to admit
I'm just missing something really really really obvious (it happens
often), but how can:
it "should attempt to parse the RSS" do
::RSS::Parser.should_receive(:parse)
@rss_reader.rss
end
it "should not attempt to parse the RSS" do
::RSS::Parser.should_not_receive(:parse)
@rss_reader.rss
end
both pass, under any circumstances?
Ashley
--
http://www.patchspace.co.uk/
http://aviewfromafar.net/
More information about the rspec-users
mailing list