Ruby 检查来自“的输出”;“命令”;应包含具有NilClass的意外崩溃

Ruby 检查来自“的输出”;“命令”;应包含具有NilClass的意外崩溃,ruby,cucumber,bdd,aruba,Ruby,Cucumber,Bdd,Aruba,为了将Cucumber用于命令行脚本,我按照提供的说明安装了aruba gem。它在我的GEM文件中,我可以验证是否安装了正确的版本,并且我已包括在内 require 'aruba/cucumber' 在“features/env.rb”中 为了确保它正常工作,我编写了以下场景: @announce Scenario: Testing cucumber/aruba Given a blank slate Then the output from "ls -la" should cont

为了将Cucumber用于命令行脚本,我按照提供的说明安装了aruba gem。它在我的GEM文件中,我可以验证是否安装了正确的版本,并且我已包括在内

require 'aruba/cucumber'
在“features/env.rb”中

为了确保它正常工作,我编写了以下场景:

@announce
Scenario: Testing cucumber/aruba
    Given a blank slate
Then the output from "ls -la" should contain "drw"
假设事情会失败

它确实失败了,但失败的原因是错误的:

@announce
Scenario: Testing cucumber/aruba                 
    Given a blank slate                        
    Then the output from "ls -la" should contain "drw"
        You have a nil object when you didn't expect it!
        You might have expected an instance of Array.
        The error occurred while evaluating nil.[] (NoMethodError)
        features/dataloader.feature:9:in `Then the output from "ls -la" should contain "drw"'

有人知道为什么这样不行吗?这似乎是非常基本的aruba行为。

您缺少了一个“When”步骤-aruba“output should contain”步骤要求命令已经运行(它本身不运行,它只是查找)

这在我的机器上产生:

@announce
Scenario: Testing cucumber/aruba                     # features/test_aruba.feature:8
    When I run `ls -la`                                # aruba-0.4.11/lib/aruba/cucumber.rb:56
      $ cd /Users/d.chetlin/dev/mine/ladder/tmp/aruba
      $ ls -la
      total 0
      drwx------  2 d.chetlin  staff   68 Feb 15 23:38 .
      drwx------  7 d.chetlin  staff  238 Feb 15 23:38 ..

    Then the output from "ls -la" should contain "drw" # aruba-0.4.11/lib/aruba/cucumber.rb:86

1 scenario (1 passed)
2 steps (2 passed)
0m0.465s

非常感谢。我假设“ls-la”的输出应该包含“drw”的步骤也运行了该命令。但显然不是这样。如果你不介意接受答案的话,那么我将不胜感激:-)完成。很抱歉这对stackoverflow有点陌生。:-)
@announce
Scenario: Testing cucumber/aruba                     # features/test_aruba.feature:8
    When I run `ls -la`                                # aruba-0.4.11/lib/aruba/cucumber.rb:56
      $ cd /Users/d.chetlin/dev/mine/ladder/tmp/aruba
      $ ls -la
      total 0
      drwx------  2 d.chetlin  staff   68 Feb 15 23:38 .
      drwx------  7 d.chetlin  staff  238 Feb 15 23:38 ..

    Then the output from "ls -la" should contain "drw" # aruba-0.4.11/lib/aruba/cucumber.rb:86

1 scenario (1 passed)
2 steps (2 passed)
0m0.465s