aruba 1.0.0.pre.alpha.3 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +0 -1
  3. data/.rubocop.yml +40 -1
  4. data/.rubocop_todo.yml +106 -254
  5. data/.simplecov +7 -5
  6. data/.travis.yml +25 -38
  7. data/CHANGELOG.md +246 -46
  8. data/CONTRIBUTING.md +8 -17
  9. data/Gemfile +5 -54
  10. data/LICENSE +1 -1
  11. data/README.md +37 -30
  12. data/Rakefile +23 -50
  13. data/appveyor.yml +4 -8
  14. data/aruba.gemspec +34 -13
  15. data/bin/console +1 -1
  16. data/cucumber.yml +4 -15
  17. data/exe/aruba +1 -1
  18. data/fixtures/cli-app/bin/aruba-test-cli +1 -1
  19. data/fixtures/cli-app/cli-app.gemspec +4 -5
  20. data/fixtures/cli-app/lib/cli/app.rb +1 -1
  21. data/fixtures/cli-app/spec/spec_helper.rb +3 -2
  22. data/fixtures/empty-app/cli-app.gemspec +4 -5
  23. data/fixtures/empty-app/lib/cli/app.rb +0 -2
  24. data/fixtures/getting-started-app/Gemfile +1 -1
  25. data/lib/aruba/api.rb +6 -6
  26. data/lib/aruba/api/bundler.rb +1 -1
  27. data/lib/aruba/api/commands.rb +36 -13
  28. data/lib/aruba/api/core.rb +74 -47
  29. data/lib/aruba/api/environment.rb +16 -4
  30. data/lib/aruba/api/filesystem.rb +48 -48
  31. data/lib/aruba/api/text.rb +15 -3
  32. data/lib/aruba/aruba_path.rb +24 -95
  33. data/lib/aruba/basic_configuration.rb +5 -6
  34. data/lib/aruba/basic_configuration/option.rb +2 -2
  35. data/lib/aruba/cli.rb +4 -1
  36. data/lib/aruba/colorizer.rb +10 -99
  37. data/lib/aruba/config/jruby.rb +15 -5
  38. data/lib/aruba/config_wrapper.rb +17 -2
  39. data/lib/aruba/configuration.rb +43 -14
  40. data/lib/aruba/console.rb +0 -2
  41. data/lib/aruba/console/help.rb +5 -2
  42. data/lib/aruba/contracts/absolute_path.rb +3 -3
  43. data/lib/aruba/contracts/is_power_of_two.rb +2 -2
  44. data/lib/aruba/contracts/relative_path.rb +3 -3
  45. data/lib/aruba/cucumber.rb +0 -2
  46. data/lib/aruba/cucumber/command.rb +190 -93
  47. data/lib/aruba/cucumber/file.rb +53 -35
  48. data/lib/aruba/cucumber/hooks.rb +4 -1
  49. data/lib/aruba/cucumber/testing_frameworks.rb +76 -50
  50. data/lib/aruba/event_bus.rb +4 -2
  51. data/lib/aruba/event_bus/name_resolver.rb +9 -8
  52. data/lib/aruba/events.rb +2 -1
  53. data/lib/aruba/hooks.rb +2 -4
  54. data/lib/aruba/in_config_wrapper.rb +10 -3
  55. data/lib/aruba/initializer.rb +37 -31
  56. data/lib/aruba/matchers/base/base_matcher.rb +2 -11
  57. data/lib/aruba/matchers/base/message_indenter.rb +1 -1
  58. data/lib/aruba/matchers/base/object_formatter.rb +0 -5
  59. data/lib/aruba/matchers/collection/include_an_object.rb +4 -4
  60. data/lib/aruba/matchers/command/be_successfully_executed.rb +6 -0
  61. data/lib/aruba/matchers/command/have_exit_status.rb +15 -3
  62. data/lib/aruba/matchers/command/have_finished_in_time.rb +3 -1
  63. data/lib/aruba/matchers/command/have_output.rb +3 -1
  64. data/lib/aruba/matchers/command/have_output_on_stderr.rb +3 -1
  65. data/lib/aruba/matchers/command/have_output_on_stdout.rb +3 -1
  66. data/lib/aruba/matchers/command/have_output_size.rb +1 -1
  67. data/lib/aruba/matchers/directory/be_an_existing_directory.rb +1 -1
  68. data/lib/aruba/matchers/directory/have_sub_directory.rb +8 -3
  69. data/lib/aruba/matchers/file/be_an_existing_file.rb +1 -1
  70. data/lib/aruba/matchers/file/have_file_size.rb +4 -2
  71. data/lib/aruba/matchers/path/have_permissions.rb +4 -2
  72. data/lib/aruba/platform.rb +0 -7
  73. data/lib/aruba/platforms/announcer.rb +36 -17
  74. data/lib/aruba/platforms/aruba_file_creator.rb +3 -1
  75. data/lib/aruba/platforms/aruba_fixed_size_file_creator.rb +7 -2
  76. data/lib/aruba/platforms/command_monitor.rb +39 -3
  77. data/lib/aruba/platforms/determine_disk_usage.rb +56 -19
  78. data/lib/aruba/platforms/simple_table.rb +2 -10
  79. data/lib/aruba/platforms/unix_environment_variables.rb +10 -13
  80. data/lib/aruba/platforms/unix_platform.rb +16 -12
  81. data/lib/aruba/platforms/unix_which.rb +1 -1
  82. data/lib/aruba/platforms/windows_command_string.rb +2 -2
  83. data/lib/aruba/platforms/windows_environment_variables.rb +9 -2
  84. data/lib/aruba/platforms/windows_platform.rb +4 -0
  85. data/lib/aruba/platforms/windows_which.rb +6 -2
  86. data/lib/aruba/processes/basic_process.rb +13 -15
  87. data/lib/aruba/processes/debug_process.rb +11 -5
  88. data/lib/aruba/processes/in_process.rb +4 -2
  89. data/lib/aruba/processes/spawn_process.rb +32 -16
  90. data/lib/aruba/rspec.rb +24 -14
  91. data/lib/aruba/runtime.rb +11 -4
  92. data/lib/aruba/setup.rb +27 -14
  93. data/lib/aruba/tasks/docker_helpers.rb +3 -1
  94. data/lib/aruba/version.rb +1 -1
  95. metadata +190 -34
  96. data/bin/build +0 -3
  97. data/bin/release +0 -3
  98. data/lib/aruba/platforms/disk_usage_calculator.rb +0 -20
