2

我在这里扯头发。在 Spork 兼容模式 (--drb) 下运行 Cucumber 时,visit()方法不起作用。

只需尝试功能步骤:

When I go to the home page

调用 web 步骤:

When /^(?:|I )go to (.+)$/ do |page_name|
  visit path_to(page_name)
end

在命令行上运行“cucumber”会产生以下错误:

% cucumber
Using the default profile...
Disabling profiles...
.F--

(::) failed steps (::)

undefined method `visit' for #<Object:0x82fcc588> (NoMethodError)
./features/step_definitions/web_steps.rb:24:in `/^(?:|I )go to (.+)$/'
features/authenticated/home_page_visit.feature:10:in `When I go to the home page'

Failing Scenarios:
cucumber features/authenticated/home_page_visit.feature:7 # Scenario: Visit the home page

有谁知道为什么 visit() 不可用?


我的环境:

我正在使用 Rails 2.3.9 并且刚刚安装了 cucumber-rails (0.3.2)、cucumber (0.9.2)、capybara (0.3.9) 和 spork (0.8.4)。有趣的是,如果我不使用 Spork,那么这绝对可以正常工作:

% cucumber
Using the default profile...
...

1 scenario (1 passed)
3 steps (3 passed)
0m0.114s

另一个有趣的数据点:

我做了一些调试并深入到 Cucumber gem 本身(在 cucumber-0.9.2/lib/cucumber/core_ext/instance_exec.rb 中)我放入了puts()以将self.class.name转储到stdout,当我使用 Spork 运行时,它会吐出“Object”,但是当我不使用 Spork 运行它时,它会打印出“Cucumber::Rails::World”。

4

1 回答 1

0

我是在 github 上打开这个问题的人,我可以确认它适用于 cucumber 0.9.3 及更高版本。

于 2011-02-27T19:30:39.437 回答