eg.<br>I'm going to the store to buy one milk<br>I'm going to the store to buy one bagel<br>I'm going to the store to buy one coffee<br><br>@shopping_list.should_receive(:milk).once.and_return('milk')<br>
@shopping_list.should_receive(:bagel).once.and_return('bagel')<br>@shopping_list.should_receive(:coffee).once.and_return('coffee')<br><br>I going to the store to buy one:<br> * milk<br> * bagel<br> * coffee
<br><br>@shopping_list.should_receive_the_following(<br>
:milk => 'milk'<br>
:bagel => 'bagel'<br>
:coffee => 'coffee'<br>).once<br><br>For the shopping list I describe its expected that they all have the same expectations.<br>I'm still reading the rspec source.<br><br>I would think of creating a new method called: should_receive_the_following but seeing how the message_expectations work not sure how plausible it would be to implement.
<br><br>You wouldn't expect to return something:<br><br>
@shopping_list.should_receive_the_following(<br>
:milk => 'milk'<br>
:bagel => 'bagel'<br>
:coffee => 'coffee'<br>
).once.and_return(@list)<br><br>It boggles my mind. I haven't done too much meta programming.<br><br>I just see these large blocks of:<br><br>@shopping_list.should_receive(:milk)..and_return('milk')<br>
@shopping_list.should_receive(:bagel).and_return('bagel')<br>
@shopping_list.should_receive(:coffee).and_return('coffee')<br><br>and it would be much clearer if I could list them in a hash instead.<br><br><br><div class="gmail_quote">On Dec 29, 2007 1:29 PM, Pat Maddox <
<a href="mailto:pergesu@gmail.com">pergesu@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">On Dec 28, 2007 11:00 PM, Andrew WC Brown <
<a href="mailto:omen.king@gmail.com">omen.king@gmail.com</a>> wrote:<br>> I was looking over some of my specs.<br>> I was thinking that the following:<br>><br>> @game.should_receive(:name).and_return('The Battle for Blaze')
<br>> @game.should_receive(:people).and_return(5000000)<br>> @game.should_receive (:activated).and_return(true)<br>><br>> Would it look cleaner if I could do this instead?<br>><br>> @game.should_recieve_and_return
(<br>> :name => 'The Battle for Blaze'<br>> :people => 5000000<br>> :activated => true)<br>><br>> Opinions?<br>><br>> _______________________________________________<br>> rspec-users mailing list
<br>> <a href="mailto:rspec-users@rubyforge.org">rspec-users@rubyforge.org</a><br>> <a href="http://rubyforge.org/mailman/listinfo/rspec-users" target="_blank">http://rubyforge.org/mailman/listinfo/rspec-users</a><br>
><br><br>Two thoughts as to why I wouldn't use this...<br><br>1. One expectation per example<br>2. Stub queries, expect commands<br><br>Your way is clean though. How do you handle arguments?<br><br>Pat<br>_______________________________________________
<br>rspec-users mailing list<br><a href="mailto:rspec-users@rubyforge.org">rspec-users@rubyforge.org</a><br><a href="http://rubyforge.org/mailman/listinfo/rspec-users" target="_blank">http://rubyforge.org/mailman/listinfo/rspec-users
</a><br></blockquote></div><br>