@@ -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 "([^"]*)"$/) do |source, destination|
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 "([^"]*)"$/) do |source, destination|
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 "([^"]*)"$/) do |dir_name, dir_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
@@ -25,14 +28,15 @@ Given(/^(?:a|the) file(?: named)? "([^"]*)" with:$/) do |file_name, file_content
25
28
  end
26
29
 
27
30
  Given(/^(?:an|the) executable(?: named)? "([^"]*)" with:$/) do |file_name, file_content|
28
- step %(a file named "#{file_name}" with mode "0755" and with:), file_content
31
+ step %(a file named "#{file_name}" with mode "0o755" and with:), file_content
29
32
  end
30
33
 
31
34
  Given(/^(?:a|the) file(?: named)? "([^"]*)" with "([^"]*)"$/) do |file_name, file_content|
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:$/) do |file_name, file_mode, file_content|
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 "([^"]*)"$/) do |file_name, file_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:$/) do |file_name, file_content|
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)?$/) do |name, force_remove|
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,21 +95,21 @@ Then(/^the following files should (not )?exist:$/) do |negated, files|
88
95
  end
89
96
  end
90
97
 
91
- Then(/^(?:a|the) (file|directory)(?: named)? "([^"]*)" should (not )?exist(?: anymore)?$/) do |directory_or_file, path, expect_match|
92
- if directory_or_file == 'file'
93
- if expect_match
94
- expect(path).not_to be_an_existing_file
95
- else
96
- expect(path).to be_an_existing_file
97
- end
98
- elsif directory_or_file == 'directory'
99
- if expect_match
100
- expect(path).not_to be_an_existing_directory
101
- else
102
- expect(path).to be_an_existing_directory
103
- end
98
+ Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?exist(?: anymore)?$/) \
99
+ do |path, expect_match|
100
+ if expect_match
101
+ expect(path).not_to be_an_existing_file
102
+ else
103
+ expect(path).to be_an_existing_file
104
+ end
105
+ end
106
+
107
+ Then(/^(?:a|the) directory(?: named)? "([^"]*)" should (not )?exist(?: anymore)?$/) \
108
+ do |path, expect_match|
109
+ if expect_match
110
+ expect(path).not_to be_an_existing_directory
104
111
  else
