Cucumber Failing with Nokogiri

好久不见. 提交于 2019-12-13 06:44:06

问题


I just started using Cucumber and in the simplest of scenarios I throw the following error:

undefined method has_key?' for #<Nokogiri::XML::Element:0x10677a400> (NoMethodError) ./features/step_definitions/web_steps.rb:36:in/^(?:|I )fill in "([^"])" with "([^"])"$/' features/authentication.feature:9:in `When I fill in "user_name" with "Joe User"'

The Scenario is as follows...

Scenario: Signup Given I go to the signup page When I fill in "user_name" with "Joe User"

Is this a problem in the Scenario, Cucumber, or Nokogiri? Any Solutions?


回答1:


OK, here's the scoop. Apparently there is some problem related to webrat when using the following gems: cucumber 0.8.0, cucumber-rails 0.3.2, nokogiri 1.4.2, webrat 0.7.1

I reconfigured with the following...

script/generate cucumber --rspec --capybara

and all was happy.




回答2:


If you are using the linkedin gem, it turns out this is an issue with ROXML monkey-patching Nokogiri. See http://github.com/pengwynn/linkedin/issues#issue/4. You can re-monkey-patch a quick fix by adding this to linkedin/lib/linkedin.rb:

class Nokogiri::XML::Element
  def has_key?(key)
    self.keys.include?(key)
  end
end

(source http://github.com/caike/linkedin/commit/011370f5d9d002a140a99a59a09866922ecf969f)



来源:https://stackoverflow.com/questions/3026033/cucumber-failing-with-nokogiri

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!