On Wed, Dec 9, 2009 at 2:16 PM, Wincent Colaiuta <w...@wincent.com> wrote: > El 09/12/2009, a las 19:15, David Chelimsky escribió: > >> On Wed, Dec 9, 2009 at 11:55 AM, Pat Maddox <mailingli...@patmaddox.com> >> wrote: >>> >>> [...@admin, @allowed_user].should all(be_allowed_to_visit(url)) >>> [...@admin, @allowed_user].should all_be_allowed_to_visit(url) > >>> On Dec 9, 2009, at 5:27 AM, David Chelimsky wrote: >>> >>> On Wed, Dec 9, 2009 at 5:41 AM, Rodrigo Rosenfeld Rosas >>> <lboc...@yahoo.com.br> wrote: >>>> >>>> I was thinking that it would be great to add 2 additional methods to >>>> Object: should_all and should_none. >>>> >>>> The idea is that we would be able to write tests like: >>>> >>>> [...@admin, @allowed_user].should_all be_allowed_to_visit(url) >>>> >>>> [...@unprivileged, @non_welcome].should_none be_allowed_to_visit(url) >>>> >>>> Implementation is trivial, but I think that tests would become much >>>> cleaner than: >>>> >>>> [...@admin, @allowed_user].each{|u| u.should be_allowed_to_visit(url)} >>>> >>>> Any thoughts on that? >>> >>> How about: >>> each_of(@admin, @allowed_user).should be_allowed_to_visit(url) >>> none_of(@admin, @allowed_user).should be_allowed_to_visit(url) >>> This gets the cleanliness without adding to Object. > > I'm puzzled as to why people are so focussed on making specs read like plain > text English when they are still developer-facing Ruby code. > > Especially suprised in this case of wanting to avoid the "each + block" > enumeration idiom, which is about as "bread and butter" Ruby as you can get, > readable to anybody who's ever read the first chapter of a Ruby book.
I think that the english text is secondary to doing something which doesn't require mixing another method or methods into all objects. In the early days RSpec added quite a few more methods to Object besides (or perhaps instead of) should and should_not. One of the goals is to minimize disturbing the system being speced. -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users