105
- fail ArgumentError, %("#{directory_or_file}" can only be "directory" or "file".)
112
+ expect(path).to be_an_existing_directory
106
113
  end
107
114
  end
108
115
 
@@ -114,7 +121,8 @@ Then(/^(?:a|the) file matching %r<(.*?)> should (not )?exist$/) do |pattern, exp
114
121
  end
115
122
  end
116
123
 
117
- Then(/^(?:a|the) (\d+) byte file(?: named)? "([^"]*)" should (not )?exist$/) do |size, file, negated|
124
+ Then(/^(?:a|the) (\d+) byte file(?: named)? "([^"]*)" should (not )?exist$/) \
125
+ do |size, file, negated|
118
126
  if negated
119
127
  expect(file).not_to have_file_size(size)
120
128
  else
@@ -132,7 +140,8 @@ Then(/^the following directories should (not )?exist:$/) do |negated, directorie
132
140
  end
133
141
  end
134
142
 
135
- Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?contain "([^"]*)"$/) do |file, negated, content|
143
+ Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?contain "([^"]*)"$/) \
144
+ do |file, negated, content|
136
145
  if negated
137
146
  expect(file).not_to have_file_content file_content_including(content.chomp)
138
147
  else
@@ -140,7 +149,8 @@ Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?contain "([^"]*)"$/) do
140
149
  end
141
150
  end
142
151
 
143
- Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?contain:$/) do |file, negated, content|
152
+ Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?contain:$/) \
153
+ do |file, negated, content|
144
154
  if negated
145
155
  expect(file).not_to have_file_content file_content_including(content.chomp)
146
156
  else
@@ -148,7 +158,8 @@ Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?contain:$/) do |file, n
148
158
  end
149
159
  end
150
160
 
151
- Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?contain exactly:$/) do |file, negated, content|
161
+ Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?contain exactly:$/) \
162
+ do |file, negated, content|
152
163
  if negated
153
164
  expect(file).not_to have_file_content content
154
165
  else
@@ -156,7 +167,8 @@ Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?contain exactly:$/) do
156
167
  end
157
168
  end
158
169
 
159
- Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?match %r<([^>]*)>$/) do |file, negated, content|
170
+ Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?match %r<([^>]*)>$/) \
171
+ do |file, negated, content|
160
172
  if negated
161
173
  expect(file).not_to have_file_content file_content_matching(content)
162
174
  else
@@ -164,7 +176,8 @@ Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?match %r<([^>]*)>$/) do
164
176
  end
165
177
  end
166
178
 
167
- Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?match \/([^\/]*)\/$/) do |file, negated, content|
179
+ Then(%r{^(?:a|the) file(?: named)? "([^"]*)" should (not )?match /([^/]*)/$}) \
180
+ do |file, negated, content|
168
181
  if negated
169
182
  expect(file).not_to have_file_content file_content_matching(content)
170
183
  else
@@ -172,7 +185,8 @@ Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?match \/([^\/]*)\/$/) d
172
185
  end
173
186
  end
174
187
 
175
- Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?be equal to file "([^"]*)"/) do |file, negated, reference_file|
188
+ Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?be equal to file "([^"]*)"/) \
189
+ do |file, negated, reference_file|
176
190
  if negated
177
191
  expect(file).not_to have_same_file_content_as(reference_file)
178
192
  else
@@ -180,10 +194,14 @@ Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?be equal to file "([^"]
180
194
  end
181
195
  end
182
196
 
