网络老鼠 +野科切 + CSS 选择器 +空格=噩梦
我需要使用 Cucumber/Webrat 测试此按钮的存在:
<%=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 "([^\"]*)"$/'
当我使用一个单词值测试按钮时,它可以工作,所以它是“Get”和“it”之间的空格。
有想法吗?
谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
custom_steps.rb
感谢 http://www.vermonster.com/ 2009/12/16/黄瓜研讨会回顾/
custom_steps.rb
Thanks to http://www.vermonster.com/2009/12/16/cucumber-workshop-recap/
对我来说,这似乎是 Nokogiri 的一个问题:
This appears to specifically be a problem with Nokogiri, for me: