aruba 0.7.4 → 0.8.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.nav +12 -0
- data/.rspec +1 -0
- data/.rubocop.yml +12 -0
- data/.simplecov +2 -0
- data/.travis.yml +5 -6
- data/Gemfile +53 -26
- data/History.md +17 -0
- data/LICENSE +1 -1
- data/README.md +45 -19
- data/Rakefile +12 -2
- data/TODO.md +3 -0
- data/aruba.gemspec +19 -8
- data/cucumber.yml +1 -1
- data/features/api/cd.feature +119 -0
- data/features/api/command/run.feature +37 -0
- data/features/api/command/which.feature +37 -0
- data/features/api/environment/append_environment_variable.feature +118 -0
- data/features/api/environment/prepend_environment_variable.feature +118 -0
- data/features/api/environment/set_environment_variable.feature +252 -0
- data/features/configuration/exit_timeout.feature +51 -0
- data/features/configuration/fixtures_directories.feature +31 -0
- data/features/configuration/fixtures_path_prefix.feature +24 -0
- data/features/configuration/io_timeout.feature +31 -0
- data/features/configuration/keep_ansi.feature +31 -0
- data/features/configuration/root_directory.feature +31 -0
- data/features/configuration/working_directory.feature +32 -0
- data/features/fixtures/cli-app/.gitignore +9 -0
- data/features/fixtures/cli-app/.rspec +2 -0
- data/features/fixtures/cli-app/README.md +34 -0
- data/features/fixtures/cli-app/Rakefile +1 -0
- data/features/fixtures/cli-app/bin/cli +6 -0
- data/features/fixtures/cli-app/cli-app.gemspec +26 -0
- data/features/fixtures/cli-app/features/support/env.rb +1 -0
- data/features/fixtures/cli-app/lib/cli/app.rb +13 -0
- data/features/fixtures/cli-app/lib/cli/app/version.rb +5 -0
- data/features/fixtures/cli-app/script/console +14 -0
- data/features/fixtures/cli-app/spec/cli/app_spec.rb +7 -0
- data/features/fixtures/cli-app/spec/spec_helper.rb +10 -0
- data/features/fixtures/copy/file.txt +1 -1
- data/features/hooks/after/command.feature +34 -0
- data/features/hooks/before/command.feature +61 -0
- data/features/matchers/directory/have_sub_directory.feature +110 -0
- data/features/matchers/file/be_existing_file.feature +82 -0
- data/features/matchers/file/have_file_content.feature +123 -0
- data/features/matchers/file/have_file_size.feature +107 -0
- data/features/matchers/path/be_an_absolute_path.feature +74 -0
- data/features/matchers/path/be_an_existing_path.feature +97 -0
- data/features/matchers/path/have_permissions.feature +118 -0
- data/features/matchers/timeouts.feature +48 -0
- data/features/step_definitions/aruba_dev_steps.rb +69 -1
- data/features/steps/commands/exit_statuses.feature +136 -0
- data/features/steps/commands/in_process.feature +129 -0
- data/features/steps/commands/run.feature +36 -0
- data/features/steps/environment/home_variable.feature +49 -0
- data/features/steps/environment/set_environment_variable.feature +34 -0
- data/features/support/aruba.rb +5 -0
- data/features/support/env.rb +8 -4
- data/lib/aruba.rb +20 -8
- data/lib/aruba/announcer.rb +1 -0
- data/lib/aruba/api.rb +18 -1179
- data/lib/aruba/api/command.rb +351 -0
- data/lib/aruba/api/core.rb +141 -0
- data/lib/aruba/api/deprecated.rb +549 -0
- data/lib/aruba/api/environment.rb +61 -0
- data/lib/aruba/api/filesystem.rb +305 -0
- data/lib/aruba/api/rvm.rb +39 -0
- data/lib/aruba/aruba_path.rb +75 -0
- data/lib/aruba/basic_configuration.rb +208 -0
- data/lib/aruba/basic_configuration/option.rb +25 -0
- data/lib/aruba/config.rb +43 -30
- data/lib/aruba/config/jruby.rb +14 -0
- data/lib/aruba/config_wrapper.rb +17 -0
- data/lib/aruba/contracts/relative_path.rb +13 -0
- data/lib/aruba/creators/aruba_file_creator.rb +32 -0
- data/lib/aruba/creators/aruba_fixed_size_file_creator.rb +32 -0
- data/lib/aruba/cucumber.rb +87 -53
- data/lib/aruba/cucumber/hooks.rb +65 -10
- data/lib/aruba/environment.rb +121 -0
- data/lib/aruba/errors.rb +3 -0
- data/lib/aruba/extensions/string/strip.rb +24 -0
- data/lib/aruba/hooks.rb +54 -0
- data/lib/aruba/jruby.rb +4 -9
- data/lib/aruba/matchers/command.rb +1 -79
- data/lib/aruba/matchers/command/be_successfully_executed.rb +30 -0
- data/lib/aruba/matchers/command/have_exit_status.rb +47 -0
- data/lib/aruba/matchers/command/have_finished_in_time.rb +42 -0
- data/lib/aruba/matchers/directory.rb +1 -59
- data/lib/aruba/matchers/directory/be_an_existing_directory.rb +34 -0
- data/lib/aruba/matchers/directory/have_sub_directory.rb +49 -0
- data/lib/aruba/matchers/file.rb +1 -177
- data/lib/aruba/matchers/file/be_an_existing_file.rb +34 -0
- data/lib/aruba/matchers/file/have_file_content.rb +58 -0
- data/lib/aruba/matchers/file/have_file_size.rb +43 -0
- data/lib/aruba/matchers/file/have_same_file_content.rb +44 -0
- data/lib/aruba/matchers/path.rb +1 -99
- data/lib/aruba/matchers/path/a_path_matching_pattern.rb +21 -0
- data/lib/aruba/matchers/path/be_an_absolute_path.rb +32 -0
- data/lib/aruba/matchers/path/be_an_existing_path.rb +33 -0
- data/lib/aruba/matchers/path/have_permissions.rb +60 -0
- data/lib/aruba/matchers/path/match_path_pattern.rb +41 -0
- data/lib/aruba/matchers/rspec.rb +0 -0
- data/lib/aruba/matchers/rspec_matcher_include_regexp.rb +1 -1
- data/lib/aruba/platform.rb +230 -0
- data/lib/aruba/process_monitor.rb +23 -5
- data/lib/aruba/processes/basic_process.rb +35 -1
- data/lib/aruba/processes/debug_process.rb +26 -15
- data/lib/aruba/processes/in_process.rb +21 -9
- data/lib/aruba/processes/spawn_process.rb +29 -19
- data/lib/aruba/reporting.rb +2 -0
- data/lib/aruba/rspec.rb +61 -13
- data/lib/aruba/runtime.rb +33 -0
- data/script/bootstrap +4 -6
- data/spec/aruba/api/runtime_spec.rb +28 -0
- data/spec/aruba/api_spec.rb +129 -126
- data/spec/aruba/aruba_path_spec.rb +65 -0
- data/spec/aruba/basic_configuration_spec.rb +5 -0
- data/spec/aruba/config_wrapper_spec.rb +25 -0
- data/spec/aruba/configuration_spec.rb +5 -0
- data/spec/aruba/jruby_spec.rb +34 -18
- data/spec/aruba/matchers/directory_spec.rb +6 -7
- data/spec/aruba/matchers/file_spec.rb +16 -20
- data/spec/aruba/matchers/path_spec.rb +14 -11
- data/spec/aruba/rspec_spec.rb +15 -0
- data/spec/aruba/runtime_spec.rb +29 -0
- data/spec/aruba/spawn_process_spec.rb +2 -2
- data/spec/spec_helper.rb +10 -2
- data/spec/support/configs/rspec.rb +1 -1
- data/spec/support/matchers/option.rb +35 -0
- data/spec/support/shared_contexts/aruba.rb +10 -8
- data/spec/support/shared_examples/configuration.rb +116 -0
- metadata +182 -33
- data/.rvmrc +0 -1
- data/features/before_cmd_hooks.feature +0 -61
- data/features/command_environment_variables.feature +0 -31
- data/features/custom_ruby_process.feature +0 -12
- data/features/exit_statuses.feature +0 -30
- data/features/support/custom_main.rb +0 -28
- data/lib/aruba/matchers/mode.rb +0 -52
- data/lib/aruba/utils.rb +0 -21
@@ -0,0 +1,51 @@
|
|
1
|
+
Feature: Configure timeout for command execution
|
2
|
+
|
3
|
+
As a developer
|
4
|
+
I want to configure the timeout when executing a command
|
5
|
+
In order to support some longer running commands
|
6
|
+
|
7
|
+
Background:
|
8
|
+
Given I use the fixture "cli-app"
|
9
|
+
And the default feature-test
|
10
|
+
|
11
|
+
Scenario: Default value
|
12
|
+
Given a file named "features/support/aruba.rb" with:
|
13
|
+
"""
|
14
|
+
Aruba.configure do |config|
|
15
|
+
puts %(The default value is "#{config.exit_timeout}")
|
16
|
+
end
|
17
|
+
"""
|
18
|
+
When I successfully run `cucumber`
|
19
|
+
Then the output should contain:
|
20
|
+
"""
|
21
|
+
The default value is "15"
|
22
|
+
"""
|
23
|
+
|
24
|
+
Scenario: Modify value
|
25
|
+
Given an executable named "bin/cli" with:
|
26
|
+
"""
|
27
|
+
#!/bin/bash
|
28
|
+
sleep 1
|
29
|
+
"""
|
30
|
+
And a file named "features/support/aruba.rb" with:
|
31
|
+
"""
|
32
|
+
Aruba.configure do |config|
|
33
|
+
config.exit_timeout = 2
|
34
|
+
end
|
35
|
+
"""
|
36
|
+
Then I successfully run `cucumber`
|
37
|
+
|
38
|
+
Scenario: Fails if takes longer
|
39
|
+
Given an executable named "bin/cli" with:
|
40
|
+
"""
|
41
|
+
#!/bin/bash
|
42
|
+
sleep 2
|
43
|
+
"""
|
44
|
+
And a file named "features/support/aruba.rb" with:
|
45
|
+
"""
|
46
|
+
Aruba.configure do |config|
|
47
|
+
config.exit_timeout = 1
|
48
|
+
end
|
49
|
+
"""
|
50
|
+
Then I run `cucumber`
|
51
|
+
And the exit status should be 1
|
@@ -0,0 +1,31 @@
|
|
1
|
+
Feature: Configure directory where to look for fixtures
|
2
|
+
|
3
|
+
As a developer
|
4
|
+
I want to configure the directory where aruba looks for fixtures
|
5
|
+
In order to use them in my tests
|
6
|
+
|
7
|
+
Background:
|
8
|
+
Given I use the fixture "cli-app"
|
9
|
+
And the default feature-test
|
10
|
+
|
11
|
+
Scenario: Default value
|
12
|
+
Given a file named "features/support/aruba.rb" with:
|
13
|
+
"""
|
14
|
+
Aruba.configure do |config|
|
15
|
+
puts %(The default value is "%w(#{config.fixtures_directories.join(" ")})")
|
16
|
+
end
|
17
|
+
"""
|
18
|
+
When I successfully run `cucumber`
|
19
|
+
Then the output should contain:
|
20
|
+
"""
|
21
|
+
The default value is "%w(features/fixtures spec/fixtures test/fixtures)"
|
22
|
+
"""
|
23
|
+
|
24
|
+
Scenario: Modify value
|
25
|
+
Given a file named "features/support/aruba.rb" with:
|
26
|
+
"""
|
27
|
+
Aruba.configure do |config|
|
28
|
+
config.fixtures_directories = %w(spec/fixtures)
|
29
|
+
end
|
30
|
+
"""
|
31
|
+
When I successfully run `cucumber`
|
@@ -0,0 +1,24 @@
|
|
1
|
+
Feature: Use fixtures path prefix of aruba
|
2
|
+
|
3
|
+
As a developer
|
4
|
+
I want to use the fixtures path prefix in aruba
|
5
|
+
In some API-method for using the fixtures path
|
6
|
+
|
7
|
+
Background:
|
8
|
+
Given I use the fixture "cli-app"
|
9
|
+
And the default feature-test
|
10
|
+
|
11
|
+
Scenario: Default value
|
12
|
+
Given a file named "features/support/aruba.rb" with:
|
13
|
+
"""
|
14
|
+
Aruba.configure do |config|
|
15
|
+
puts "The prefix is \"#{config.fixtures_path_prefix}\"."
|
16
|
+
end
|
17
|
+
"""
|
18
|
+
When I successfully run `cucumber`
|
19
|
+
Then the output should contain:
|
20
|
+
"""
|
21
|
+
The prefix is "%".
|
22
|
+
"""
|
23
|
+
|
24
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
Feature: Configure timeout for io of commands
|
2
|
+
|
3
|
+
As a developer
|
4
|
+
I want to configure the timeout waiting for io of a command
|
5
|
+
In order to support some longer running commands
|
6
|
+
|
7
|
+
Background:
|
8
|
+
Given I use the fixture "cli-app"
|
9
|
+
And the default feature-test
|
10
|
+
|
11
|
+
Scenario: Default value
|
12
|
+
Given a file named "features/support/aruba.rb" with:
|
13
|
+
"""
|
14
|
+
Aruba.configure do |config|
|
15
|
+
puts %(The default value is "#{config.io_wait_timeout}")
|
16
|
+
end
|
17
|
+
"""
|
18
|
+
When I successfully run `cucumber`
|
19
|
+
Then the output should contain:
|
20
|
+
"""
|
21
|
+
The default value is "0.1"
|
22
|
+
"""
|
23
|
+
|
24
|
+
Scenario: Modify value
|
25
|
+
Given a file named "features/support/aruba.rb" with:
|
26
|
+
"""
|
27
|
+
Aruba.configure do |config|
|
28
|
+
config.io_wait_timeout = 2
|
29
|
+
end
|
30
|
+
"""
|
31
|
+
Then I successfully run `cucumber`
|
@@ -0,0 +1,31 @@
|
|
1
|
+
Feature: Configure if ansi color codes should be stripped off from command output
|
2
|
+
|
3
|
+
As a developer
|
4
|
+
I want to strip off ansi color codes
|
5
|
+
In order to make checking of those outputs easier
|
6
|
+
|
7
|
+
Background:
|
8
|
+
Given I use the fixture "cli-app"
|
9
|
+
And the default feature-test
|
10
|
+
|
11
|
+
Scenario: Default value
|
12
|
+
Given a file named "features/support/aruba.rb" with:
|
13
|
+
"""
|
14
|
+
Aruba.configure do |config|
|
15
|
+
puts %(The default value is "#{config.keep_ansi}")
|
16
|
+
end
|
17
|
+
"""
|
18
|
+
When I successfully run `cucumber`
|
19
|
+
Then the output should contain:
|
20
|
+
"""
|
21
|
+
The default value is "false"
|
22
|
+
"""
|
23
|
+
|
24
|
+
Scenario: Modify value
|
25
|
+
Given a file named "features/support/aruba.rb" with:
|
26
|
+
"""
|
27
|
+
Aruba.configure do |config|
|
28
|
+
config.keep_ansi = true
|
29
|
+
end
|
30
|
+
"""
|
31
|
+
Then I successfully run `cucumber`
|
@@ -0,0 +1,31 @@
|
|
1
|
+
Feature: Use root directory of aruba
|
2
|
+
|
3
|
+
As a developer
|
4
|
+
I want to use the root directory of aruba
|
5
|
+
In order to use it elsewhere
|
6
|
+
|
7
|
+
Background:
|
8
|
+
Given I use the fixture "cli-app"
|
9
|
+
And the default feature-test
|
10
|
+
|
11
|
+
Scenario: Default configuration
|
12
|
+
Given a file named "features/support/aruba.rb" with:
|
13
|
+
"""
|
14
|
+
Aruba.configure do |config|
|
15
|
+
puts config.root_directory
|
16
|
+
end
|
17
|
+
"""
|
18
|
+
When I successfully run `cucumber`
|
19
|
+
Then the output should contain:
|
20
|
+
"""
|
21
|
+
tmp/aruba
|
22
|
+
"""
|
23
|
+
|
24
|
+
Scenario: Modify value
|
25
|
+
Given a file named "features/support/aruba.rb" with:
|
26
|
+
"""
|
27
|
+
Aruba.configure do |config|
|
28
|
+
config.root_directory = '/tmp/'
|
29
|
+
end
|
30
|
+
"""
|
31
|
+
Then I successfully run `cucumber`
|
@@ -0,0 +1,32 @@
|
|
1
|
+
Feature: Configure working directory of aruba
|
2
|
+
|
3
|
+
As a developer
|
4
|
+
I want to configure the working directory of aruba
|
5
|
+
In order to have a test directory for each used spec runner - e.g. cucumber or rspec
|
6
|
+
|
7
|
+
Background:
|
8
|
+
Given I use the fixture "cli-app"
|
9
|
+
And the default feature-test
|
10
|
+
|
11
|
+
Scenario: Default value
|
12
|
+
Given a file named "features/support/aruba.rb" with:
|
13
|
+
"""
|
14
|
+
Aruba.configure do |config|
|
15
|
+
puts %(The default value is "#{config.working_directory}")
|
16
|
+
end
|
17
|
+
"""
|
18
|
+
When I successfully run `cucumber`
|
19
|
+
Then the output should contain:
|
20
|
+
"""
|
21
|
+
The default value is "tmp/aruba"
|
22
|
+
"""
|
23
|
+
|
24
|
+
Scenario: Modify value
|
25
|
+
Given a file named "features/support/aruba.rb" with:
|
26
|
+
"""
|
27
|
+
Aruba.configure do |config|
|
28
|
+
config.working_directory = 'tmp/cucumber'
|
29
|
+
end
|
30
|
+
"""
|
31
|
+
When I successfully run `cucumber`
|
32
|
+
Then a directory named "tmp/cucumber" should exist
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# Simple Cli App
|
2
|
+
|
3
|
+
This is a simple test cli app
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'cli-app'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install cli-app
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Place files in `lib/cli/app/`. They are loaded automatically. If you need a
|
24
|
+
specific load order, use `require` in your files.
|
25
|
+
|
26
|
+
### CLI
|
27
|
+
|
28
|
+
```
|
29
|
+
cli
|
30
|
+
```
|
31
|
+
|
32
|
+
### Library
|
33
|
+
|
34
|
+
You can use `script/console` to load your library.
|
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'cli/app/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'cli-app'
|
8
|
+
spec.version = Cli::App::VERSION
|
9
|
+
spec.authors = ['Aruba Developers']
|
10
|
+
spec.email = 'cukes@googlegroups.com'
|
11
|
+
|
12
|
+
spec.summary = 'Summary'
|
13
|
+
spec.description = 'Description'
|
14
|
+
spec.homepage = 'http://example.com'
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
17
|
+
# delete this section to allow pushing this gem to any host.
|
18
|
+
|
19
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
|
+
spec.bindir = 'exe'
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ['lib']
|
23
|
+
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.9'
|
25
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
26
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'aruba/cucumber'
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'cli/app/version'
|
2
|
+
|
3
|
+
if RUBY_VERSION < '1.9'
|
4
|
+
::Dir.glob(::File.expand_path('../**/*.rb', __FILE__)).each { |f| require File.join(File.dirname(f), File.basename(f, '.rb')) }
|
5
|
+
else
|
6
|
+
::Dir.glob(File.expand_path('../**/*.rb', __FILE__)).each { |f| require_relative f }
|
7
|
+
end
|
8
|
+
|
9
|
+
module Cli
|
10
|
+
module App
|
11
|
+
# Your code goes here...
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "cli/app"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
@@ -0,0 +1,10 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
|
+
|
3
|
+
require 'cli/app'
|
4
|
+
require 'aruba/rspec'
|
5
|
+
|
6
|
+
if RUBY_VERSION < '1.9.'
|
7
|
+
::Dir.glob(::File.expand_path('../support/**/*.rb', __FILE__)).each { |f| require File.join(File.dirname(f), File.basename(f, '.rb')) }
|
8
|
+
else
|
9
|
+
::Dir.glob(::File.expand_path('../support/**/*.rb', __FILE__)).each { |f| require_relative f }
|
10
|
+
end
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
a
|
@@ -0,0 +1,34 @@
|
|
1
|
+
Feature: After command hooks
|
2
|
+
|
3
|
+
You can configure Aruba to run blocks of code after it has run
|
4
|
+
a command. The command will be passed to the block.
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given I use a fixture named "cli-app"
|
8
|
+
|
9
|
+
Scenario: Run a simple command with an "after(:command)"-hook
|
10
|
+
Given a file named "spec/support/hooks.rb" with:
|
11
|
+
"""
|
12
|
+
Aruba.configure do |config|
|
13
|
+
config.after :command do |cmd|
|
14
|
+
puts "after the run of `#{cmd.commandline}`"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
"""
|
18
|
+
And a file named "spec/hook_spec.rb" with:
|
19
|
+
"""
|
20
|
+
require 'spec_helper'
|
21
|
+
|
22
|
+
RSpec.describe 'Hooks', :type => :aruba do
|
23
|
+
before(:each) { run_simple 'echo running' }
|
24
|
+
|
25
|
+
it { expect(last_command.stdout.chomp).to eq 'running' }
|
26
|
+
end
|
27
|
+
"""
|
28
|
+
When I run `rspec`
|
29
|
+
Then the specs should all pass
|
30
|
+
And the output should contain:
|
31
|
+
"""
|
32
|
+
after the run of `echo running`
|
33
|
+
"""
|
34
|
+
|
@@ -0,0 +1,61 @@
|
|
1
|
+
Feature: before_cmd hooks
|
2
|
+
|
3
|
+
You can configure Aruba to run blocks of code before it runs
|
4
|
+
each command.
|
5
|
+
|
6
|
+
The command will be passed to the block.
|
7
|
+
|
8
|
+
Background:
|
9
|
+
Given I use a fixture named "cli-app"
|
10
|
+
|
11
|
+
Scenario: Run a simple command with a "before(:command)"-hook
|
12
|
+
Given a file named "spec/support/hooks.rb" with:
|
13
|
+
"""
|
14
|
+
Aruba.configure do |config|
|
15
|
+
config.before :command do |cmd|
|
16
|
+
puts "before the run of `#{cmd.commandline}`"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
"""
|
20
|
+
And a file named "spec/hook_spec.rb" with:
|
21
|
+
"""
|
22
|
+
require 'spec_helper'
|
23
|
+
|
24
|
+
RSpec.describe 'Hooks', :type => :aruba do
|
25
|
+
before(:each) { run_simple 'echo running' }
|
26
|
+
|
27
|
+
it { expect(last_command.stdout.chomp).to eq 'running' }
|
28
|
+
end
|
29
|
+
"""
|
30
|
+
When I run `rspec`
|
31
|
+
Then the specs should all pass
|
32
|
+
And the output should contain:
|
33
|
+
"""
|
34
|
+
before the run of `echo running`
|
35
|
+
"""
|
36
|
+
|
37
|
+
Scenario: Run a simple command with a "before(:cmd)"-hook (deprecated)
|
38
|
+
Given a file named "spec/support/hooks.rb" with:
|
39
|
+
"""
|
40
|
+
Aruba.configure do |config|
|
41
|
+
config.before :cmd do |cmd|
|
42
|
+
puts "before the run of `#{cmd}`"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
"""
|
46
|
+
And a file named "spec/hook_spec.rb" with:
|
47
|
+
"""
|
48
|
+
require 'spec_helper'
|
49
|
+
|
50
|
+
RSpec.describe 'Hooks', :type => :aruba do
|
51
|
+
before(:each) { run_simple 'echo running' }
|
52
|
+
|
53
|
+
it { expect(last_command.stdout.chomp).to eq 'running' }
|
54
|
+
end
|
55
|
+
"""
|
56
|
+
When I run `rspec`
|
57
|
+
Then the specs should all pass
|
58
|
+
And the output should contain:
|
59
|
+
"""
|
60
|
+
before the run of `echo running`
|
61
|
+
"""
|