183
- Then(/^the (?:file|directory)(?: named)? "([^"]*)" should( not)? have permissions "([^"]*)"$/) do |path, negated, permissions|
184
- if negated
185
- expect(path).not_to have_permissions(permissions)
186
- else
187
- expect(path).to have_permissions(permissions)
188
- end
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)
189
207
  end
@@ -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 'PATH', aruba.config.command_search_paths.join(File::PATH_SEPARATOR) + File::PATH_SEPARATOR
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,25 +1,33 @@
1
1
  # Cucumber
2
- Then /^the feature(?:s)? should( not)?(?: all)? pass$/ do |negated|
3
- if negated
4
- step 'the output should contain " failed)"'
5
- step 'the exit status should be 1'
6
- else
7
- step 'the output should not contain " failed)"'
8
- step 'the output should not contain " undefined)"'
9
- step 'the exit status should be 0'
10
- end
2
+ Then(/^the feature(?:s)? should not(?: all)? pass$/) do
3
+ step 'the output should contain " failed)"'
4
+ step 'the exit status should be 1'
5
+ end
6
+
7
+ # Cucumber
8
+ Then(/^the feature(?:s)? should(?: all)? pass$/) do
9
+ step 'the output should not contain " failed)"'
10
+ step 'the output should not contain " undefined)"'
11
+ step 'the exit status should be 0'
11
12
  end
12
13
 
13
14
  # Cucumber
14
- Then /^the feature(?:s)? should( not)?(?: all)? pass with( regex)?:$/ do |negated, regex, string|
15
- if negated
16
- step 'the output should contain " failed)"'
17
- step 'the exit status should be 1'
15
+ Then(/^the feature(?:s)? should not(?: all)? pass with( regex)?:$/) do |regex, string|
16
+ step 'the output should contain " failed)"'
17
+ step 'the exit status should be 1'
18
+
19
+ if regex
20
+ step "the output should match %r<#{string}>"
18
21
  else
19
- step 'the output should not contain " failed)"'
20
- step 'the output should not contain " undefined)"'
21
- step 'the exit status should be 0'
22
+ step 'the output should contain:', string
22
23
  end
24
+ end
25
+
26
+ # Cucumber
27
+ Then(/^the feature(?:s)? should(?: all)? pass with( regex)?:$/) do |regex, string|
28
+ step 'the output should not contain " failed)"'
29
+ step 'the output should not contain " undefined)"'
30
+ step 'the exit status should be 0'
23
31
 
24
32
  if regex
25
33
  step "the output should match %r<#{string}>"
@@ -29,30 +37,39 @@ Then /^the feature(?:s)? should( not)?(?: all)? pass with( regex)?:$/ do |negate
29
37
  end
30
38
 
31
39
  # RSpec
32
- Then /^the spec(?:s)? should( not)?(?: all)? pass(?: with (\d+) failures?)?$/ do |negated, count_failures|
33
- if negated
34
- if count_failures.nil?
35
- step 'the output should not contain "0 failures"'
36
- else
37
- step %(the output should contain "#{count_failures} failures")
38
- end
39
-
40
- step 'the exit status should be 1'
40
+ Then(/^the spec(?:s)? should not(?: all)? pass(?: with (\d+) failures?)?$/) \
41
+ do |count_failures|
42
+ if count_failures.nil?
43
+ step 'the output should not contain "0 failures"'
41
44
  else
42
- step 'the output should contain "0 failures"'
43
- step 'the exit status should be 0'
45
+ step %(the output should contain "#{count_failures} failures")
44
46
  end
47
+
48
+ step 'the exit status should be 1'
45
49
  end
46
50
 
47
51
  # RSpec
48
- Then /^the spec(?:s)? should( not)?(?: all)? pass with( regex)?:$/ do |negated, regex, string|
49
- if negated
50
- step 'the output should not contain "0 failures"'
51
- step 'the exit status should be 1'
52
+ Then(/^the spec(?:s)? should all pass$/) do
53
+ step 'the output should contain "0 failures"'
54
+ step 'the exit status should be 0'
55
+ end
56
+
57
+ # RSpec
58
+ Then(/^the spec(?:s)? should not(?: all)? pass with( regex)?:$/) do |regex, string|
59
+ step 'the output should not contain "0 failures"'
60
+ step 'the exit status should be 1'
61
+
62
+ if regex
63
+ step "the output should match %r<#{string}>"
52
64
  else
