aruba 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +29 -8
- data/.rubocop_todo.yml +100 -146
- data/CHANGELOG.md +23 -1
- data/CONTRIBUTING.md +0 -8
- data/Gemfile +3 -1
- data/Rakefile +6 -4
- data/appveyor.yml +0 -1
- data/aruba.gemspec +7 -4
- data/fixtures/cli-app/cli-app.gemspec +3 -2
- data/fixtures/cli-app/spec/spec_helper.rb +2 -1
- data/fixtures/empty-app/cli-app.gemspec +3 -2
- data/lib/aruba/api/bundler.rb +1 -1
- data/lib/aruba/api/commands.rb +8 -11
- data/lib/aruba/api/core.rb +48 -33
- data/lib/aruba/api/environment.rb +12 -4
- data/lib/aruba/api/filesystem.rb +27 -23
- data/lib/aruba/api/text.rb +15 -3
- data/lib/aruba/basic_configuration.rb +5 -6
- data/lib/aruba/basic_configuration/option.rb +2 -2
- data/lib/aruba/cli.rb +4 -1
- data/lib/aruba/config_wrapper.rb +17 -2
- data/lib/aruba/configuration.rb +27 -12
- data/lib/aruba/console.rb +0 -2
- data/lib/aruba/console/help.rb +5 -2
- data/lib/aruba/contracts/absolute_path.rb +1 -1
- data/lib/aruba/contracts/is_power_of_two.rb +2 -2
- data/lib/aruba/contracts/relative_path.rb +1 -1
- data/lib/aruba/cucumber/command.rb +83 -64
- data/lib/aruba/cucumber/file.rb +42 -22
- data/lib/aruba/cucumber/hooks.rb +4 -1
- data/lib/aruba/cucumber/testing_frameworks.rb +14 -12
- data/lib/aruba/event_bus.rb +4 -2
- data/lib/aruba/event_bus/name_resolver.rb +9 -8
- data/lib/aruba/events.rb +2 -1
- data/lib/aruba/hooks.rb +2 -4
- data/lib/aruba/in_config_wrapper.rb +8 -5
- data/lib/aruba/initializer.rb +5 -3
- data/lib/aruba/matchers/base/base_matcher.rb +2 -11
- data/lib/aruba/matchers/base/object_formatter.rb +0 -3
- data/lib/aruba/matchers/collection/include_an_object.rb +4 -4
- data/lib/aruba/matchers/command/be_successfully_executed.rb +3 -1
- data/lib/aruba/matchers/command/have_exit_status.rb +3 -1
- data/lib/aruba/matchers/command/have_finished_in_time.rb +3 -1
- data/lib/aruba/matchers/command/have_output.rb +3 -1
- data/lib/aruba/matchers/command/have_output_on_stderr.rb +3 -1
- data/lib/aruba/matchers/command/have_output_on_stdout.rb +3 -1
- data/lib/aruba/matchers/directory/have_sub_directory.rb +8 -3
- data/lib/aruba/matchers/file/have_file_size.rb +4 -2
- data/lib/aruba/matchers/path/have_permissions.rb +4 -2
- data/lib/aruba/platforms/announcer.rb +18 -6
- data/lib/aruba/platforms/aruba_file_creator.rb +3 -1
- data/lib/aruba/platforms/aruba_fixed_size_file_creator.rb +7 -2
- data/lib/aruba/platforms/command_monitor.rb +3 -3
- data/lib/aruba/platforms/unix_environment_variables.rb +2 -4
- data/lib/aruba/platforms/unix_which.rb +1 -1
- data/lib/aruba/platforms/windows_environment_variables.rb +2 -1
- data/lib/aruba/platforms/windows_which.rb +6 -2
- data/lib/aruba/processes/debug_process.rb +4 -2
- data/lib/aruba/processes/in_process.rb +4 -2
- data/lib/aruba/processes/spawn_process.rb +18 -10
- data/lib/aruba/rspec.rb +25 -15
- data/lib/aruba/runtime.rb +11 -4
- data/lib/aruba/setup.rb +23 -10
- data/lib/aruba/tasks/docker_helpers.rb +3 -1
- data/lib/aruba/version.rb +1 -1
- metadata +22 -8
data/lib/aruba/cucumber/file.rb
CHANGED
@@ -3,11 +3,13 @@ Given(/^I use (?:a|the) fixture(?: named)? "([^"]*)"$/) do |name|
|
|
3
3
|
cd name
|
4
4
|
end
|
5
5
|
|
6
|
-
Given(/^I copy (?:a|the) (?:file|directory)(?: (?:named|from))? "([^"]*)" to "([^"]*)"$/)
|
6
|
+
Given(/^I copy (?:a|the) (?:file|directory)(?: (?:named|from))? "([^"]*)" to "([^"]*)"$/) \
|
7
|
+
do |source, destination|
|
7
8
|
copy source, destination
|
8
9
|
end
|
9
10
|
|
10
|
-
Given(/^I move (?:a|the) (?:file|directory)(?: (?:named|from))? "([^"]*)" to "([^"]*)"$/)
|
11
|
+
Given(/^I move (?:a|the) (?:file|directory)(?: (?:named|from))? "([^"]*)" to "([^"]*)"$/) \
|
12
|
+
do |source, destination|
|
11
13
|
move source, destination
|
12
14
|
end
|
13
15
|
|
@@ -15,7 +17,8 @@ Given(/^(?:a|the|(?:an empty)) directory(?: named)? "([^"]*)"$/) do |dir_name|
|
|
15
17
|
create_directory(dir_name)
|
16
18
|
end
|
17
19
|
|
18
|
-
Given(/^(?:a|the) directory(?: named)? "([^"]*)" with mode "([^"]*)"$/)
|
20
|
+
Given(/^(?:a|the) directory(?: named)? "([^"]*)" with mode "([^"]*)"$/) \
|
21
|
+
do |dir_name, dir_mode|
|
19
22
|
create_directory(dir_name)
|
20
23
|
chmod(dir_mode, dir_name)
|
21
24
|
end
|
@@ -32,7 +35,8 @@ Given(/^(?:a|the) file(?: named)? "([^"]*)" with "([^"]*)"$/) do |file_name, fil
|
|
32
35
|
write_file(file_name, unescape_text(file_content))
|
33
36
|
end
|
34
37
|
|
35
|
-
Given(/^(?:a|the) file(?: named)? "([^"]*)" with mode "([^"]*)" and with:$/)
|
38
|
+
Given(/^(?:a|the) file(?: named)? "([^"]*)" with mode "([^"]*)" and with:$/) \
|
39
|
+
do |file_name, file_mode, file_content|
|
36
40
|
write_file(file_name, unescape_text(file_content))
|
37
41
|
chmod(file_mode, file_name)
|
38
42
|
end
|
@@ -45,7 +49,8 @@ Given(/^(?:an|the) empty file(?: named)? "([^"]*)"$/) do |file_name|
|
|
45
49
|
write_file(file_name, '')
|
46
50
|
end
|
47
51
|
|
48
|
-
Given(/^(?:an|the) empty file(?: named)? "([^"]*)" with mode "([^"]*)"$/)
|
52
|
+
Given(/^(?:an|the) empty file(?: named)? "([^"]*)" with mode "([^"]*)"$/) \
|
53
|
+
do |file_name, file_mode|
|
49
54
|
write_file(file_name, '')
|
50
55
|
chmod(file_mode, file_name)
|
51
56
|
end
|
@@ -54,7 +59,8 @@ When(/^I write to "([^"]*)" with:$/) do |file_name, file_content|
|
|
54
59
|
write_file(file_name, file_content)
|
55
60
|
end
|
56
61
|
|
57
|
-
When(/^I overwrite(?: (?:a|the) file(?: named)?)? "([^"]*)" with:$/)
|
62
|
+
When(/^I overwrite(?: (?:a|the) file(?: named)?)? "([^"]*)" with:$/) \
|
63
|
+
do |file_name, file_content|
|
58
64
|
overwrite_file(file_name, file_content)
|
59
65
|
end
|
60
66
|
|
@@ -66,7 +72,8 @@ When(/^I append to "([^"]*)" with "([^"]*)"$/) do |file_name, file_content|
|
|
66
72
|
append_to_file(file_name, file_content)
|
67
73
|
end
|
68
74
|
|
69
|
-
When(/^I remove (?:a|the) (?:file|directory)(?: named)? "([^"]*)"( with full force)?$/)
|
75
|
+
When(/^I remove (?:a|the) (?:file|directory)(?: named)? "([^"]*)"( with full force)?$/) \
|
76
|
+
do |name, force_remove|
|
70
77
|
remove(name, force: force_remove.nil? ? false : true)
|
71
78
|
end
|
72
79
|
|
@@ -88,7 +95,8 @@ Then(/^the following files should (not )?exist:$/) do |negated, files|
|
|
88
95
|
end
|
89
96
|
end
|
90
97
|
|
91
|
-
Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?exist(?: anymore)?$/)
|
98
|
+
Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?exist(?: anymore)?$/) \
|
99
|
+
do |path, expect_match|
|
92
100
|
if expect_match
|
93
101
|
expect(path).not_to be_an_existing_file
|
94
102
|
else
|
@@ -96,7 +104,8 @@ Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?exist(?: anymore)?$/) d
|
|
96
104
|
end
|
97
105
|
end
|
98
106
|
|
99
|
-
Then(/^(?:a|the) directory(?: named)? "([^"]*)" should (not )?exist(?: anymore)?$/)
|
107
|
+
Then(/^(?:a|the) directory(?: named)? "([^"]*)" should (not )?exist(?: anymore)?$/) \
|
108
|
+
do |path, expect_match|
|
100
109
|
if expect_match
|
101
110
|
expect(path).not_to be_an_existing_directory
|
102
111
|
else
|
@@ -112,7 +121,8 @@ Then(/^(?:a|the) file matching %r<(.*?)> should (not )?exist$/) do |pattern, exp
|
|
112
121
|
end
|
113
122
|
end
|
114
123
|
|
115
|
-
Then(/^(?:a|the) (\d+) byte file(?: named)? "([^"]*)" should (not )?exist$/)
|
124
|
+
Then(/^(?:a|the) (\d+) byte file(?: named)? "([^"]*)" should (not )?exist$/) \
|
125
|
+
do |size, file, negated|
|
116
126
|
if negated
|
117
127
|
expect(file).not_to have_file_size(size)
|
118
128
|
else
|
@@ -130,7 +140,8 @@ Then(/^the following directories should (not )?exist:$/) do |negated, directorie
|
|
130
140
|
end
|
131
141
|
end
|
132
142
|
|
133
|
-
Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?contain "([^"]*)"$/)
|
143
|
+
Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?contain "([^"]*)"$/) \
|
144
|
+
do |file, negated, content|
|
134
145
|
if negated
|
135
146
|
expect(file).not_to have_file_content file_content_including(content.chomp)
|
136
147
|
else
|
@@ -138,7 +149,8 @@ Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?contain "([^"]*)"$/) do
|
|
138
149
|
end
|
139
150
|
end
|
140
151
|
|
141
|
-
Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?contain:$/)
|
152
|
+
Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?contain:$/) \
|
153
|
+
do |file, negated, content|
|
142
154
|
if negated
|
143
155
|
expect(file).not_to have_file_content file_content_including(content.chomp)
|
144
156
|
else
|
@@ -146,7 +158,8 @@ Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?contain:$/) do |file, n
|
|
146
158
|
end
|
147
159
|
end
|
148
160
|
|
149
|
-
Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?contain exactly:$/)
|
161
|
+
Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?contain exactly:$/) \
|
162
|
+
do |file, negated, content|
|
150
163
|
if negated
|
151
164
|
expect(file).not_to have_file_content content
|
152
165
|
else
|
@@ -154,7 +167,8 @@ Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?contain exactly:$/) do
|
|
154
167
|
end
|
155
168
|
end
|
156
169
|
|
157
|
-
Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?match %r<([^>]*)>$/)
|
170
|
+
Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?match %r<([^>]*)>$/) \
|
171
|
+
do |file, negated, content|
|
158
172
|
if negated
|
159
173
|
expect(file).not_to have_file_content file_content_matching(content)
|
160
174
|
else
|
@@ -162,7 +176,8 @@ Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?match %r<([^>]*)>$/) do
|
|
162
176
|
end
|
163
177
|
end
|
164
178
|
|
165
|
-
Then(
|
179
|
+
Then(%r{^(?:a|the) file(?: named)? "([^"]*)" should (not )?match /([^/]*)/$}) \
|
180
|
+
do |file, negated, content|
|
166
181
|
if negated
|
167
182
|
expect(file).not_to have_file_content file_content_matching(content)
|
168
183
|
else
|
@@ -170,7 +185,8 @@ Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?match \/([^\/]*)\/$/) d
|
|
170
185
|
end
|
171
186
|
end
|
172
187
|
|
173
|
-
Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?be equal to file "([^"]*)"/)
|
188
|
+
Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?be equal to file "([^"]*)"/) \
|
189
|
+
do |file, negated, reference_file|
|
174
190
|
if negated
|
175
191
|
expect(file).not_to have_same_file_content_as(reference_file)
|
176
192
|
else
|
@@ -178,10 +194,14 @@ Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?be equal to file "([^"]
|
|
178
194
|
end
|
179
195
|
end
|
180
196
|
|
181
|
-
Then(
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
197
|
+
Then(
|
198
|
+
/^(?:a|the) (?:file|directory)(?: named)? "([^"]*)" should have permissions "([^"]*)"$/
|
199
|
+
) do |path, permissions|
|
200
|
+
expect(path).to have_permissions(permissions)
|
201
|
+
end
|
202
|
+
|
203
|
+
Then(
|
204
|
+
/^(?:a|the) (?:file|directory)(?: named)? "([^"]*)" should not have permissions "([^"]*)"$/
|
205
|
+
) do |path, permissions|
|
206
|
+
expect(path).not_to have_permissions(permissions)
|
187
207
|
end
|
data/lib/aruba/cucumber/hooks.rb
CHANGED
@@ -9,7 +9,10 @@ end
|
|
9
9
|
|
10
10
|
Before do
|
11
11
|
# ... so every change needs to be done later
|
12
|
-
prepend_environment_variable
|
12
|
+
prepend_environment_variable(
|
13
|
+
'PATH',
|
14
|
+
aruba.config.command_search_paths.join(File::PATH_SEPARATOR) + File::PATH_SEPARATOR
|
15
|
+
)
|
13
16
|
set_environment_variable 'HOME', aruba.config.home_directory
|
14
17
|
end
|
15
18
|
|
@@ -1,18 +1,18 @@
|
|
1
1
|
# Cucumber
|
2
|
-
Then
|
2
|
+
Then(/^the feature(?:s)? should not(?: all)? pass$/) do
|
3
3
|
step 'the output should contain " failed)"'
|
4
4
|
step 'the exit status should be 1'
|
5
5
|
end
|
6
6
|
|
7
7
|
# Cucumber
|
8
|
-
Then
|
8
|
+
Then(/^the feature(?:s)? should(?: all)? pass$/) do
|
9
9
|
step 'the output should not contain " failed)"'
|
10
10
|
step 'the output should not contain " undefined)"'
|
11
11
|
step 'the exit status should be 0'
|
12
12
|
end
|
13
13
|
|
14
14
|
# Cucumber
|
15
|
-
Then
|
15
|
+
Then(/^the feature(?:s)? should not(?: all)? pass with( regex)?:$/) do |regex, string|
|
16
16
|
step 'the output should contain " failed)"'
|
17
17
|
step 'the exit status should be 1'
|
18
18
|
|
@@ -24,7 +24,7 @@ Then /^the feature(?:s)? should not(?: all)? pass with( regex)?:$/ do |regex, st
|
|
24
24
|
end
|
25
25
|
|
26
26
|
# Cucumber
|
27
|
-
Then
|
27
|
+
Then(/^the feature(?:s)? should(?: all)? pass with( regex)?:$/) do |regex, string|
|
28
28
|
step 'the output should not contain " failed)"'
|
29
29
|
step 'the output should not contain " undefined)"'
|
30
30
|
step 'the exit status should be 0'
|
@@ -37,7 +37,8 @@ Then /^the feature(?:s)? should(?: all)? pass with( regex)?:$/ do |regex, string
|
|
37
37
|
end
|
38
38
|
|
39
39
|
# RSpec
|
40
|
-
Then
|
40
|
+
Then(/^the spec(?:s)? should not(?: all)? pass(?: with (\d+) failures?)?$/) \
|
41
|
+
do |count_failures|
|
41
42
|
if count_failures.nil?
|
42
43
|
step 'the output should not contain "0 failures"'
|
43
44
|
else
|
@@ -48,13 +49,13 @@ Then /^the spec(?:s)? should not(?: all)? pass(?: with (\d+) failures?)?$/ do |c
|
|
48
49
|
end
|
49
50
|
|
50
51
|
# RSpec
|
51
|
-
Then
|
52
|
+
Then(/^the spec(?:s)? should all pass$/) do
|
52
53
|
step 'the output should contain "0 failures"'
|
53
54
|
step 'the exit status should be 0'
|
54
55
|
end
|
55
56
|
|
56
57
|
# RSpec
|
57
|
-
Then
|
58
|
+
Then(/^the spec(?:s)? should not(?: all)? pass with( regex)?:$/) do |regex, string|
|
58
59
|
step 'the output should not contain "0 failures"'
|
59
60
|
step 'the exit status should be 1'
|
60
61
|
|
@@ -66,7 +67,7 @@ Then /^the spec(?:s)? should not(?: all)? pass with( regex)?:$/ do |regex, strin
|
|
66
67
|
end
|
67
68
|
|
68
69
|
# RSpec
|
69
|
-
Then
|
70
|
+
Then(/^the spec(?:s)? should(?: all)? pass with( regex)?:$/) do |regex, string|
|
70
71
|
step 'the output should contain "0 failures"'
|
71
72
|
step 'the exit status should be 0'
|
72
73
|
|
@@ -78,7 +79,8 @@ Then /^the spec(?:s)? should(?: all)? pass with( regex)?:$/ do |regex, string|
|
|
78
79
|
end
|
79
80
|
|
80
81
|
# Minitest
|
81
|
-
Then
|
82
|
+
Then(/^the tests(?:s)? should not(?: all)? pass(?: with (\d+) failures?)?$/) \
|
83
|
+
do |count_failures|
|
82
84
|
if count_failures.nil?
|
83
85
|
step 'the output should not contain "0 errors"'
|
84
86
|
else
|
@@ -89,13 +91,13 @@ Then /^the tests(?:s)? should not(?: all)? pass(?: with (\d+) failures?)?$/ do |
|
|
89
91
|
end
|
90
92
|
|
91
93
|
# Minitest
|
92
|
-
Then
|
94
|
+
Then(/^the tests(?:s)? should all pass$/) do
|
93
95
|
step 'the output should contain "0 errors"'
|
94
96
|
step 'the exit status should be 0'
|
95
97
|
end
|
96
98
|
|
97
99
|
# Minitest
|
98
|
-
Then
|
100
|
+
Then(/^the test(?:s)? should not(?: all)? pass with( regex)?:$/) do |regex, string|
|
99
101
|
step 'the output should contain "0 errors"'
|
100
102
|
step 'the exit status should be 1'
|
101
103
|
|
@@ -107,7 +109,7 @@ Then /^the test(?:s)? should not(?: all)? pass with( regex)?:$/ do |regex, strin
|
|
107
109
|
end
|
108
110
|
|
109
111
|
# Minitest
|
110
|
-
Then
|
112
|
+
Then(/^the test(?:s)? should(?: all)? pass with( regex)?:$/) do |regex, string|
|
111
113
|
step 'the output should not contain "0 errors"'
|
112
114
|
step 'the exit status should be 0'
|
113
115
|
|
data/lib/aruba/event_bus.rb
CHANGED
@@ -33,7 +33,9 @@ module Aruba
|
|
33
33
|
def register(event_ids, handler_object = nil, &handler_proc)
|
34
34
|
handler = handler_proc || handler_object
|
35
35
|
|
36
|
-
|
36
|
+
if handler.nil? || !handler.respond_to?(:call)
|
37
|
+
raise ArgumentError, 'Please pass either an object#call or a handler block'
|
38
|
+
end
|
37
39
|
|
38
40
|
Array(event_ids).flatten.each do |id|
|
39
41
|
@handlers[
|
@@ -51,7 +53,7 @@ module Aruba
|
|
51
53
|
# handler.
|
52
54
|
#
|
53
55
|
def notify(event)
|
54
|
-
|
56
|
+
raise NoEventError, 'Please pass an event object, not a class' if event.is_a?(Class)
|
55
57
|
|
56
58
|
@handlers[event.class.to_s].each { |handler| handler.call(event) }
|
57
59
|
end
|
@@ -15,11 +15,11 @@ module Aruba
|
|
15
15
|
|
16
16
|
# Thanks ActiveSupport
|
17
17
|
# (Only needed to support Ruby 1.9.3 and JRuby)
|
18
|
-
# rubocop:disable Metrics/CyclomaticComplexity
|
19
18
|
def constantize(camel_cased_word)
|
20
19
|
names = camel_cased_word.split('::')
|
21
20
|
|
22
|
-
# Trigger a built-in NameError exception including the ill-formed
|
21
|
+
# Trigger a built-in NameError exception including the ill-formed
|
22
|
+
# constant in the message.
|
23
23
|
Object.const_get(camel_cased_word) if names.empty?
|
24
24
|
|
25
25
|
# Remove the first blank element in case of '::ClassName' notation.
|
@@ -49,7 +49,6 @@ module Aruba
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
52
|
-
# rubocop:enable Metrics/CyclomaticComplexity
|
53
52
|
end
|
54
53
|
|
55
54
|
# @private
|
@@ -120,7 +119,8 @@ module Aruba
|
|
120
119
|
class FailingResolver
|
121
120
|
class << self
|
122
121
|
def match?(event_id)
|
123
|
-
|
122
|
+
raise ArgumentError,
|
123
|
+
%(Input type "#{event_id.class}" of event_id "#{event_id}" is invalid)
|
124
124
|
end
|
125
125
|
|
126
126
|
def supports
|
@@ -147,10 +147,11 @@ module Aruba
|
|
147
147
|
|
148
148
|
def transform(event_id)
|
149
149
|
resolvers.find { |r| r.match? event_id }.new.transform(default_namespace, event_id)
|
150
|
-
rescue => e
|
151
|
-
|
152
|
-
|
153
|
-
|
150
|
+
rescue StandardError => e
|
151
|
+
types = @resolvers.map(&:supports).flatten.join(', ')
|
152
|
+
message = "Transforming \"#{event_id}\" into an event class failed." \
|
153
|
+
" Supported types are: #{types}. #{e.message}."
|
154
|
+
raise EventNameResolveError, message, cause: e
|
154
155
|
end
|
155
156
|
end
|
156
157
|
end
|
data/lib/aruba/events.rb
CHANGED
@@ -4,7 +4,8 @@ module Aruba
|
|
4
4
|
module Events
|
5
5
|
# Basic event
|
6
6
|
#
|
7
|
-
# This is not meant for direct use - BasicEvent.new - by users. It is
|
7
|
+
# This is not meant for direct use - BasicEvent.new - by users. It is
|
8
|
+
# inherited by normal events
|
8
9
|
#
|
9
10
|
# @private
|
10
11
|
class BasicEvent
|
data/lib/aruba/hooks.rb
CHANGED
@@ -21,12 +21,10 @@ module Aruba
|
|
21
21
|
# @param [Proc] block
|
22
22
|
# The block which should be run for the hook
|
23
23
|
def append(label, block)
|
24
|
-
|
25
|
-
store[label.to_sym] << block
|
26
|
-
else
|
24
|
+
unless store.key?(label.to_sym) && store[label.to_sym].respond_to?(:<<)
|
27
25
|
store[label.to_sym] = []
|
28
|
-
store[label.to_sym] << block
|
29
26
|
end
|
27
|
+
store[label.to_sym] << block
|
30
28
|
end
|
31
29
|
|
32
30
|
# Run hook
|
@@ -15,14 +15,17 @@ module Aruba
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def method_missing(name, *args)
|
18
|
-
|
19
|
-
|
18
|
+
if config.key? name
|
19
|
+
raise ArgumentError, 'Options take no argument' if args.any?
|
20
20
|
|
21
|
-
|
21
|
+
config[name]
|
22
|
+
else
|
23
|
+
super
|
24
|
+
end
|
22
25
|
end
|
23
26
|
|
24
|
-
def respond_to_missing?(
|
25
|
-
|
27
|
+
def respond_to_missing?(name, _include_private)
|
28
|
+
config.key? name
|
26
29
|
end
|
27
30
|
end
|
28
31
|
end
|
data/lib/aruba/initializer.rb
CHANGED
@@ -23,7 +23,8 @@ module Aruba
|
|
23
23
|
end
|
24
24
|
|
25
25
|
content = if File.exist? file
|
26
|
-
file_ends_with_carriage_return =
|
26
|
+
file_ends_with_carriage_return =
|
27
|
+
File.open(file, 'r').readlines.last.match(/.*\n$/)
|
27
28
|
|
28
29
|
prefix = file_ends_with_carriage_return ? '' : "\n"
|
29
30
|
|
@@ -53,7 +54,8 @@ module Aruba
|
|
53
54
|
end
|
54
55
|
|
55
56
|
def start(*)
|
56
|
-
|
57
|
+
raise ArgumentError,
|
58
|
+
%(Unknown test framework. Please use one of :rspec, :cucumber or :minitest)
|
57
59
|
end
|
58
60
|
end
|
59
61
|
end
|
@@ -206,7 +208,7 @@ module Aruba
|
|
206
208
|
begin
|
207
209
|
initializers.find { |i| i.match? test_framework }.start [], {}
|
208
210
|
rescue ArgumentError => e
|
209
|
-
|
211
|
+
warn e.message
|
210
212
|
exit 0
|
211
213
|
end
|
212
214
|
|
@@ -33,6 +33,8 @@ module Aruba
|
|
33
33
|
|
34
34
|
# @private
|
35
35
|
module HashFormatting
|
36
|
+
module_function
|
37
|
+
|
36
38
|
# `{ :a => 5, :b => 2 }.inspect` produces:
|
37
39
|
#
|
38
40
|
# {:a=>5, :b=>2}
|
@@ -45,7 +47,6 @@ module Aruba
|
|
45
47
|
def improve_hash_formatting(inspect_string)
|
46
48
|
inspect_string.gsub(/(\S)=>(\S)/, '\1 => \2')
|
47
49
|
end
|
48
|
-
module_function :improve_hash_formatting
|
49
50
|
end
|
50
51
|
|
51
52
|
include HashFormatting
|
@@ -70,16 +71,6 @@ module Aruba
|
|
70
71
|
def failure_message_when_negated
|
71
72
|
"expected #{description_of @actual} not to #{description}"
|
72
73
|
end
|
73
|
-
|
74
|
-
# @private
|
75
|
-
# rubocop:disable Naming/PredicateName
|
76
|
-
def self.has_default_failure_messages?(matcher)
|
77
|
-
matcher.method(:failure_message).owner == self &&
|
78
|
-
matcher.method(:failure_message_when_negated).owner == self
|
79
|
-
rescue NameError
|
80
|
-
false
|
81
|
-
end
|
82
|
-
# rubocop:enable Naming/PredicateName
|
83
74
|
end
|
84
75
|
|
85
76
|
include DefaultFailureMessages
|