On Tue, Oct 7, 2008 at 7:59 AM, Ashley Moran
<[EMAIL PROTECTED]> wrote:
> Hi
>
> Can I still rely on this RSpec behaviour?
>
> I've got a spec for a TCP socket client:
>
> it "should do things in a sane order" do
> @socket.should_receive(:write) do
> @socket.should_receive(:read) do
> @socket.should_receive(:close)
> end
> end
> @client.update_news_feeds
> end
>
> But this passes, where I was expecting it to fail:
>
> def update_news_feeds
> socket = TCPSocket.new(@server, @port)
> socket.read
> socket.write("UPDATE\n")
> socket.close
> end
>
> Has this form of expectation ordering been removed?
As far as I know this form of expectation ordering was never
supported. If you've seen documentation that suggests it should be,
please point me to it so I can resolve the discrepancy.
Ordering in rspec mocks is managed with the #ordered method:
@socket.should_receive(:write).ordered
@socket.should_receive(:read).ordered
@socket.should_receive(:close).ordered
See http://rspec.info/documentation/mocks/message_expectations.html -
almost all the way down the page.
Cheers,
David
>
> Thanks
> Ashley
>
> --
> http://www.patchspace.co.uk/
> http://aviewfromafar.net/
>
>
>
> _______________________________________________
> rspec-users mailing list
> [email protected]
> http://rubyforge.org/mailman/listinfo/rspec-users
>
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users