为了使用Cucumber作为命令行脚本,我按照提供的说明安装了aruba gem。它在我的Gemfile中,我可以验证是否安装了正确的版本并且我已经包含了
require 'aruba/cucumber'
'feature / 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"'
任何人都有任何想法为什么这不起作用?这似乎是非常基本的阿鲁巴行为。
答案 0 :(得分:8)
你错过了'当'步骤 - aruba“输出应该包含”步骤要求命令已经运行(它本身不运行它,它只查找它)。
@announce
Scenario: Testing cucumber/aruba
Given a blank slate
When I run `ls -la`
Then the output from "ls -la" should contain "drw"
这会在我的机器上生成:
@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