On Wed, Apr 22, 2009 at 3:51 PM, Jeff Talbot <jeff.a.tal...@gmail.com>wrote:
> > On Wed, Apr 22, 2009 at 1:17 AM, aslak hellesoy > <aslak.helle...@gmail.com>wrote: > >> >> >> 2009/4/17 Lenny Marks <le...@aps.org> >> >>> I've been doing something similar. I think the benefit of having half the >>> steps(each can be negated) wins over the small impact it has on step >>> readability. Personally I started adding stuff like this(perhaps not as DRY >>> but simple enough): >>> Then /^the correspondence should (not )?have inclusions$/ do |negate| >>> if negate >>> @outcorr.inclusions.should be_empty >>> else >>> @outcorr.inclusions.should_not be_empty >>> end >>> end >>> >> >> Thanks Lenny. You get it. Readability trumps obsessive DRYness. >> Corollary: The value of DRYness diminishes with distance. >> >>> > > This is just a thought, but every solution on this thread, including this > one, indicates to me that something is amiss. > > I don't recall ever seeing a "Then" step without a "should" or "should not" > (I've only come across steps in English so far). To me, this means there's > something special about "Then" steps, and quite possibly the "should" / > "should not" aspect of it should be built into the cucumber grammar. > > I'll be the first one to agree that cucumber steps are not the place to get > cute, and that readability is paramount, but seriously, shouldn't you be > able to negate the core expectation of a step without having to write extra > code? > It's an interesting idea. Could you give an example of how you'd like it to look? How would you like to use this? A step definition example would be great. Aslak > > Jeff > > > >> >>> -lenny >>> >>> On Apr 16, 2009, at 12:03 PM, Joaquin Rivera Padron wrote: >>> >>> wow! even shorter :-) >>> >>> 2009/4/16 Matt Wynne <m...@mattwynne.net> >>> >>>> >>>> On 16 Apr 2009, at 14:06, Joaquin Rivera Padron wrote: >>>> >>>> thanks matt, >>>>> yes, the regexp in the step matcher is a good one to dry it up >>>>> >>>>> So I end up with this one: >>>>> >>>>> Then /^I (should|should not) see the people search form$/ do |maybe| >>>>> people_search_form_should_exist maybe == "should" >>>>> end >>>>> >>>>> and the method: >>>>> >>>>> def people_search_form_should_exist it_should_exist >>>>> _not = "_not" unless it_should_exist >>>>> >>>>> response.send "should#{_not}".to_sym, have_tag('form#frmSearch') >>>>> end >>>>> >>>>> only because I find it easier to read (when I don't need to jump to the >>>>> method), but yours maybe faster (shorter it is), I could come back to it >>>>> later and benchmark both >>>>> >>>> >>>> If you don't mind using the #send (I was trying to help you get rid of >>>> it) then just do this: >>>> >>>> Then /^I (should|should not) see the people search form$/ do |maybe| >>>> response.send maybe.underscore.to_sym, have_tag('form#frmSearch') >>>> end >>>> >>>> >>>> thanks again, >>>>> joaquin >>>>> _______________________________________________ >>>>> rspec-users mailing list >>>>> rspec-users@rubyforge.org >>>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>>> >>>> >>>> Matt Wynne >>>> http://blog.mattwynne.net >>>> http://www.songkick.com >>>> >>>> _______________________________________________ >>>> rspec-users mailing list >>>> rspec-users@rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>> >>> >>> >>> >>> -- >>> www.least-significant-bit.com >>> _______________________________________________ >>> 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 >>> >> >> >> _______________________________________________ >> 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 >
_______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users