Contents

Running shell commands

You can run an ad hoc script with the following steps:

  • When I run the following script:

Or you can run shell commands with:

  • I run the following (commands|script):
  • I run the following (commands|script) (in|with) \interpreter\:
  • I run the following (commands|script) (in|with) \/path/to/interpreter\:

Background:

  • Given I use a fixture named "cli-app"

Scenario: Creating and running scripts

@requires-ruby

  • Given a file named "features/shell.feature" with:
    gherkin
    Feature: Running scripts
      Scenario: Running ruby script
        When I run the following script:
        \"\"\"bash
        #!/usr/bin/env ruby
    
        puts "Hello"
        \"\"\"
        Then the output should contain exactly "Hello"
  • When I run `cucumber`
  • Then the features should all pass

Scenario: Running shell commands

@requires-bash

  • Given a file named "features/shell.feature" with:
    gherkin
    Feature: Running scripts
      Scenario: Running shell commands
        When I run the following commands:
        \"\"\"bash
        echo "Hello shell"
        \"\"\"
        Then the output should contain exactly "Hello shell"
  • When I run `cucumber`
  • Then the features should all pass

Scenario: Running commands with a named interpreter

  • Given a file named "features/shell.feature" with:
    gherkin
    Feature: Running scripts
      Scenario: Running ruby commands
        When I run the following commands with `ruby`:
        \"\"\"
        puts "Hello, Aruba!"
        \"\"\"
        Then the output should contain exactly "Hello, Aruba!"
  • When I run `cucumber`
  • Then the features should all pass

Scenario: Running commands if full path to interpreter is given

@requires-bash

  • Given a file named "features/shell.feature" with:
    gherkin
    Feature: Running full path
      Scenario: Running full path bash
        When I run the following commands with `/bin/bash`:
        \"\"\"bash
        echo "Hello Aruba!"
        \"\"\"
        Then the output should contain "Hello Aruba!"
  • When I run `cucumber`
  • Then the features should all pass

Source: features/03_testing_frameworks/cucumber/steps/command/run_commands_which_require_a_shell.feature at commit c39310a7, Aruba (MIT license).