黄瓜因Nokogiri而失败

发布于 2024-09-04 23:02:40 字数 444 浏览 1 评论 0原文

我刚刚开始使用 Cucumber,在最简单的情况下,我抛出以下错误:

未定义的方法 has_key?'对于#(无方法错误) ./features/step_definitions/web_steps.rb:36:in/^(?:|I )将“([^”])”填入“([^”]) “$/” features/authentication.feature:9:in `当我用“Joe User”填写“user_name”时'

场景如下...

场景:注册 鉴于我进入注册页面 当我用“Joe User”填写“user_name”时,

这是场景、Cucumber 或 Nokogiri 中的问题吗?有什么解决方案吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

你的他你的她 2024-09-11 23:02:40

好的,这是独家新闻。显然,使用以下 gem 时存在与 webrat 相关的问题:cucumber 0.8.0、cucumber-rails 0.3.2、nokogiri 1.4.2、webrat 0.7.1

我使用以下命令重新配置...

script/generate cucumber --rspec ——水豚

,一切都很快乐。

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.

猫卆 2024-09-11 23:02:40

如果您使用 linkedin gem,则会发现这是 ROXML 猴子修补 Nokogiri 的问题。请参阅http://github.com/pengwynn/linkedin/issues#issue/4。您可以通过将其添加到 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)

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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文