5

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.

Arnaud Meuret
  • 985
  • 8
  • 26
Agazoom
  • 618
  • 4
  • 19

1 Answers1

8

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
dlchet
  • 1,053
  • 6
  • 13
  • Thank you. I had assumed that the step 'the output from "ls -la" should contain "drw"' also ran the command. But apparently it does not. Separating the two into two separate steps did the trick. – Agazoom Feb 16 '12 at 15:02
  • if you wouldn't mind accepting the answer, in that case, i would be appreciative :-) – dlchet Feb 16 '12 at 18:24
  • Done. Sorry ... kinda new to this stackoverflow thing. :-) – Agazoom Feb 16 '12 at 20:36