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?
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.
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)
精彩评论