2010-09-14 57 views
1

我需要與黃瓜/ Webrat測試這個按鈕的存在:webrat +引入nokogiri + CSS選擇+空格=夢魘

<%=submit_tag 'Get it'%> 

但是,當我使用此自定義步驟:

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

那是:

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

我得到:

 
    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 "([^\"]*)"$/' 

當我測試一個帶有ONE WORD值的按鈕時,它的作用是,所以它是「Get」和「it」之間的空格。

想法?

感謝

回答

0

這似乎專門與引入nokogiri一個問題,對我來說:

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