On 16 Apr 2009, at 11:22, Joaquin Rivera Padron wrote:

at the moment I do it this way, hiding the complexity out of the steps:

Then /^I should see the people search form$/ do
  people_search_form_exists
end

Then /^I should not see the people search form$/ do
  people_search_form_exists "not"
end

and then the method:

def people_search_form_exists negation = ""
  neg = "_not" unless negation.blank?
  response.send "should#{neg}".to_sym, have_tag('form#frmSearch')
end

this is a simple case, but what do you think about this? any blog post or so

Yeah this is an annoying one isn't it. I sometimes get around it by going old-skool and pulling out the Test::Unit assertion methods instead:

Then /^I (should|should not) see the people search form$/ do | maybe|
      has_matching_tags = current_dom.css('form#frmSearch').length > 0
      assert has_matching_tags == (maybe == "should")
    end

I think that would work. It's shorter, but is it much easier to understand?

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

Reply via email to