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
data/lib/aruba/cucumber/hooks.rb
CHANGED
@@ -1,25 +1,50 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
require 'aruba/aruba_path'
|
2
|
+
require 'aruba/api'
|
3
|
+
World(Aruba::Api)
|
4
|
+
|
5
|
+
# Activate on 1.0.0
|
6
|
+
#
|
7
|
+
# Around do |_, block|
|
8
|
+
# begin
|
9
|
+
# if RUBY_VERSION < '1.9'
|
10
|
+
# old_env = ENV.to_hash
|
11
|
+
# else
|
12
|
+
# old_env = ENV.to_h
|
13
|
+
# end
|
14
|
+
#
|
15
|
+
# block.call
|
16
|
+
# ensure
|
17
|
+
# ENV.clear
|
18
|
+
# ENV.update old_env
|
19
|
+
# end
|
20
|
+
# end
|
4
21
|
|
5
22
|
Before do
|
6
|
-
|
7
|
-
|
23
|
+
aruba.environment.update aruba.config.command_runtime_environment
|
24
|
+
prepend_environment_variable 'PATH', aruba.config.command_search_paths.join(':') + ':'
|
8
25
|
end
|
9
26
|
|
10
27
|
After do
|
11
|
-
|
28
|
+
restore_env
|
29
|
+
process_monitor.stop_processes!
|
30
|
+
process_monitor.clear
|
12
31
|
end
|
13
32
|
|
14
33
|
Before('~@no-clobber') do
|
15
|
-
|
34
|
+
setup_aruba
|
16
35
|
end
|
17
36
|
|
18
37
|
Before('@puts') do
|
19
38
|
announcer.mode = :puts
|
20
39
|
end
|
21
40
|
|
41
|
+
Before('@announce-command') do
|
42
|
+
announcer.activate :command
|
43
|
+
end
|
44
|
+
|
22
45
|
Before('@announce-cmd') do
|
46
|
+
Aruba::Platform.deprecated 'The use of "@announce-cmd"-hook is deprecated. Please use "@announce-command"'
|
47
|
+
|
23
48
|
announcer.activate :command
|
24
49
|
end
|
25
50
|
|
@@ -32,19 +57,36 @@ Before('@announce-stderr') do
|
|
32
57
|
end
|
33
58
|
|
34
59
|
Before('@announce-dir') do
|
60
|
+
Aruba::Platform.deprecated 'The use of "@announce-dir"-hook is deprecated. Please use "@announce-directory"'
|
61
|
+
|
62
|
+
announcer.activate :directory
|
63
|
+
end
|
64
|
+
|
65
|
+
Before('@announce-directory') do
|
35
66
|
announcer.activate :directory
|
36
67
|
end
|
37
68
|
|
38
69
|
Before('@announce-env') do
|
70
|
+
Aruba::Platform.deprecated 'The use of "@announce-env"-hook is deprecated. Please use "@announce-environment"'
|
71
|
+
|
72
|
+
announcer.activate :environment
|
73
|
+
end
|
74
|
+
|
75
|
+
Before('@announce-environment') do
|
39
76
|
announcer.activate :environment
|
40
77
|
end
|
41
78
|
|
79
|
+
Before('@announce-timeout') do
|
80
|
+
announcer.activate :timeout
|
81
|
+
end
|
82
|
+
|
42
83
|
Before('@announce') do
|
43
84
|
announcer.activate :command
|
44
85
|
announcer.activate :stdout
|
45
86
|
announcer.activate :stderr
|
46
87
|
announcer.activate :directory
|
47
88
|
announcer.activate :environment
|
89
|
+
announcer.activate :timeout
|
48
90
|
end
|
49
91
|
|
50
92
|
Before('@debug') do
|
@@ -52,11 +94,24 @@ Before('@debug') do
|
|
52
94
|
Aruba.process = Aruba::Processes::DebugProcess
|
53
95
|
end
|
54
96
|
|
97
|
+
After('@debug') do
|
98
|
+
Aruba.process = Aruba::Processes::SpawnProcess
|
99
|
+
end
|
100
|
+
|
55
101
|
Before('@ansi') do
|
56
102
|
@aruba_keep_ansi = true
|
57
103
|
end
|
58
104
|
|
59
|
-
|
60
|
-
|
61
|
-
|
105
|
+
Before '@mocked_home_directory' do
|
106
|
+
Aruba::Platform.deprecated('The use of "@mocked_home_directory" is deprecated. Use "@mocked-home-directory" instead')
|
107
|
+
|
108
|
+
set_environment_variable 'HOME', expand_path('.')
|
109
|
+
end
|
110
|
+
|
111
|
+
Before '@mocked-home-directory' do
|
112
|
+
set_environment_variable 'HOME', expand_path('.')
|
113
|
+
end
|
114
|
+
|
115
|
+
Before('@disable-bundler') do
|
116
|
+
unset_bundler_env_vars
|
62
117
|
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
module Aruba
|
2
|
+
class Environment
|
3
|
+
private
|
4
|
+
|
5
|
+
attr_reader :env
|
6
|
+
|
7
|
+
public
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@env = ENV.to_hash
|
11
|
+
end
|
12
|
+
|
13
|
+
# Update environment with other en
|
14
|
+
#
|
15
|
+
# @param [#to_hash, #to_h] other_env
|
16
|
+
# Another environment object or hash
|
17
|
+
#
|
18
|
+
# @yield
|
19
|
+
# Pass block to env
|
20
|
+
def update(other_env, &block)
|
21
|
+
if RUBY_VERSION <= '1.9.3'
|
22
|
+
# rubocop:disable Style/EachWithObject
|
23
|
+
other_env = other_env.to_hash.inject({}) { |a, (k, v)| a[k] = v.to_s; a }
|
24
|
+
# rubocop:enable Style/EachWithObject
|
25
|
+
else
|
26
|
+
other_env = other_env.to_h.each_with_object({}) { |(k, v), a| a[k] = v.to_s }
|
27
|
+
end
|
28
|
+
|
29
|
+
env.update(other_env, &block)
|
30
|
+
|
31
|
+
self
|
32
|
+
end
|
33
|
+
|
34
|
+
# Fetch variable from environment
|
35
|
+
#
|
36
|
+
# @param [#to_s] name
|
37
|
+
# The name of the variable
|
38
|
+
#
|
39
|
+
# @param [Object] default
|
40
|
+
# The default value used, if the variable is not defined
|
41
|
+
def fetch(name, default)
|
42
|
+
env.fetch name.to_s, default
|
43
|
+
end
|
44
|
+
|
45
|
+
# Check if variable exist
|
46
|
+
#
|
47
|
+
# @param [#to_s] name
|
48
|
+
# The name of the variable
|
49
|
+
def key?(name)
|
50
|
+
env.key? name.to_s
|
51
|
+
end
|
52
|
+
|
53
|
+
# Get value of variable
|
54
|
+
#
|
55
|
+
# @param [#to_s] name
|
56
|
+
# The name of the variable
|
57
|
+
def [](name)
|
58
|
+
env[name.to_s]
|
59
|
+
end
|
60
|
+
|
61
|
+
# Set value of variable
|
62
|
+
#
|
63
|
+
# @param [#to_s] name
|
64
|
+
# The name of the variable
|
65
|
+
#
|
66
|
+
# @param [#to_s] value
|
67
|
+
# The value of the variable
|
68
|
+
def []=(name, value)
|
69
|
+
env[name.to_s] = value.to_s
|
70
|
+
|
71
|
+
self
|
72
|
+
end
|
73
|
+
|
74
|
+
# Append value to variable
|
75
|
+
#
|
76
|
+
# @param [#to_s] name
|
77
|
+
# The name of the variable
|
78
|
+
#
|
79
|
+
# @param [#to_s] value
|
80
|
+
# The value of the variable
|
81
|
+
def append(name, value)
|
82
|
+
name = name.to_s
|
83
|
+
env[name] = env[name].to_s + value.to_s
|
84
|
+
|
85
|
+
self
|
86
|
+
end
|
87
|
+
|
88
|
+
# Prepend value to variable
|
89
|
+
#
|
90
|
+
# @param [#to_s] name
|
91
|
+
# The name of the variable
|
92
|
+
#
|
93
|
+
# @param [#to_s] value
|
94
|
+
# The value of the variable
|
95
|
+
def prepend(name, value)
|
96
|
+
name = name.to_s
|
97
|
+
env[name] = value.to_s + env[name].to_s
|
98
|
+
|
99
|
+
self
|
100
|
+
end
|
101
|
+
|
102
|
+
# Convert to hash
|
103
|
+
#
|
104
|
+
# @return [Hash]
|
105
|
+
# A new hash from environment
|
106
|
+
def to_h
|
107
|
+
if RUBY_VERSION < '2.0'
|
108
|
+
env.to_hash.dup
|
109
|
+
else
|
110
|
+
env.to_h.dup
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
# Reset environment
|
115
|
+
def clear
|
116
|
+
env.clear
|
117
|
+
|
118
|
+
self
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
data/lib/aruba/errors.rb
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
class String
|
2
|
+
# Strips indentation in heredocs.
|
3
|
+
#
|
4
|
+
# For example in
|
5
|
+
#
|
6
|
+
# if options[:usage]
|
7
|
+
# puts <<-USAGE.strip_heredoc
|
8
|
+
# This command does such and such.
|
9
|
+
#
|
10
|
+
# Supported options are:
|
11
|
+
# -h This message
|
12
|
+
# ...
|
13
|
+
# USAGE
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# the user would see the usage message aligned against the left margin.
|
17
|
+
#
|
18
|
+
# Technically, it looks for the least indented line in the whole string, and removes
|
19
|
+
# that amount of leading whitespace.
|
20
|
+
def strip_heredoc
|
21
|
+
indent = scan(/^[ \t]*(?=\S)/).min.to_s.size
|
22
|
+
gsub(/^[ \t]{#{indent}}/, '')
|
23
|
+
end
|
24
|
+
end
|
data/lib/aruba/hooks.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
module Aruba
|
2
|
+
# Aruba Hooks
|
3
|
+
class Hooks
|
4
|
+
private
|
5
|
+
|
6
|
+
attr_reader :store
|
7
|
+
|
8
|
+
public
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@store = {}
|
12
|
+
end
|
13
|
+
|
14
|
+
# Add new hook
|
15
|
+
#
|
16
|
+
# @param [String, Symbol] label
|
17
|
+
# The name of the hook
|
18
|
+
#
|
19
|
+
# @para [Proc] block
|
20
|
+
# The block which should be run for the hook
|
21
|
+
def append(label, block)
|
22
|
+
if store.key?(label.to_sym) && store[label.to_sym].respond_to?(:<<)
|
23
|
+
store[label.to_sym] << block
|
24
|
+
else
|
25
|
+
store[label.to_sym] = []
|
26
|
+
store[label.to_sym] << block
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# Run hook
|
31
|
+
#
|
32
|
+
# @param [String, Symbol] label
|
33
|
+
# The name of the hook
|
34
|
+
#
|
35
|
+
# @param [Object] context
|
36
|
+
# The context in which the hook is run
|
37
|
+
#
|
38
|
+
# @param [Array] args
|
39
|
+
# Other arguments
|
40
|
+
def execute(label, context, *args)
|
41
|
+
Array(store[label.to_sym]).each do |block|
|
42
|
+
context.instance_exec(*args, &block)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# Check if hook exist
|
47
|
+
#
|
48
|
+
# @param [String, Symbol] label
|
49
|
+
# The name of the hook
|
50
|
+
def exist?(label)
|
51
|
+
store.key? label.to_sym
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/lib/aruba/jruby.rb
CHANGED
@@ -1,9 +1,4 @@
|
|
1
|
-
|
2
|
-
Aruba.
|
3
|
-
|
4
|
-
|
5
|
-
set_env('JRUBY_OPTS', "-X-C #{ENV['JRUBY_OPTS']}")
|
6
|
-
# force jRuby to use client JVM for faster startup times
|
7
|
-
set_env('JAVA_OPTS', "-d32 #{ENV['JAVA_OPTS']}") if RbConfig::CONFIG['host_os'] =~ /solaris|sunos/i
|
8
|
-
end
|
9
|
-
end if RUBY_PLATFORM == 'java'
|
1
|
+
require 'aruba/platform'
|
2
|
+
Aruba::Platform.deprecated('The use of "aruba/jruby" is deprecated. Use "aruba/config/jruby" instead')
|
3
|
+
|
4
|
+
require 'aruba/config/jruby'
|
@@ -1,79 +1 @@
|
|
1
|
-
|
2
|
-
# This matchers checks if <command> has exit status <status>
|
3
|
-
#
|
4
|
-
# @param [Integer] status
|
5
|
-
# The value of the exit status
|
6
|
-
#
|
7
|
-
# @return [TrueClass, FalseClass] The result
|
8
|
-
#
|
9
|
-
# false:
|
10
|
-
# * if command does not have exit status
|
11
|
-
# true:
|
12
|
-
# * if command has exit status
|
13
|
-
#
|
14
|
-
# @example Use matcher
|
15
|
-
#
|
16
|
-
# RSpec.describe do
|
17
|
-
# it { expect(last_command).to have_exit_status(0) }
|
18
|
-
# end
|
19
|
-
RSpec::Matchers.define :have_exit_status do |expected|
|
20
|
-
match do |actual|
|
21
|
-
@old_actual = actual
|
22
|
-
|
23
|
-
@announcer ||= Aruba::Announcer.new(
|
24
|
-
self,
|
25
|
-
:stdout => @announce_stdout,
|
26
|
-
:stderr => @announce_stderr,
|
27
|
-
:dir => @announce_dir,
|
28
|
-
:cmd => @announce_cmd,
|
29
|
-
:env => @announce_env
|
30
|
-
)
|
31
|
-
|
32
|
-
@old_actual.stop(@announcer) unless @old_actual.stopped?
|
33
|
-
@actual = actual.exit_status
|
34
|
-
|
35
|
-
next false unless @old_actual.respond_to? :exit_status
|
36
|
-
|
37
|
-
values_match? expected, @actual
|
38
|
-
end
|
39
|
-
|
40
|
-
failure_message do |actual|
|
41
|
-
format(%(expected that command "%s" has exit status of "%s", but has "%s".), @old_actual.commandline, expected.to_s, actual.to_s)
|
42
|
-
end
|
43
|
-
|
44
|
-
failure_message_when_negated do |actual|
|
45
|
-
format(%(expected that command "%s" does not have exit status of "%s", but has "%s".), @old_actual.commandline, expected.to_s, actual.to_s)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
# @!method be_successfuly_executed
|
50
|
-
# This matchers checks if execution of <command> was successful
|
51
|
-
#
|
52
|
-
# @return [TrueClass, FalseClass] The result
|
53
|
-
#
|
54
|
-
# false:
|
55
|
-
# * if command was not successful
|
56
|
-
# true:
|
57
|
-
# * if command was successful
|
58
|
-
#
|
59
|
-
# @example Use matcher
|
60
|
-
#
|
61
|
-
# RSpec.describe do
|
62
|
-
# it { expect(last_command).to be_successfully_executed }
|
63
|
-
# end
|
64
|
-
RSpec::Matchers.define :be_successfully_executed do
|
65
|
-
match do |actual|
|
66
|
-
@old_actual = actual
|
67
|
-
@actual = actual.exit_status
|
68
|
-
|
69
|
-
expect(@old_actual).to have_exit_status 0
|
70
|
-
end
|
71
|
-
|
72
|
-
failure_message do |actual|
|
73
|
-
format(%(expected that command "%s" has exit status of "%s", but has "%s".), @old_actual.commandline, '0', actual.to_s)
|
74
|
-
end
|
75
|
-
|
76
|
-
failure_message_when_negated do |actual|
|
77
|
-
format(%(expected that command "%s" does not have exit status of "%s", but has "%s".), @old_actual.commandline, '0', actual.to_s)
|
78
|
-
end
|
79
|
-
end
|
1
|
+
Aruba::Platform.require_matching_files('../command/**/*.rb', __FILE__)
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'aruba/matchers/command/have_exit_status'
|
2
|
+
require 'aruba/matchers/command/have_finished_in_time'
|
3
|
+
|
4
|
+
# @!method be_successfuly_executed
|
5
|
+
# This matchers checks if execution of <command> was successful
|
6
|
+
#
|
7
|
+
# @return [TrueClass, FalseClass] The result
|
8
|
+
#
|
9
|
+
# false:
|
10
|
+
# * if command was not successful
|
11
|
+
# true:
|
12
|
+
# * if command was successful
|
13
|
+
#
|
14
|
+
# @example Use matcher
|
15
|
+
#
|
16
|
+
# RSpec.describe do
|
17
|
+
# it { expect(last_command).to be_successfully_executed }
|
18
|
+
# it { expect(last_command).not_to be_successfully_executed }
|
19
|
+
# it { expect(last_command).to have_failed_running }
|
20
|
+
# end
|
21
|
+
RSpec::Matchers.define :be_successfully_executed do
|
22
|
+
match do |actual|
|
23
|
+
@old_actual = actual
|
24
|
+
@actual = @old_actual.commandline
|
25
|
+
|
26
|
+
expect(@old_actual).to have_exit_status(0)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
RSpec::Matchers.define_negated_matcher :have_failed_running, :be_successfully_executed
|