ruby-on-rails - "rake"可以正常运行我所有的 Cucumber 测试,但是 "cucumber"没有这些步骤

标签 ruby-on-rails ruby-on-rails-3 cucumber

我继承了一个 Rails (3) 应用程序,并试图掌握现有的 Cucumber 测试。我在应用程序的“功能”文件夹中有以下设置(我遗漏了任何不相关的文件,例如额外的功能和步骤)

/features
  /people
    new-person.feature
  /step_definitions
    people_steps.rb
    web_steps.rb
  /support
    env.rb
    paths.rb
    selectors.rb

如果我运行“rake”,那么它会正确使用 step_definitions 中列出的步骤运行 features/people/new-person.feature 中的所有功能。

但是,我不想每次都运行 rake 因为它需要太长时间,我只想在 Cucumber 中运行一个特定的测试,例如cucumber features/people/new-person.feature -l 8
当我这样做时,它运行该功能但尚未加载步骤。我得到这个:
Using the default profile...
Feature: Add a new person
  In order to allocate tasks to people
  As a community manager
  I want to add a new person

  Scenario: Secondary navigation should contain "Add new person" # features/people/new-person.feature:8
    Given I am on the new person page                            # features/people/new-person.feature:9
      Undefined step: "I am on the new person page" (Cucumber::Undefined)
      features/people/new-person.feature:9:in `Given I am on the new person page'
    Then I should not see "Add new person"                       # features/people/new-person.feature:10
      Undefined step: "I should not see "Add new person"" (Cucumber::Undefined)
      features/people/new-person.feature:10:in `Then I should not see "Add new person"'

1 scenario (1 undefined)
2 steps (2 undefined)
0m0.005s

You can implement step definitions for undefined steps with these snippets:

Given /^I am on the new person page$/ do
  pending # express the regexp above with the code you wish you had
end

Then /^I should not see "([^"]*)"$/ do |arg1|
  pending # express the regexp above with the code you wish you had
end

If you want snippets in a different programming language, just make sure a file
with the appropriate file extension exists where cucumber looks for step definitions.

为什么 Cucumber 没有加载步骤?我猜我需要在某个地方要求这些步骤,但我不知道在哪里。

谢谢,马克斯

最佳答案

Max Williams 找到了他问题的答案:

编辑 - 在这里找到答案:https://rspec.lighthouseapp.com/projects/16211/tickets/401-envrb-not-loaded-when-running-individual-features-in-sub-directories

在 config/cucumber.yml 中有一行看起来像这样:
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
将其更改为
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip --require features/"
这就像添加 --require features/到您的 cucumber 测试运行结束,并使其正确加载所有内容。

关于ruby-on-rails - "rake"可以正常运行我所有的 Cucumber 测试,但是 "cucumber"没有这些步骤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6264030/

相关文章:

ruby - 使用 watir-webdriver 在 Internet Explorer 上设置 cookie

ruby-on-rails - 将配置文件模型的某些属性设置为对其他用户公开(可见)或私有(private)(不可见)的最佳方法是什么?

ruby-on-rails - Rails View Helper 是如何工作的

ruby-on-rails - Steak gem 解决什么问题?

rspec - 使用 Modular Sinatra 应用程序设置 Cucumber、Capybara 和 RSpec

ruby-on-rails - 日志 rails 控制台总是在生产环境中归档

ruby-on-rails - Rails 3 capybara 错误

ruby-on-rails - 在多服务器环境中,如果站点不活动时间超过 1500 万,服务器将失去与 PostgreSQL 数据库的连接

ruby-on-rails - Devise gem 中的 'skip session storage' 是什么意思?

ruby-on-rails - 覆盖注册 Controller 时设计 'Unknown action'