ruby-on-rails – 黄瓜没有找到步骤定义

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – 黄瓜没有找到步骤定义前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我的黄瓜只是找不到步骤定义.文件结构(只有Rails根目录下的specs文件夹)如下所示:
  1. -> specs
  2. -> features
  3. -> main_structure.feature
  4. -> step_definitions
  5. -> main_structure_steps.rb

这是main_structure.feature:

  1. Feature: Main structure
  2. Scenario: Viewing the Structure page
  3. When I am on the structure page

这是main_structure_steps.rb:

  1. When(/^I am on the structure page$/) do
  2. visit '/'
  3. end

现在我像这样运行黄瓜命令:

  1. cucumber spec/features -r features

我得到这个输出

  1. Using the default profile...
  2. Feature: Main structure
  3.  
  4. Scenario: Viewing the Structure page # spec/features/main_structure.feature:2
  5. When I am on the structure page # spec/features/main_structure.feature:3
  6. Undefined step: "I am on the structure page" (Cucumber::Undefined)
  7. spec/features/main_structure.feature:3:in `When I am on the structure page'
  8.  
  9. 1 scenario (1 undefined)
  10. 1 step (1 undefined)
  11. 0m0.229s
  12.  
  13. You can implement step definitions for undefined steps with these snippets:
  14.  
  15. When(/^I am on the structure page$/) do
  16. pending # express the regexp above with the code you wish you had
  17. end
  18.  
  19. /Users/rudolf/.rvm/gems/ruby-2.0.0-p247@global/gems/minitest-4.7.5/lib/minitest/unit.rb:1037:in `block in process_args': invalid option: -r (OptionParser::InvalidOption)
  20. from /Users/rudolf/.rvm/gems/ruby-2.0.0-p247@global/gems/minitest-4.7.5/lib/minitest/unit.rb:1016:in `new'
  21. from /Users/rudolf/.rvm/gems/ruby-2.0.0-p247@global/gems/minitest-4.7.5/lib/minitest/unit.rb:1016:in `process_args'
  22. from /Users/rudolf/.rvm/gems/ruby-2.0.0-p247@global/gems/minitest-4.7.5/lib/minitest/unit.rb:1066:in `_run'
  23. from /Users/rudolf/.rvm/gems/ruby-2.0.0-p247@global/gems/minitest-4.7.5/lib/minitest/unit.rb:1059:in `run'
  24. from /Users/rudolf/.rvm/gems/ruby-2.0.0-p247@global/gems/minitest-4.7.5/lib/minitest/unit.rb:795:in `block in autorun'

底部还有一条错误消息,当我在RubyMine中运行测试时,它不会出现.但在这两种情况下,都找不到步骤定义.这是Rubymine的输出

  1. Testing started at 21:29 ...
  2.  
  3.  
  4. You can implement step definitions for undefined steps with these snippets:
  5.  
  6. When(/^I am on the structure page$/) do
  7. pending # express the regexp above with the code you wish you had
  8. end
  9. 1 scenario (1 undefined)
  10. 1 step (1 undefined)
  11. 0m0.001s
  12.  
  13. Process finished with exit code 0

如果您需要任何其他信息,请告诉我.

解决方法

尝试
  1. cucumber spec/features/main_structure.feature -r spec/features

猜你在找的Ruby相关文章