Contents

Return last command started

Background:

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

Scenario: A command has been started

  • Given a file named "spec/run_spec.rb" with:
    ruby
    require 'spec_helper'
    
    RSpec.describe 'Run command', :type => :aruba do
      before { run_command('echo hello') }
      before { stop_all_commands }
    
      it { expect(last_command_started).to be_successfully_executed }
      it { expect(last_command_started.commandline).to eq 'echo hello' }
    end
  • When I run `rspec`
  • Then the specs should all pass

Scenario: Multiple commands have been started

  • Given a file named "spec/run_spec.rb" with:
    ruby
    require 'spec_helper'
    
    RSpec.describe 'Run command', :type => :aruba do
      before { run_command('echo hello') }
      before { run_command('echo world') }
    
      before { stop_all_commands }
    
      it { expect(last_command_started).to be_successfully_executed }
      it { expect(last_command_started.commandline).to eq 'echo world' }
    end
  • When I run `rspec`
  • Then the specs should all pass

Scenario: No command has been started

  • Given a file named "spec/run_spec.rb" with:
    ruby
    require 'spec_helper'
    
    RSpec.describe 'Run command', :type => :aruba do
      it { expect{ last_command_started.commandline }.to raise_error Aruba::NoCommandHasBeenStartedError }
    end
  • When I run `rspec`
  • Then the specs should all pass

Source: features/04_aruba_api/command/use_last_command_started.feature at commit c39310a7, Aruba (MIT license).