eg. I'm going to the store to buy one milk I'm going to the store to buy one bagel I'm going to the store to buy one coffee
@shopping_list.should_receive(:milk).once.and_return('milk') @shopping_list.should_receive(:bagel).once.and_return('bagel') @shopping_list.should_receive(:coffee).once.and_return('coffee') I going to the store to buy one: * milk * bagel * coffee @shopping_list.should_receive_the_following( :milk => 'milk' :bagel => 'bagel' :coffee => 'coffee' ).once For the shopping list I describe its expected that they all have the same expectations. I'm still reading the rspec source. 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. You wouldn't expect to return something: @shopping_list.should_receive_the_following( :milk => 'milk' :bagel => 'bagel' :coffee => 'coffee' ).once.and_return(@list) It boggles my mind. I haven't done too much meta programming. I just see these large blocks of: @shopping_list.should_receive(:milk)..and_return('milk') @shopping_list.should_receive(:bagel).and_return('bagel') @shopping_list.should_receive(:coffee).and_return('coffee') and it would be much clearer if I could list them in a hash instead. On Dec 29, 2007 1:29 PM, Pat Maddox <[EMAIL PROTECTED]> wrote: > On Dec 28, 2007 11:00 PM, Andrew WC Brown <[EMAIL PROTECTED]> wrote: > > I was looking over some of my specs. > > I was thinking that the following: > > > > @game.should_receive(:name).and_return('The Battle for Blaze') > > @game.should_receive(:people).and_return(5000000) > > @game.should_receive (:activated).and_return(true) > > > > Would it look cleaner if I could do this instead? > > > > @game.should_recieve_and_return( > > :name => 'The Battle for Blaze' > > :people => 5000000 > > :activated => true) > > > > Opinions? > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users@rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > Two thoughts as to why I wouldn't use this... > > 1. One expectation per example > 2. Stub queries, expect commands > > Your way is clean though. How do you handle arguments? > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
_______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users