[Rspec-devel] Mock API - should_not_receive

aslak hellesoy aslak.hellesoy at gmail.com
Wed Aug 30 08:28:56 EDT 2006


On 8/30/06, DeeJay <smartgpx at gmail.com> wrote:
>
>
> I would like to be able to specify that under given circumstances a
> particular message
> from my application is NOT returned to the user. [eg. IF Bank_Balance is
> Positive THEN
> Credit_Status_Report should NOT be "you are overdrawn."]
>
>
> I can do -
>
> specify "correct output" do
>   my_mock_output.should_receive(:msg).with("expected text")
> end
>
> By trying for a PLS solution, I would hope to be able to write -
>
>
> specify "unwanted output" do
>   my_mock_output.should_not_receive(:msg).with("unwanted
> text")
> end
>

I would do:

specify "should not receive unwanted text" do
  # don't expect anything on the mock - it will barf if :msg is sent to it
end

Aslak

> But that fails - it looks as though 'with' is not implemented for
> should_not_receive.
>
> Is there a way of expressing this logic in the API as it stands, or should
> I submit a Feature Request?
>
> Thanks -
>
> DeeJay
>
> _______________________________________________
> Rspec-devel mailing list
> Rspec-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-devel
>
>


More information about the Rspec-devel mailing list