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
-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