views:

88

answers:

2

I need to test with Cucumber/Webrat the presence of this button:

<%=submit_tag 'Get it'%>

But when I use this custom step:

And I should see a button with a value of "Get it"

that is:

Then /^I should see a button with a value of "([^\"]*)"$/ do |value|
 response.should have_selector("form input[value=#{value}]")
end

I get:

    And I should see a button with a value of "Get it"                       # features/step_definitions/common_steps.rb:181
      unexpected ' ' after 'includesGet' (Nokogiri::CSS::SyntaxError)
      /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/racc/parser.rb:99:in `_racc_do_parse_c'
      /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/racc/parser.rb:99:in `__send__'
      /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/racc/parser.rb:99:in `do_parse'
      ./features/step_definitions/common_steps.rb:182:in `/^I should see a button with a value of "([^\"]*)"$/'

When I test a button with a ONE WORD value it works, so it's the space between "Get" and "it".

Ideas?

Thanks

A: 
And I should see a button named "Get it"

custom_steps.rb

Then /^I should see a button named "([^\"]*)"$/ do |name|
 response.should have_xpath("//input[@type='submit' and @value='#{name}']")
end

Thanks to http://www.vermonster.com/2009/12/16/cucumber-workshop-recap/

Leonardo Dario Perna
A: 

This appears to specifically be a problem with Nokogiri, for me:

page.search("input[value='Next Batch']")   # => Nokogiri::CSS::SyntaxError
page.search("//input[@value='Next Batch']") # => Okay
Kris