Sha256: fa0b27be57188a176d06b5fe9e80989a714b159df38c0a68c78ff21ee1069504

Contents?: true

Size: 1.77 KB

Versions: 8

Compression:

Stored size: 1.77 KB

Contents

Feature: before_cmd hooks

  You can configure Aruba to run blocks of code before it runs
  each command.

  The command will be passed to the block.

  You can hook into Aruba's lifecycle just before it runs a command and after it has run the command:

  ```ruby
  Aruba.configure do |config|
    config.before :command do |cmd|
      puts "About to run '#{cmd}'"
    end
  end
  ```

  Background:
    Given I use a fixture named "cli-app"

  Scenario: Run a simple command with a "before(:command)"-hook
    Given a file named "spec/support/hooks.rb" with:
    """
    Aruba.configure do |config|
      config.before :command do |cmd|
        puts "before the run of `#{cmd.commandline}`"
      end
    end
    """
    And a file named "spec/hook_spec.rb" with:
    """
    require 'spec_helper'

    RSpec.describe 'Hooks', :type => :aruba do
      before(:each) { run_simple 'echo running' }

      it { expect(last_command_started.stdout.chomp).to eq 'running' }
    end
    """
    When I run `rspec`
    Then the specs should all pass
    And the output should contain:
    """
    before the run of `echo running`
    """

  Scenario: Run a simple command with a "before(:cmd)"-hook (deprecated)
    Given a file named "spec/support/hooks.rb" with:
    """
    Aruba.configure do |config|
      config.before :cmd do |cmd|
        puts "before the run of `#{cmd}`"
      end
    end
    """
    And a file named "spec/hook_spec.rb" with:
    """
    require 'spec_helper'

    RSpec.describe 'Hooks', :type => :aruba do
      before(:each) { run_simple 'echo running' }

      it { expect(last_command_started.stdout.chomp).to eq 'running' }
    end
    """
    When I run `rspec`
    Then the specs should all pass
    And the output should contain:
    """
    before the run of `echo running`
    """

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
aruba-win-fix-0.14.2 features/hooks/before/command.feature
aruba-0.14.2 features/hooks/before/command.feature
aruba-0.14.1 features/hooks/before/command.feature
aruba-0.14.0 features/hooks/before/command.feature
aruba-0.13.0 features/hooks/before/command.feature
aruba-0.12.0 features/hooks/before/command.feature
aruba-0.11.2 features/hooks/before/command.feature
aruba-0.11.1 features/hooks/before/command.feature