Question

In an effort to use Cucumber for a command-line script, I've installed the aruba gem as per the instructions provided. It's in my Gemfile, I can verify that the correct version is installed and I've included

require 'aruba/cucumber'

in 'features/env.rb'

In order to ensure it works, I wrote the following scenario:

@announce
Scenario: Testing cucumber/aruba
    Given a blank slate
Then the output from "ls -la" should contain "drw"

assuming the thing should fail.

It does fail, but it fails for the wrong reasons:

@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"'

Anyone have any ideas why this isn't working? This seems to be very basic aruba behavior.

Was it helpful?

Solution

You are missing a 'When' step - the aruba "output should contain" step requires the command to have already run (it does not run it itself, it only looks it up).

@announce
Scenario: Testing cucumber/aruba
    Given a blank slate
    When I run `ls -la`
    Then the output from "ls -la" should contain "drw"

This produces, on my machine:

@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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top