aruba 0.9.0.pre → 0.9.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +8 -3
- data/History.md +61 -19
- data/README.md +10 -6
- data/TODO.md +6 -1
- data/cucumber.yml +10 -6
- data/features/.nav +72 -0
- data/features/announce.feature +203 -0
- data/features/api/command/extract_text.feature +10 -0
- data/features/api/command/run.feature +6 -6
- data/features/api/command/stop_all_commands.feature +53 -0
- data/features/api/command/terminate_all_commands.feature +53 -0
- data/features/api/command/unescape_text.feature +12 -0
- data/features/api/command/which.feature +3 -3
- data/features/api/core/expand_path.feature +4 -4
- data/features/api/environment/append_environment_variable.feature +18 -8
- data/features/api/environment/prepend_environment_variable.feature +18 -8
- data/features/api/environment/set_environment_variable.feature +33 -16
- data/features/api/filesystem/cd.feature +23 -13
- data/features/api/filesystem/create_directory.feature +2 -2
- data/features/api/filesystem/disk_usage.feature +7 -6
- data/features/api/filesystem/does_exist.feature +2 -2
- data/features/api/filesystem/is_absolute.feature +2 -2
- data/features/api/filesystem/is_directory.feature +2 -2
- data/features/api/filesystem/is_file.feature +2 -2
- data/features/api/filesystem/is_relative.feature +2 -2
- data/features/api/filesystem/move.feature +119 -0
- data/features/cli/console.feature +3 -3
- data/features/commands/debug_command.feature +93 -0
- data/features/commands/environment_variables.feature +64 -0
- data/features/commands/flushing.feature +74 -0
- data/features/commands/interactive.feature +90 -0
- data/features/commands/output/all_output.feature +445 -0
- data/features/commands/output/stdout.feature +66 -0
- data/features/configuration/exit_timeout.feature +5 -5
- data/features/configuration/fixtures_directories.feature +3 -3
- data/features/configuration/fixtures_path_prefix.feature +1 -1
- data/features/configuration/home_directory.feature +4 -4
- data/features/configuration/io_timeout.feature +2 -2
- data/features/configuration/keep_ansi.feature +2 -2
- data/features/configuration/log_level.feature +3 -3
- data/features/configuration/physical_block_size.feature +3 -3
- data/features/configuration/usage.feature +159 -0
- data/features/core/cleanup_aruba_directory.feature +52 -0
- data/features/development/build.feature +16 -0
- data/features/development/test.feature +24 -0
- data/features/file_system_commands.feature +12 -12
- data/features/getting_started/supported_programming_languages.feature +89 -0
- data/features/hooks/after/command.feature +1 -1
- data/features/hooks/before/command.feature +2 -2
- data/features/matchers/collection/include_an_object.feature +72 -0
- data/features/matchers/timeouts.feature +2 -2
- data/features/output.feature +60 -181
- data/features/step_definitions/aruba_dev_steps.rb +17 -10
- data/features/step_definitions/hooks.rb +11 -0
- data/features/steps/commands/exit_statuses.feature +3 -3
- data/features/steps/commands/run.feature +0 -15
- data/features/steps/filesystem/copy.feature +45 -0
- data/features/steps/filesystem/create_directory.feature +47 -0
- data/features/steps/filesystem/create_file.feature +53 -0
- data/features/steps/filesystem/file_content.feature +1 -1
- data/features/steps/filesystem/move.feature +45 -0
- data/features/steps/filesystem/overwrite_file.feature +72 -0
- data/features/steps/filesystem/use_fixture.feature +77 -0
- data/features/usage/install.feature +8 -0
- data/{features/fixtures → fixtures}/cli-app/.gitignore +0 -0
- data/{features/fixtures → fixtures}/cli-app/.rspec +0 -0
- data/{features/fixtures → fixtures}/cli-app/README.md +0 -0
- data/{features/fixtures → fixtures}/cli-app/Rakefile +0 -0
- data/{features/fixtures → fixtures}/cli-app/bin/cli +0 -0
- data/{features/fixtures → fixtures}/cli-app/cli-app.gemspec +0 -0
- data/{features/fixtures → fixtures}/cli-app/features/support/env.rb +0 -0
- data/{features/fixtures → fixtures}/cli-app/lib/cli/app.rb +0 -0
- data/fixtures/cli-app/lib/cli/app/suppress_simple_cov_output.rb +15 -0
- data/{features/fixtures → fixtures}/cli-app/lib/cli/app/version.rb +0 -0
- data/{features/fixtures/empty-app → fixtures/cli-app}/script/console +3 -3
- data/{features/fixtures → fixtures}/cli-app/spec/spec_helper.rb +0 -0
- data/{features/fixtures → fixtures}/cli-app/spec/support/aruba.rb +0 -0
- data/{features/fixtures → fixtures}/copy/file.txt +0 -0
- data/{features/fixtures → fixtures}/empty-app/.gitignore +0 -0
- data/{features/fixtures → fixtures}/empty-app/.rspec +0 -0
- data/{features/fixtures → fixtures}/empty-app/README.md +0 -0
- data/{features/fixtures → fixtures}/empty-app/Rakefile +0 -0
- data/{features/fixtures → fixtures}/empty-app/bin/cli +0 -0
- data/{features/fixtures → fixtures}/empty-app/cli-app.gemspec +0 -0
- data/{features/fixtures → fixtures}/empty-app/lib/cli/app.rb +0 -0
- data/{features/fixtures → fixtures}/empty-app/lib/cli/app/version.rb +0 -0
- data/{features/fixtures/cli-app → fixtures/empty-app}/script/console +3 -3
- data/{features/fixtures → fixtures}/empty-app/spec/spec_helper.rb +0 -0
- data/{features/fixtures → fixtures}/fixtures-app/test.txt +0 -0
- data/fixtures/getting-started-app/.gitignore +4 -0
- data/fixtures/getting-started-app/Gemfile +4 -0
- data/fixtures/getting-started-app/README.md +3 -0
- data/fixtures/getting-started-app/features/support/env.rb +1 -0
- data/{features/fixtures → fixtures}/spawn_process/stderr.sh +0 -0
- data/lib/aruba/announcer.rb +6 -2
- data/lib/aruba/api.rb +0 -16
- data/lib/aruba/api/command.rb +64 -266
- data/lib/aruba/api/core.rb +24 -26
- data/lib/aruba/api/deprecated.rb +370 -12
- data/lib/aruba/api/filesystem.rb +64 -15
- data/lib/aruba/aruba_path.rb +4 -0
- data/lib/aruba/config.rb +1 -1
- data/lib/aruba/cucumber.rb +5 -449
- data/lib/aruba/cucumber/command.rb +378 -0
- data/lib/aruba/cucumber/core.rb +29 -0
- data/lib/aruba/cucumber/environment.rb +30 -0
- data/lib/aruba/cucumber/file.rb +210 -0
- data/lib/aruba/cucumber/hooks.rb +11 -14
- data/lib/aruba/cucumber/rvm.rb +3 -0
- data/lib/aruba/matchers/base/base_matcher.rb +94 -0
- data/lib/aruba/matchers/collection.rb +1 -0
- data/lib/aruba/matchers/collection/all_objects.rb +2 -0
- data/lib/aruba/matchers/collection/include_an_object.rb +120 -0
- data/lib/aruba/matchers/command/be_successfully_executed.rb +3 -3
- data/lib/aruba/matchers/command/have_exit_status.rb +2 -11
- data/lib/aruba/matchers/command/have_finished_in_time.rb +5 -5
- data/lib/aruba/matchers/command/have_output.rb +46 -0
- data/lib/aruba/matchers/command/have_output_on_stderr.rb +42 -0
- data/lib/aruba/matchers/command/have_output_on_stdout.rb +42 -0
- data/lib/aruba/matchers/command/have_output_size.rb +28 -0
- data/lib/aruba/matchers/directory/be_an_existing_directory.rb +1 -1
- data/lib/aruba/matchers/file/be_an_existing_file.rb +1 -1
- data/lib/aruba/matchers/file/have_file_content.rb +1 -1
- data/lib/aruba/matchers/file/have_file_size.rb +2 -2
- data/lib/aruba/matchers/file/have_same_file_content.rb +1 -1
- data/lib/aruba/matchers/path/have_permissions.rb +1 -1
- data/lib/aruba/platforms/aruba_file_creator.rb +2 -3
- data/lib/aruba/platforms/aruba_fixed_size_file_creator.rb +2 -3
- data/lib/aruba/platforms/determine_disk_usage.rb +23 -0
- data/lib/aruba/platforms/determine_file_size.rb +13 -0
- data/lib/aruba/platforms/disk_usage_calculator.rb +11 -0
- data/lib/aruba/platforms/local_environment.rb +15 -0
- data/lib/aruba/platforms/unix_environment_variables.rb +1 -1
- data/lib/aruba/platforms/unix_platform.rb +35 -14
- data/lib/aruba/process_monitor.rb +53 -7
- data/lib/aruba/processes/basic_process.rb +25 -5
- data/lib/aruba/processes/debug_process.rb +27 -25
- data/lib/aruba/processes/in_process.rb +7 -22
- data/lib/aruba/processes/spawn_process.rb +74 -31
- data/lib/aruba/rspec.rb +1 -6
- data/lib/aruba/version.rb +1 -1
- data/script/console +0 -1
- data/spec/aruba/api/environment/restore_env_spec.rb +65 -0
- data/spec/aruba/api/environment/set_env_spec.rb +42 -0
- data/spec/aruba/api/filesystem/file_size_spec.rb +28 -0
- data/spec/aruba/api_spec.rb +10 -7
- data/spec/aruba/matchers/command/have_output_size_spec.rb +25 -0
- data/spec/aruba/matchers/command_spec.rb +135 -4
- data/spec/aruba/spawn_process_spec.rb +1 -1
- metadata +107 -65
- data/.nav +0 -12
- data/features/debug.feature +0 -15
- data/features/fixtures/cli-app/spec/cli/app_spec.rb +0 -7
- data/features/flushing.feature +0 -26
- data/features/interactive.feature +0 -66
- data/features/no_clobber.feature +0 -25
- data/lib/aruba/disk_usage_calculator.rb +0 -7
@@ -0,0 +1,378 @@
|
|
1
|
+
When(/^I run "(.*)"$/)do |cmd|
|
2
|
+
warn(%{\e[35m The /^I run "(.*)"$/ step definition is deprecated. Please use the `backticks` version\e[0m})
|
3
|
+
|
4
|
+
cmd = unescape_text(cmd)
|
5
|
+
cmd = extract_text(cmd) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
|
6
|
+
|
7
|
+
run_simple(cmd, false)
|
8
|
+
end
|
9
|
+
|
10
|
+
When(/^I run `([^`]*)`$/)do |cmd|
|
11
|
+
cmd = unescape_text(cmd)
|
12
|
+
cmd = extract_text(cmd) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
|
13
|
+
|
14
|
+
run_simple(cmd, false)
|
15
|
+
end
|
16
|
+
|
17
|
+
When(/^I successfully run "(.*)"$/)do |cmd|
|
18
|
+
warn(%{\e[35m The /^I successfully run "(.*)"$/ step definition is deprecated. Please use the `backticks` version\e[0m})
|
19
|
+
|
20
|
+
cmd = unescape_text(cmd)
|
21
|
+
cmd = extract_text(cmd) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
|
22
|
+
|
23
|
+
run_simple(cmd)
|
24
|
+
end
|
25
|
+
|
26
|
+
## I successfully run `echo -n "Hello"`
|
27
|
+
## I successfully run `sleep 29` for up to 30 seconds
|
28
|
+
When(/^I successfully run `(.*?)`(?: for up to (\d+) seconds)?$/)do |cmd, secs|
|
29
|
+
cmd = unescape_text(cmd)
|
30
|
+
cmd = extract_text(cmd) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
|
31
|
+
|
32
|
+
run_simple(cmd, true, secs && secs.to_i)
|
33
|
+
end
|
34
|
+
|
35
|
+
When(/^I run "([^"]*)" interactively$/) do |cmd|
|
36
|
+
Aruba.platform.deprecated(%{\e[35m The /^I run "([^"]*)" interactively$/ step definition is deprecated. Please use the `backticks` version\e[0m})
|
37
|
+
|
38
|
+
step %(I run `#{cmd}` interactively)
|
39
|
+
end
|
40
|
+
|
41
|
+
When(/^I run `([^`]*)` interactively$/)do |cmd|
|
42
|
+
cmd = unescape_text(cmd)
|
43
|
+
cmd = extract_text(cmd) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
|
44
|
+
|
45
|
+
@interactive = run(cmd)
|
46
|
+
end
|
47
|
+
|
48
|
+
When(/^I type "([^"]*)"$/) do |input|
|
49
|
+
type(unescape_text(input))
|
50
|
+
end
|
51
|
+
|
52
|
+
When(/^I close the stdin stream$/) do
|
53
|
+
close_input
|
54
|
+
end
|
55
|
+
|
56
|
+
When(/^I pipe in (?:a|the) file(?: named)? "([^"]*)"$/) do |file|
|
57
|
+
pipe_in_file(file)
|
58
|
+
|
59
|
+
close_input
|
60
|
+
end
|
61
|
+
|
62
|
+
When(/^I stop the command(?: started last)? if (output|stdout|stderr) contains:$/) do |channel, expected|
|
63
|
+
fail %(Invalid output channel "#{channel}" chosen. Please choose one of "output, stdout or stderr") unless %w(output stdout stderr).include? channel
|
64
|
+
|
65
|
+
begin
|
66
|
+
Timeout.timeout(aruba.config.exit_timeout) do
|
67
|
+
loop do
|
68
|
+
output = if RUBY_VERSION < '1.9.3'
|
69
|
+
last_command_started.send channel.to_sym, :wait_for_io => 0
|
70
|
+
else
|
71
|
+
last_command_started.public_send channel.to_sym, :wait_for_io => 0
|
72
|
+
end
|
73
|
+
|
74
|
+
output = unescape_text(output)
|
75
|
+
output = extract_text(output) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
|
76
|
+
|
77
|
+
expected = unescape_text(expected)
|
78
|
+
expected = extract_text(expected) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
|
79
|
+
|
80
|
+
if output.include? expected
|
81
|
+
last_command_started.terminate
|
82
|
+
|
83
|
+
break
|
84
|
+
end
|
85
|
+
|
86
|
+
sleep 0.1
|
87
|
+
end
|
88
|
+
end
|
89
|
+
rescue ChildProcess::TimeoutError, TimeoutError
|
90
|
+
last_command_started.terminate
|
91
|
+
ensure
|
92
|
+
announcer.announce :stdout, last_command_started.stdout
|
93
|
+
announcer.announce :stderr, last_command_started.stderr
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
When(/^I wait for (?:output|stdout) to contain:$/) do |expected|
|
98
|
+
Timeout.timeout(exit_timeout) do
|
99
|
+
loop do
|
100
|
+
begin
|
101
|
+
expected = unescape_text(expected)
|
102
|
+
expected = extract_text(expected) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
|
103
|
+
|
104
|
+
expect(last_command_started).to have_output Regexp.new(expected)
|
105
|
+
rescue ExpectationError
|
106
|
+
sleep 0.1
|
107
|
+
retry
|
108
|
+
end
|
109
|
+
|
110
|
+
break
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
When(/^I wait for (?:output|stdout) to contain "([^"]*)"$/) do |expected|
|
116
|
+
Timeout.timeout(exit_timeout) do
|
117
|
+
loop do
|
118
|
+
begin
|
119
|
+
expected = unescape_text(expected)
|
120
|
+
expected = extract_text(expected) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
|
121
|
+
|
122
|
+
expect(last_command_started).to have_output Regexp.new(expected)
|
123
|
+
rescue ExpectationError
|
124
|
+
sleep 0.1
|
125
|
+
retry
|
126
|
+
end
|
127
|
+
|
128
|
+
break
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
Then(/^the output should be (\d+) bytes long$/) do |size|
|
134
|
+
expect(all_output).to have_output_size size.to_i
|
135
|
+
end
|
136
|
+
|
137
|
+
Then(/^(?:the )?(output|stderr|stdout)(?: from "([^"]*)")? should( not)? contain( exactly)? "([^"]*)"$/) do |channel, cmd, negated, exactly, expected|
|
138
|
+
matcher = case channel.to_sym
|
139
|
+
when :output
|
140
|
+
:have_output
|
141
|
+
when :stderr
|
142
|
+
:have_output_on_stderr
|
143
|
+
when :stdout
|
144
|
+
:have_output_on_stdout
|
145
|
+
end
|
146
|
+
|
147
|
+
commands = if cmd
|
148
|
+
[process_monitor.get_process(Aruba.platform.detect_ruby(cmd))]
|
149
|
+
else
|
150
|
+
all_commands
|
151
|
+
end
|
152
|
+
|
153
|
+
expected = unescape_text(expected).chomp
|
154
|
+
expected = extract_text(expected) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
|
155
|
+
|
156
|
+
expected = if exactly
|
157
|
+
expected
|
158
|
+
else
|
159
|
+
Regexp.new(Regexp.escape(expected))
|
160
|
+
end
|
161
|
+
|
162
|
+
if Aruba::VERSION < '1.0'
|
163
|
+
combined_output = commands.map do |c|
|
164
|
+
c.stop(announcer)
|
165
|
+
c.send(channel.to_sym).chomp
|
166
|
+
end.join("\n")
|
167
|
+
|
168
|
+
if negated
|
169
|
+
expect(combined_output).not_to match expected
|
170
|
+
else
|
171
|
+
expect(combined_output).to match expected
|
172
|
+
end
|
173
|
+
else
|
174
|
+
if negated
|
175
|
+
expect(commands).not_to include_an_object send(matcher, expected)
|
176
|
+
else
|
177
|
+
expect(commands).to include_an_object send(matcher, expected)
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
## the stderr should contain "hello"
|
183
|
+
## the stderr from "echo -n 'Hello'" should contain "hello"
|
184
|
+
## the stderr should contain exactly:
|
185
|
+
## the stderr from "echo -n 'Hello'" should contain exactly:
|
186
|
+
Then(/^(?:the )?(output|stderr|stdout)(?: from "([^"]*)")? should( not)? contain( exactly)?:$/) do |channel, cmd, negated, exactly, expected|
|
187
|
+
matcher = case channel.to_sym
|
188
|
+
when :output
|
189
|
+
:have_output
|
190
|
+
when :stderr
|
191
|
+
:have_output_on_stderr
|
192
|
+
when :stdout
|
193
|
+
:have_output_on_stdout
|
194
|
+
else
|
195
|
+
fail ArgumentError, %(Invalid channel "#{channel}" chosen. Only "output", "stderr" or "stdout" are allowed.)
|
196
|
+
end
|
197
|
+
|
198
|
+
commands = if cmd
|
199
|
+
[process_monitor.get_process(Aruba.platform.detect_ruby(cmd))]
|
200
|
+
else
|
201
|
+
all_commands
|
202
|
+
end
|
203
|
+
|
204
|
+
expected = unescape_text(expected).chomp
|
205
|
+
expected = extract_text(expected) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
|
206
|
+
|
207
|
+
expected = if exactly
|
208
|
+
expected
|
209
|
+
else
|
210
|
+
Regexp.new(Regexp.escape(expected))
|
211
|
+
end
|
212
|
+
|
213
|
+
if Aruba::VERSION < '1.0'
|
214
|
+
combined_output = commands.map do |c|
|
215
|
+
c.stop(announcer)
|
216
|
+
c.send(channel.to_sym).chomp
|
217
|
+
end.join("\n")
|
218
|
+
|
219
|
+
if negated
|
220
|
+
expect(combined_output).not_to match expected
|
221
|
+
else
|
222
|
+
expect(combined_output).to match expected
|
223
|
+
end
|
224
|
+
else
|
225
|
+
if negated
|
226
|
+
expect(commands).not_to include_an_object send(matcher, expected)
|
227
|
+
else
|
228
|
+
expect(commands).to include_an_object send(matcher, expected)
|
229
|
+
end
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
# "the output should match" allows regex in the partial_output, if
|
234
|
+
# you don't need regex, use "the output should contain" instead since
|
235
|
+
# that way, you don't have to escape regex characters that
|
236
|
+
# appear naturally in the output
|
237
|
+
Then(/^the output should( not)? match \/([^\/]*)\/$/) do |negated, expected|
|
238
|
+
if negated
|
239
|
+
expect(all_commands).not_to include_an_object have_output Regexp.new(expected, Regexp::MULTILINE)
|
240
|
+
else
|
241
|
+
expect(all_commands).to include_an_object have_output Regexp.new(expected, Regexp::MULTILINE)
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
Then(/^the output should( not)? match %r<([^>]*)>$/) do |negated, expected|
|
246
|
+
if negated
|
247
|
+
expect(all_commands).not_to include_an_object have_output Regexp.new(expected, Regexp::MULTILINE)
|
248
|
+
else
|
249
|
+
expect(all_commands).to include_an_object have_output Regexp.new(expected, Regexp::MULTILINE)
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
Then(/^the output should( not)? match:$/) do |negated, expected|
|
254
|
+
if negated
|
255
|
+
expect(all_commands).not_to include_an_object have_output Regexp.new(expected, Regexp::MULTILINE)
|
256
|
+
else
|
257
|
+
expect(all_commands).to include_an_object have_output Regexp.new(expected, Regexp::MULTILINE)
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
Then(/^the exit status should( not)? be (\d+)$/) do |negated, exit_status|
|
262
|
+
if negated
|
263
|
+
expect(last_command_stopped).not_to have_exit_status exit_status.to_i
|
264
|
+
else
|
265
|
+
expect(last_command_stopped).to have_exit_status exit_status.to_i
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
Then(/^it should( not)? (pass|fail) with "(.*?)"$/) do |negated, pass_fail, expected|
|
270
|
+
expected = unescape_text(expected).chomp
|
271
|
+
expected = extract_text(expected) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
|
272
|
+
expected = Regexp.new(Regexp.escape(expected))
|
273
|
+
|
274
|
+
if pass_fail == 'pass'
|
275
|
+
expect(last_command_stopped).to be_successfully_executed
|
276
|
+
else
|
277
|
+
expect(last_command_stopped).not_to be_successfully_executed
|
278
|
+
end
|
279
|
+
|
280
|
+
if negated
|
281
|
+
expect(last_command_stopped).not_to have_output expected
|
282
|
+
else
|
283
|
+
expect(last_command_stopped).to have_output expected
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
Then(/^it should( not)? (pass|fail) with:$/) do |negated, pass_fail, expected|
|
288
|
+
expected = unescape_text(expected).chomp
|
289
|
+
expected = extract_text(expected) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
|
290
|
+
expected = Regexp.new(Regexp.escape(expected))
|
291
|
+
|
292
|
+
if pass_fail == 'pass'
|
293
|
+
expect(last_command_stopped).to be_successfully_executed
|
294
|
+
else
|
295
|
+
expect(last_command_stopped).not_to be_successfully_executed
|
296
|
+
end
|
297
|
+
|
298
|
+
if negated
|
299
|
+
expect(last_command_stopped).not_to have_output expected
|
300
|
+
else
|
301
|
+
expect(last_command_stopped).to have_output expected
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
305
|
+
Then(/^it should( not)? (pass|fail) with exactly:$/) do |negated, pass_fail, expected|
|
306
|
+
expected = unescape_text(expected).chomp
|
307
|
+
expected = extract_text(expected) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
|
308
|
+
|
309
|
+
if pass_fail == 'pass'
|
310
|
+
expect(last_command_stopped).to be_successfully_executed
|
311
|
+
else
|
312
|
+
expect(last_command_stopped).not_to be_successfully_executed
|
313
|
+
end
|
314
|
+
|
315
|
+
if negated
|
316
|
+
expect(last_command_stopped).not_to have_output expected
|
317
|
+
else
|
318
|
+
expect(last_command_stopped).to have_output expected
|
319
|
+
end
|
320
|
+
end
|
321
|
+
|
322
|
+
Then(/^it should( not)? (pass|fail) with regexp?:$/) do |negated, pass_fail, expected|
|
323
|
+
expected = unescape_text(expected).chomp
|
324
|
+
expected = extract_text(expected) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
|
325
|
+
expected = Regexp.new(expected, Regexp::MULTILINE)
|
326
|
+
|
327
|
+
if pass_fail == 'pass'
|
328
|
+
expect(last_command_stopped).to be_successfully_executed
|
329
|
+
else
|
330
|
+
expect(last_command_stopped).not_to be_successfully_executed
|
331
|
+
end
|
332
|
+
|
333
|
+
if negated
|
334
|
+
expect(last_command_stopped).not_to have_output expected
|
335
|
+
else
|
336
|
+
expect(last_command_stopped).to have_output expected
|
337
|
+
end
|
338
|
+
end
|
339
|
+
|
340
|
+
Then(/^(?:the )?(output|stderr|stdout) should not contain anything$/) do |channel|
|
341
|
+
matcher = case channel.to_sym
|
342
|
+
when :output
|
343
|
+
:have_output
|
344
|
+
when :stderr
|
345
|
+
:have_output_on_stderr
|
346
|
+
when :stdout
|
347
|
+
:have_output_on_stdout
|
348
|
+
else
|
349
|
+
fail ArgumentError, %(Invalid channel "#{channel}" chosen. Only "output", "stdout" and "stderr" are supported.)
|
350
|
+
end
|
351
|
+
|
352
|
+
expect(all_commands).to include_an_object send(matcher, be_nil.or(be_empty))
|
353
|
+
end
|
354
|
+
|
355
|
+
Then(/^(?:the )?(output|stdout|stderr) should( not)? contain all of these lines:$/) do |channel, negated, table|
|
356
|
+
table.raw.flatten.each do |expected|
|
357
|
+
expected = unescape_text(expected).chomp
|
358
|
+
expected = extract_text(expected) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
|
359
|
+
expected = Regexp.new(Regexp.escape(expected))
|
360
|
+
|
361
|
+
matcher = case channel.to_sym
|
362
|
+
when :output
|
363
|
+
:have_output
|
364
|
+
when :stderr
|
365
|
+
:have_output_on_stderr
|
366
|
+
when :stdout
|
367
|
+
:have_output_on_stdout
|
368
|
+
else
|
369
|
+
fail ArgumentError, %(Invalid channel "#{channel}" chosen. Only "output", "stdout" and "stderr" are supported.)
|
370
|
+
end
|
371
|
+
|
372
|
+
if negated
|
373
|
+
expect(all_commands).not_to include_an_object send(matcher, expected)
|
374
|
+
else
|
375
|
+
expect(all_commands).to include_an_object send(matcher, expected)
|
376
|
+
end
|
377
|
+
end
|
378
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
if Aruba::VERSION >= '1.0.0'
|
2
|
+
Aruba.configure do |config|
|
3
|
+
config.working_directory = 'tmp/cucumber'
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
Given(/the default aruba timeout is (\d+) seconds/) do |seconds|
|
8
|
+
# rubocop:disable Metrics/LineLength
|
9
|
+
Aruba.platform.deprecated(%{The /^the default aruba timeout is (\d+) seconds/ step definition is deprecated. Please use /^the default aruba exit timeout is (\d+) seconds/ step definition is deprecated.})
|
10
|
+
# rubocop:enable Metrics/LineLength
|
11
|
+
|
12
|
+
aruba.config.exit_timeout = seconds.to_i
|
13
|
+
end
|
14
|
+
|
15
|
+
Given(/The default aruba timeout is (\d+) seconds/) do |seconds|
|
16
|
+
# rubocop:disable Metrics/LineLength
|
17
|
+
Aruba.platform.deprecated(%{The /^The default aruba timeout is (\d+) seconds/ step definition is deprecated. Please use /^the default aruba exit timeout is (\d+) seconds/ step definition is deprecated.})
|
18
|
+
# rubocop:enable Metrics/LineLength
|
19
|
+
|
20
|
+
aruba.config.exit_timeout = seconds.to_i
|
21
|
+
end
|
22
|
+
|
23
|
+
Given(/the default aruba io wait timeout is (\d+) seconds/) do |seconds|
|
24
|
+
aruba.config.io_wait_timeout = seconds.to_i
|
25
|
+
end
|
26
|
+
|
27
|
+
Given(/the default aruba exit timeout is (\d+) seconds/) do |seconds|
|
28
|
+
aruba.config.exit_timeout = seconds.to_i
|
29
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
Given(/^a mocked home directory$/)do
|
2
|
+
set_environment_variable 'HOME', expand_path('.')
|
3
|
+
end
|
4
|
+
|
5
|
+
Given(/^I set the environment variables? to:/) do |table|
|
6
|
+
table.hashes.each do |row|
|
7
|
+
variable = row['variable'].to_s.upcase
|
8
|
+
value = row['value'].to_s
|
9
|
+
|
10
|
+
set_environment_variable(variable, value)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
Given(/^I append the values? to the environment variables?:/) do |table|
|
15
|
+
table.hashes.each do |row|
|
16
|
+
variable = row['variable'].to_s.upcase
|
17
|
+
value = row['value'].to_s
|
18
|
+
|
19
|
+
append_environment_variable(variable, value)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
Given(/^I prepend the values? to the environment variables?:/) do |table|
|
24
|
+
table.hashes.each do |row|
|
25
|
+
variable = row['variable'].to_s.upcase
|
26
|
+
value = row['value'].to_s
|
27
|
+
|
28
|
+
prepend_environment_variable(variable, value)
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,210 @@
|
|
1
|
+
Given(/^I use (?:a|the) fixture(?: named)? "([^"]*)"$/) do |name|
|
2
|
+
copy File.join(aruba.config.fixtures_path_prefix, name), name
|
3
|
+
cd name
|
4
|
+
end
|
5
|
+
|
6
|
+
Given(/^I copy (?:a|the) (file|directory)(?: (?:named|from))? "([^"]*)" to "([^"]*)"$/) do |file_or_directory, source, destination|
|
7
|
+
copy source, destination
|
8
|
+
end
|
9
|
+
|
10
|
+
Given(/^I move (?:a|the) (file|directory)(?: (?:named|from))? "([^"]*)" to "([^"]*)"$/) do |file_or_directory, source, destination|
|
11
|
+
move source, destination
|
12
|
+
end
|
13
|
+
|
14
|
+
Given(/^(?:a|the) directory(?: named)? "([^"]*)"$/) do |dir_name|
|
15
|
+
create_directory(dir_name)
|
16
|
+
end
|
17
|
+
|
18
|
+
Given(/^(?:a|the) directory(?: named)? "([^"]*)" with mode "([^"]*)"$/) do |dir_name, dir_mode|
|
19
|
+
create_directory(dir_name)
|
20
|
+
chmod(dir_mode, dir_name)
|
21
|
+
end
|
22
|
+
|
23
|
+
Given(/^(?:a|the) file(?: named)? "([^"]*)" with:$/) do |file_name, file_content|
|
24
|
+
write_file(file_name, file_content)
|
25
|
+
end
|
26
|
+
|
27
|
+
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
|
29
|
+
end
|
30
|
+
|
31
|
+
Given(/^(?:a|the) file(?: named)? "([^"]*)" with "([^"]*)"$/) do |file_name, file_content|
|
32
|
+
file_content = unescape_text(file_content)
|
33
|
+
file_content = extract_text(file_content) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
|
34
|
+
|
35
|
+
write_file(file_name, file_content)
|
36
|
+
end
|
37
|
+
|
38
|
+
Given(/^(?:a|the) file(?: named)? "([^"]*)" with mode "([^"]*)" and with:$/) do |file_name, file_mode, file_content|
|
39
|
+
write_file(file_name, file_content)
|
40
|
+
chmod(file_mode, file_name)
|
41
|
+
end
|
42
|
+
|
43
|
+
Given(/^(?:a|the) (\d+) byte file(?: named)? "([^"]*)"$/) do |file_size, file_name|
|
44
|
+
write_fixed_size_file(file_name, file_size.to_i)
|
45
|
+
end
|
46
|
+
|
47
|
+
Given(/^(?:an|the) empty file(?: named)? "([^"]*)"$/) do |file_name|
|
48
|
+
write_file(file_name, "")
|
49
|
+
end
|
50
|
+
|
51
|
+
Given(/^(?:an|the) empty file(?: named)? "([^"]*)" with mode "([^"]*)"$/) do |file_name, file_mode|
|
52
|
+
write_file(file_name, "")
|
53
|
+
chmod(file_mode, file_name)
|
54
|
+
end
|
55
|
+
|
56
|
+
Given(/^(?:a|the) directory(?: named)? "([^"]*)" does not exist$/) do |directory_name|
|
57
|
+
remove(directory_name, :force => true)
|
58
|
+
end
|
59
|
+
|
60
|
+
When(/^I write to "([^"]*)" with:$/) do |file_name, file_content|
|
61
|
+
write_file(file_name, file_content)
|
62
|
+
end
|
63
|
+
|
64
|
+
When(/^I overwrite(?: (?:a|the) file(?: named)?)? "([^"]*)" with:$/) do |file_name, file_content|
|
65
|
+
overwrite_file(file_name, file_content)
|
66
|
+
end
|
67
|
+
|
68
|
+
When(/^I append to "([^"]*)" with:$/) do |file_name, file_content|
|
69
|
+
append_to_file(file_name, file_content)
|
70
|
+
end
|
71
|
+
|
72
|
+
When(/^I append to "([^"]*)" with "([^"]*)"$/) do |file_name, file_content|
|
73
|
+
append_to_file(file_name, file_content)
|
74
|
+
end
|
75
|
+
|
76
|
+
When(/^I remove (?:a|the) file(?: named)? "([^"]*)"$/) do |file_name|
|
77
|
+
remove(file_name)
|
78
|
+
end
|
79
|
+
|
80
|
+
Given(/^(?:a|the) file(?: named)? "([^"]*)" does not exist$/) do |file_name|
|
81
|
+
remove(file_name, :force => true)
|
82
|
+
end
|
83
|
+
|
84
|
+
When(/^I remove (?:a|the) directory(?: named)? "(.*?)"$/) do |directory_name|
|
85
|
+
remove(directory_name)
|
86
|
+
end
|
87
|
+
|
88
|
+
When(/^I cd to "([^"]*)"$/) do |dir|
|
89
|
+
cd(dir)
|
90
|
+
end
|
91
|
+
|
92
|
+
Then(/^the following files should (not )?exist:$/) do |negated, files|
|
93
|
+
files = files.rows.flatten
|
94
|
+
|
95
|
+
if negated
|
96
|
+
expect(files).not_to include an_existing_file
|
97
|
+
else
|
98
|
+
expect(files).to all_objects be_an_existing_file
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?exist$/) do |file, expect_match|
|
103
|
+
if expect_match
|
104
|
+
expect(file).not_to be_an_existing_file
|
105
|
+
else
|
106
|
+
expect(file).to be_an_existing_file
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
Then(/^(?:a|the) file matching %r<(.*?)> should (not )?exist$/) do |pattern, expect_match|
|
111
|
+
if expect_match
|
112
|
+
expect(all_paths).not_to include match Regexp.new(pattern)
|
113
|
+
else
|
114
|
+
expect(all_paths).to include match Regexp.new(pattern)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
Then(/^(?:a|the) (\d+) byte file(?: named)? "([^"]*)" should (not )?exist$/) do |size, file, negated|
|
119
|
+
if negated
|
120
|
+
expect(file).not_to have_file_size(size)
|
121
|
+
else
|
122
|
+
expect(file).to have_file_size(size)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
Then(/^the following directories should (not )?exist:$/) do |negated, directories|
|
127
|
+
directories = directories.rows.flatten
|
128
|
+
|
129
|
+
if negated
|
130
|
+
expect(directories).not_to include an_existing_directory
|
131
|
+
else
|
132
|
+
expect(directories).to all_objects be_an_existing_directory
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
Then(/^(?:a|the) directory(?: named)? "([^"]*)" should (not )?exist$/) do |directory, negated|
|
137
|
+
if negated
|
138
|
+
expect(directory).not_to be_an_existing_directory
|
139
|
+
else
|
140
|
+
expect(directory).to be_an_existing_directory
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?contain "([^"]*)"$/) do |file, negated, content|
|
145
|
+
if negated
|
146
|
+
expect(file).not_to have_file_content Regexp.new(Regexp.escape(content.chomp))
|
147
|
+
else
|
148
|
+
expect(file).to have_file_content Regexp.new(Regexp.escape(content.chomp))
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?contain:$/) do |file, negated, content|
|
153
|
+
if negated
|
154
|
+
expect(file).not_to have_file_content Regexp.new(Regexp.escape(content.chomp))
|
155
|
+
else
|
156
|
+
expect(file).to have_file_content Regexp.new(Regexp.escape(content.chomp))
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?contain exactly:$/) do |file, negated, content|
|
161
|
+
if negated
|
162
|
+
expect(file).not_to have_file_content content
|
163
|
+
else
|
164
|
+
expect(file).to have_file_content content
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?match %r<([^\/]*)>$/) do |file, negated, content|
|
169
|
+
if negated
|
170
|
+
expect(file).not_to have_file_content Regexp.new(content)
|
171
|
+
else
|
172
|
+
expect(file).to have_file_content Regexp.new(content)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?match \/([^\/]*)\/$/) do |file, negated, content|
|
177
|
+
if negated
|
178
|
+
expect(file).not_to have_file_content Regexp.new(content)
|
179
|
+
else
|
180
|
+
expect(file).to have_file_content Regexp.new(content)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?be equal to file "([^"]*)"/) do |file, negated, reference_file|
|
185
|
+
if negated
|
186
|
+
expect(file).not_to have_same_file_content_like(reference_file)
|
187
|
+
else
|
188
|
+
expect(file).to have_same_file_content_like(reference_file)
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
Then(/^the mode of filesystem object "([^"]*)" should (not )?match "([^"]*)"$/) do |file, negated, permissions|
|
193
|
+
# rubocop:disable Metrics/LineLength
|
194
|
+
Aruba.platform.deprecated('The use of step "the mode of filesystem object "([^"]*)" should (not )?match "([^"]*)" is deprecated. Use "^the (?:file|directory)(?: named)? "([^"]*)" should have permissions "([^"]*)"$" instead')
|
195
|
+
# rubocop:enable Metrics/LineLength
|
196
|
+
|
197
|
+
if negated
|
198
|
+
expect(file).not_to have_permissions(permissions)
|
199
|
+
else
|
200
|
+
expect(file).to have_permissions(permissions)
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
Then(/^the (?:file|directory)(?: named)? "([^"]*)" should( not)? have permissions "([^"]*)"$/) do |path, negated, permissions|
|
205
|
+
if negated
|
206
|
+
expect(path).not_to have_permissions(permissions)
|
207
|
+
else
|
208
|
+
expect(path).to have_permissions(permissions)
|
209
|
+
end
|
210
|
+
end
|