53
- step 'the output should contain "0 failures"'
54
- step 'the exit status should be 0'
65
+ step 'the output should contain:', string
55
66
  end
67
+ end
68
+
69
+ # RSpec
70
+ Then(/^the spec(?:s)? should(?: all)? pass with( regex)?:$/) do |regex, string|
71
+ step 'the output should contain "0 failures"'
72
+ step 'the exit status should be 0'
56
73
 
57
74
  if regex
58
75
  step "the output should match %r<#{string}>"
@@ -62,30 +79,39 @@ Then /^the spec(?:s)? should( not)?(?: all)? pass with( regex)?:$/ do |negated,
62
79
  end
63
80
 
64
81
  # Minitest
65
- Then /^the tests(?:s)? should( not)?(?: all)? pass(?: with (\d+) failures?)?$/ do |negated, count_failures|
66
- if negated
67
- if count_failures.nil?
68
- step 'the output should not contain "0 errors"'
69
- else
70
- step %(the output should contain "#{count_failures} errors")
71
- end
72
-
73
- step 'the exit status should be 1'
82
+ Then(/^the tests(?:s)? should not(?: all)? pass(?: with (\d+) failures?)?$/) \
83
+ do |count_failures|
84
+ if count_failures.nil?
85
+ step 'the output should not contain "0 errors"'
74
86
  else
75
- step 'the output should contain "0 errors"'
76
- step 'the exit status should be 0'
87
+ step %(the output should contain "#{count_failures} errors")
77
88
  end
89
+
90
+ step 'the exit status should be 1'
78
91
  end
79
92
 
80
93
  # Minitest
81
- Then /^the test(?:s)? should( not)?(?: all)? pass with( regex)?:$/ do |negated, regex, string|
82
- if negated
83
- step 'the output should contain "0 errors"'
84
- step 'the exit status should be 1'
94
+ Then(/^the tests(?:s)? should all pass$/) do
95
+ step 'the output should contain "0 errors"'
96
+ step 'the exit status should be 0'
97
+ end
98
+
99
+ # Minitest
100
+ Then(/^the test(?:s)? should not(?: all)? pass with( regex)?:$/) do |regex, string|
101
+ step 'the output should contain "0 errors"'
102
+ step 'the exit status should be 1'
103
+
104
+ if regex
105
+ step "the output should match %r<#{string}>"
85
106
  else
86
- step 'the output should not contain "0 errors"'
87
- step 'the exit status should be 0'
107
+ step 'the output should contain:', string
88
108
  end
109
+ end
110
+
111
+ # Minitest
112
+ Then(/^the test(?:s)? should(?: all)? pass with( regex)?:$/) do |regex, string|
113
+ step 'the output should not contain "0 errors"'
114
+ step 'the exit status should be 0'
89
115
 
90
116
  if regex
91
117
  step "the output should match %r<#{string}>"
@@ -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
- fail ArgumentError, 'Please pass either an object#call or a handler block' if handler.nil? || !handler.respond_to?(:call)
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
- fail NoEventError, 'Please pass an event object, not a class' if event.is_a?(Class)
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 constant in the message.
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
- fail ArgumentError, %(Input type "#{event_id.class}" of event_id "#{event_id}" is invalid)
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
- # rubocop:disable Metrics/LineLength
152
- raise EventNameResolveError, %(Transforming "#{event_id}" into an event class failed. Supported types are: #{@resolvers.map(&:supports).flatten.join(', ')}. #{e.message}.\n\n#{e.backtrace.join("\n")})
153
- # rubocop:enable Metrics/LineLength
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
@@ -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 inherited by normal events
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
@@ -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
- if store.key?(label.to_sym) && store[label.to_sym].respond_to?(:<<)
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