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.
Files changed (158) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +8 -3
  3. data/History.md +61 -19
  4. data/README.md +10 -6
  5. data/TODO.md +6 -1
  6. data/cucumber.yml +10 -6
  7. data/features/.nav +72 -0
  8. data/features/announce.feature +203 -0
  9. data/features/api/command/extract_text.feature +10 -0
  10. data/features/api/command/run.feature +6 -6
  11. data/features/api/command/stop_all_commands.feature +53 -0
  12. data/features/api/command/terminate_all_commands.feature +53 -0
  13. data/features/api/command/unescape_text.feature +12 -0
  14. data/features/api/command/which.feature +3 -3
  15. data/features/api/core/expand_path.feature +4 -4
  16. data/features/api/environment/append_environment_variable.feature +18 -8
  17. data/features/api/environment/prepend_environment_variable.feature +18 -8
  18. data/features/api/environment/set_environment_variable.feature +33 -16
  19. data/features/api/filesystem/cd.feature +23 -13
  20. data/features/api/filesystem/create_directory.feature +2 -2
  21. data/features/api/filesystem/disk_usage.feature +7 -6
  22. data/features/api/filesystem/does_exist.feature +2 -2
  23. data/features/api/filesystem/is_absolute.feature +2 -2
  24. data/features/api/filesystem/is_directory.feature +2 -2
  25. data/features/api/filesystem/is_file.feature +2 -2
  26. data/features/api/filesystem/is_relative.feature +2 -2
  27. data/features/api/filesystem/move.feature +119 -0
  28. data/features/cli/console.feature +3 -3
  29. data/features/commands/debug_command.feature +93 -0
  30. data/features/commands/environment_variables.feature +64 -0
  31. data/features/commands/flushing.feature +74 -0
  32. data/features/commands/interactive.feature +90 -0
  33. data/features/commands/output/all_output.feature +445 -0
  34. data/features/commands/output/stdout.feature +66 -0
  35. data/features/configuration/exit_timeout.feature +5 -5
  36. data/features/configuration/fixtures_directories.feature +3 -3
  37. data/features/configuration/fixtures_path_prefix.feature +1 -1
  38. data/features/configuration/home_directory.feature +4 -4
  39. data/features/configuration/io_timeout.feature +2 -2
  40. data/features/configuration/keep_ansi.feature +2 -2
  41. data/features/configuration/log_level.feature +3 -3
  42. data/features/configuration/physical_block_size.feature +3 -3
  43. data/features/configuration/usage.feature +159 -0
  44. data/features/core/cleanup_aruba_directory.feature +52 -0
  45. data/features/development/build.feature +16 -0
  46. data/features/development/test.feature +24 -0
  47. data/features/file_system_commands.feature +12 -12
  48. data/features/getting_started/supported_programming_languages.feature +89 -0
  49. data/features/hooks/after/command.feature +1 -1
  50. data/features/hooks/before/command.feature +2 -2
  51. data/features/matchers/collection/include_an_object.feature +72 -0
  52. data/features/matchers/timeouts.feature +2 -2
  53. data/features/output.feature +60 -181
  54. data/features/step_definitions/aruba_dev_steps.rb +17 -10
  55. data/features/step_definitions/hooks.rb +11 -0
  56. data/features/steps/commands/exit_statuses.feature +3 -3
  57. data/features/steps/commands/run.feature +0 -15
  58. data/features/steps/filesystem/copy.feature +45 -0
  59. data/features/steps/filesystem/create_directory.feature +47 -0
  60. data/features/steps/filesystem/create_file.feature +53 -0
  61. data/features/steps/filesystem/file_content.feature +1 -1
  62. data/features/steps/filesystem/move.feature +45 -0
  63. data/features/steps/filesystem/overwrite_file.feature +72 -0
  64. data/features/steps/filesystem/use_fixture.feature +77 -0
  65. data/features/usage/install.feature +8 -0
  66. data/{features/fixtures → fixtures}/cli-app/.gitignore +0 -0
  67. data/{features/fixtures → fixtures}/cli-app/.rspec +0 -0
  68. data/{features/fixtures → fixtures}/cli-app/README.md +0 -0
  69. data/{features/fixtures → fixtures}/cli-app/Rakefile +0 -0
  70. data/{features/fixtures → fixtures}/cli-app/bin/cli +0 -0
  71. data/{features/fixtures → fixtures}/cli-app/cli-app.gemspec +0 -0
  72. data/{features/fixtures → fixtures}/cli-app/features/support/env.rb +0 -0
  73. data/{features/fixtures → fixtures}/cli-app/lib/cli/app.rb +0 -0
  74. data/fixtures/cli-app/lib/cli/app/suppress_simple_cov_output.rb +15 -0
  75. data/{features/fixtures → fixtures}/cli-app/lib/cli/app/version.rb +0 -0
  76. data/{features/fixtures/empty-app → fixtures/cli-app}/script/console +3 -3
  77. data/{features/fixtures → fixtures}/cli-app/spec/spec_helper.rb +0 -0
  78. data/{features/fixtures → fixtures}/cli-app/spec/support/aruba.rb +0 -0
  79. data/{features/fixtures → fixtures}/copy/file.txt +0 -0
  80. data/{features/fixtures → fixtures}/empty-app/.gitignore +0 -0
  81. data/{features/fixtures → fixtures}/empty-app/.rspec +0 -0
  82. data/{features/fixtures → fixtures}/empty-app/README.md +0 -0
  83. data/{features/fixtures → fixtures}/empty-app/Rakefile +0 -0
  84. data/{features/fixtures → fixtures}/empty-app/bin/cli +0 -0
  85. data/{features/fixtures → fixtures}/empty-app/cli-app.gemspec +0 -0
  86. data/{features/fixtures → fixtures}/empty-app/lib/cli/app.rb +0 -0
  87. data/{features/fixtures → fixtures}/empty-app/lib/cli/app/version.rb +0 -0
  88. data/{features/fixtures/cli-app → fixtures/empty-app}/script/console +3 -3
  89. data/{features/fixtures → fixtures}/empty-app/spec/spec_helper.rb +0 -0
  90. data/{features/fixtures → fixtures}/fixtures-app/test.txt +0 -0
  91. data/fixtures/getting-started-app/.gitignore +4 -0
  92. data/fixtures/getting-started-app/Gemfile +4 -0
  93. data/fixtures/getting-started-app/README.md +3 -0
  94. data/fixtures/getting-started-app/features/support/env.rb +1 -0
  95. data/{features/fixtures → fixtures}/spawn_process/stderr.sh +0 -0
  96. data/lib/aruba/announcer.rb +6 -2
  97. data/lib/aruba/api.rb +0 -16
  98. data/lib/aruba/api/command.rb +64 -266
  99. data/lib/aruba/api/core.rb +24 -26
  100. data/lib/aruba/api/deprecated.rb +370 -12
  101. data/lib/aruba/api/filesystem.rb +64 -15
  102. data/lib/aruba/aruba_path.rb +4 -0
  103. data/lib/aruba/config.rb +1 -1
  104. data/lib/aruba/cucumber.rb +5 -449
  105. data/lib/aruba/cucumber/command.rb +378 -0
  106. data/lib/aruba/cucumber/core.rb +29 -0
  107. data/lib/aruba/cucumber/environment.rb +30 -0
  108. data/lib/aruba/cucumber/file.rb +210 -0
  109. data/lib/aruba/cucumber/hooks.rb +11 -14
  110. data/lib/aruba/cucumber/rvm.rb +3 -0
  111. data/lib/aruba/matchers/base/base_matcher.rb +94 -0
  112. data/lib/aruba/matchers/collection.rb +1 -0
  113. data/lib/aruba/matchers/collection/all_objects.rb +2 -0
  114. data/lib/aruba/matchers/collection/include_an_object.rb +120 -0
  115. data/lib/aruba/matchers/command/be_successfully_executed.rb +3 -3
  116. data/lib/aruba/matchers/command/have_exit_status.rb +2 -11
  117. data/lib/aruba/matchers/command/have_finished_in_time.rb +5 -5
  118. data/lib/aruba/matchers/command/have_output.rb +46 -0
  119. data/lib/aruba/matchers/command/have_output_on_stderr.rb +42 -0
  120. data/lib/aruba/matchers/command/have_output_on_stdout.rb +42 -0
  121. data/lib/aruba/matchers/command/have_output_size.rb +28 -0
  122. data/lib/aruba/matchers/directory/be_an_existing_directory.rb +1 -1
  123. data/lib/aruba/matchers/file/be_an_existing_file.rb +1 -1
  124. data/lib/aruba/matchers/file/have_file_content.rb +1 -1
  125. data/lib/aruba/matchers/file/have_file_size.rb +2 -2
  126. data/lib/aruba/matchers/file/have_same_file_content.rb +1 -1
  127. data/lib/aruba/matchers/path/have_permissions.rb +1 -1
  128. data/lib/aruba/platforms/aruba_file_creator.rb +2 -3
  129. data/lib/aruba/platforms/aruba_fixed_size_file_creator.rb +2 -3
  130. data/lib/aruba/platforms/determine_disk_usage.rb +23 -0
  131. data/lib/aruba/platforms/determine_file_size.rb +13 -0
  132. data/lib/aruba/platforms/disk_usage_calculator.rb +11 -0
  133. data/lib/aruba/platforms/local_environment.rb +15 -0
  134. data/lib/aruba/platforms/unix_environment_variables.rb +1 -1
  135. data/lib/aruba/platforms/unix_platform.rb +35 -14
  136. data/lib/aruba/process_monitor.rb +53 -7
  137. data/lib/aruba/processes/basic_process.rb +25 -5
  138. data/lib/aruba/processes/debug_process.rb +27 -25
  139. data/lib/aruba/processes/in_process.rb +7 -22
  140. data/lib/aruba/processes/spawn_process.rb +74 -31
  141. data/lib/aruba/rspec.rb +1 -6
  142. data/lib/aruba/version.rb +1 -1
  143. data/script/console +0 -1
  144. data/spec/aruba/api/environment/restore_env_spec.rb +65 -0
  145. data/spec/aruba/api/environment/set_env_spec.rb +42 -0
  146. data/spec/aruba/api/filesystem/file_size_spec.rb +28 -0
  147. data/spec/aruba/api_spec.rb +10 -7
  148. data/spec/aruba/matchers/command/have_output_size_spec.rb +25 -0
  149. data/spec/aruba/matchers/command_spec.rb +135 -4
  150. data/spec/aruba/spawn_process_spec.rb +1 -1
  151. metadata +107 -65
  152. data/.nav +0 -12
  153. data/features/debug.feature +0 -15
  154. data/features/fixtures/cli-app/spec/cli/app_spec.rb +0 -7
  155. data/features/flushing.feature +0 -26
  156. data/features/interactive.feature +0 -66
  157. data/features/no_clobber.feature +0 -25
  158. data/lib/aruba/disk_usage_calculator.rb +0 -7
@@ -2,9 +2,6 @@ require 'aruba/platform'
2
2
 
3
3
  require 'aruba/extensions/string/strip'
4
4
 
5
- require 'aruba/platforms/aruba_file_creator'
6
- require 'aruba/platforms/aruba_fixed_size_file_creator'
7
- require 'aruba/disk_usage_calculator'
8
5
  require 'aruba/aruba_path'
9
6
 
10
7
  Aruba.platform.require_matching_files('../matchers/file/*.rb', __FILE__)
@@ -124,7 +121,7 @@ module Aruba
124
121
  # @param [String] file_content
125
122
  # The content which should be written to the file
126
123
  def write_file(name, content)
127
- Creators::ArubaFileCreator.new.write(expand_path(name), content, false)
124
+ Aruba.platform.create_file(expand_path(name), content, false)
128
125
 
129
126
  self
130
127
  end
@@ -190,6 +187,53 @@ module Aruba
190
187
  end
191
188
  # rubocop:enable Metrics/CyclomaticComplexity
192
189
 
190
+ # Move a file and/or directory
191
+ #
192
+ # @param [String, Array] source
193
+ # A single file or directory, multiple files or directories or multiple
194
+ # files and directories. If multiple sources are given the destination
195
+ # needs to be a directory
196
+ #
197
+ # @param [String] destination
198
+ # A file or directory name. If multiple sources are given the destination
199
+ # needs to be a directory
200
+ #
201
+ # rubocop:disable Metrics/CyclomaticComplexity
202
+ # rubocop:disable Metrics/MethodLength
203
+ def move(*args)
204
+ args = args.flatten
205
+ destination = args.pop
206
+ source = args
207
+
208
+ source.each do |s|
209
+ raise ArgumentError, "Using a fixture as source (#{source}) is not supported" if s.start_with? aruba.config.fixtures_path_prefix
210
+ end
211
+
212
+ raise ArgumentError, "Using a fixture as destination (#{destination}) is not supported" if destination.start_with? aruba.config.fixtures_path_prefix
213
+
214
+ source.each do |s|
215
+ raise ArgumentError, %(The following source "#{s}" does not exist.) unless exist? s
216
+ end
217
+
218
+ raise ArgumentError, "Multiple sources can only be copied to a directory" if source.count > 1 && exist?(destination) && !directory?(destination)
219
+
220
+ source_paths = source.map { |f| expand_path(f) }
221
+ destination_path = expand_path(destination)
222
+
223
+ if source_paths.count > 1
224
+ Aruba.platform.mkdir(destination_path)
225
+ else
226
+ Aruba.platform.mkdir(File.dirname(destination_path))
227
+ source_paths = source_paths.first
228
+ end
229
+
230
+ Aruba.platform.mv source_paths, destination_path
231
+
232
+ self
233
+ end
234
+ # rubocop:enable Metrics/MethodLength
235
+ # rubocop:enable Metrics/CyclomaticComplexity
236
+
193
237
  # Create a file with the given size
194
238
  #
195
239
  # The method does not check if file already exists. If the file name is a
@@ -201,7 +245,7 @@ module Aruba
201
245
  # @param [Integer] file_size
202
246
  # The size of the file
203
247
  def write_fixed_size_file(name, size)
204
- Creators::ArubaFixedSizeFileCreator.new.write(expand_path(name), size, false)
248
+ Aruba.platform.create_fixed_size_file(expand_path(name), size, false)
205
249
 
206
250
  self
207
251
  end
@@ -212,7 +256,7 @@ module Aruba
212
256
  # missing. If the file name is a path the method will create all neccessary
213
257
  # directories.
214
258
  def overwrite_file(name, content)
215
- Creators::ArubaFileCreator.new.write(expand_path(name), content, true)
259
+ Aruba.platform.create_file(expand_path(name), content, true)
216
260
 
217
261
  self
218
262
  end
@@ -298,7 +342,7 @@ module Aruba
298
342
  # @yield
299
343
  # Pass the content of the given file to this block
300
344
  def with_file_content(file, &block)
301
- stop_processes!
345
+ expect(file).to be_an_existing_path
302
346
 
303
347
  content = read(file).join("\n")
304
348
 
@@ -316,14 +360,19 @@ module Aruba
316
360
  # @result [FileSize]
317
361
  # Bytes on disk
318
362
  def disk_usage(*paths)
319
- size = paths.flatten.map do |p|
320
- DiskUsageCalculator.new.calc(
321
- ArubaPath.new(expand_path(p)).blocks,
322
- aruba.config.physical_block_size
323
- )
324
- end.inject(0, &:+)
325
-
326
- FileSize.new(size)
363
+ expect(paths.flatten).to all_objects be_an_existing_path
364
+
365
+ Aruba.platform.determine_disk_usage paths.flatten.map { |p| ArubaPath.new(expand_path(p)) }, aruba.config.physical_block_size
366
+ end
367
+
368
+ # Get size of file
369
+ #
370
+ # @return [Numeric]
371
+ # The size of the file
372
+ def file_size(name)
373
+ expect(name).to be_an_existing_file
374
+
375
+ Aruba.platform.determine_file_size expand_path(name)
327
376
  end
328
377
  end
329
378
  end
@@ -60,6 +60,10 @@ module Aruba
60
60
  def absolute?
61
61
  (%r{\A/} === to_s)
62
62
  end
63
+
64
+ def to_ary
65
+ to_a
66
+ end
63
67
  end
64
68
 
65
69
  # How many parts has the file name
@@ -30,7 +30,7 @@ module Aruba
30
30
 
31
31
  option_accessor :exit_timeout, :contract => { Num => Num }, :default => 15
32
32
  option_accessor :io_wait_timeout, :contract => { Num => Num }, :default => 0.1
33
- option_accessor :fixtures_directories, :contract => { Array => ArrayOf[String] }, :default => %w(features/fixtures spec/fixtures test/fixtures)
33
+ option_accessor :fixtures_directories, :contract => { Array => ArrayOf[String] }, :default => %w(features/fixtures spec/fixtures test/fixtures fixtures)
34
34
  option_accessor :command_runtime_environment, :contract => { Hash => Hash }, :default => ENV.to_hash.dup
35
35
  # rubocop:disable Metrics/LineLength
36
36
  option_accessor(:command_search_paths, :contract => { ArrayOf[String] => ArrayOf[String] }) { |config| [File.join(config.root_directory.value, 'bin')] }
@@ -4,453 +4,9 @@ require 'aruba/api'
4
4
  World(Aruba::Api)
5
5
 
6
6
  require 'aruba/cucumber/hooks'
7
+ require 'aruba/cucumber/command'
8
+ require 'aruba/cucumber/core'
9
+ require 'aruba/cucumber/environment'
10
+ require 'aruba/cucumber/file'
11
+ require 'aruba/cucumber/rvm'
7
12
  require 'aruba/reporting'
8
-
9
- if Aruba::VERSION >= '1.0.0'
10
- Aruba.configure do |config|
11
- config.working_directory = 'tmp/cucumber'
12
- end
13
- end
14
-
15
- Given /the default aruba timeout is (\d+) seconds/ do |seconds|
16
- aruba.config.exit_timeout = seconds.to_i
17
- end
18
-
19
- Given /I use (?:a|the) fixture(?: named)? "([^"]*)"/ do |name|
20
- copy File.join(aruba.config.fixtures_path_prefix, name), name
21
- cd name
22
- end
23
-
24
- Given /The default aruba timeout is (\d+) seconds/ do |seconds|
25
- warn(%{\e[35m The /^The default aruba timeout is (\d+) seconds/ step definition is deprecated. Please use the one with `the` and not `The` at the beginning.\e[0m})
26
- aruba.config.exit_timeout = seconds.to_i
27
- end
28
-
29
- Given /^I'm using a clean gemset "([^"]*)"$/ do |gemset|
30
- use_clean_gemset(gemset)
31
- end
32
-
33
- Given /^(?:a|the) directory(?: named)? "([^"]*)"$/ do |dir_name|
34
- create_directory(dir_name)
35
- end
36
-
37
- Given /^(?:a|the) directory(?: named)? "([^"]*)" with mode "([^"]*)"$/ do |dir_name, dir_mode|
38
- create_directory(dir_name)
39
- chmod(dir_mode, dir_name)
40
- end
41
-
42
- Given /^(?:a|the) file(?: named)? "([^"]*)" with:$/ do |file_name, file_content|
43
- write_file(file_name, file_content)
44
- end
45
-
46
- Given /^(?:a|the) file(?: named)? "([^"]*)" with mode "([^"]*)" and with:$/ do |file_name, file_mode, file_content|
47
- write_file(file_name, file_content)
48
- chmod(file_mode, file_name)
49
- end
50
-
51
- Given /^(?:a|the) (\d+) byte file(?: named)? "([^"]*)"$/ do |file_size, file_name|
52
- write_fixed_size_file(file_name, file_size.to_i)
53
- end
54
-
55
- Given /^(?:an|the) empty file(?: named)? "([^"]*)"$/ do |file_name|
56
- write_file(file_name, "")
57
- end
58
-
59
- Given /^(?:an|the) empty file(?: named)? "([^"]*)" with mode "([^"]*)"$/ do |file_name, file_mode|
60
- write_file(file_name, "")
61
- chmod(file_mode, file_name)
62
- end
63
-
64
- Given /^a mocked home directory$/ do
65
- set_environment_variable 'HOME', expand_path('.')
66
- end
67
-
68
- Given /^(?:a|the) directory(?: named)? "([^"]*)" does not exist$/ do |directory_name|
69
- remove(directory_name, :force => true)
70
- end
71
-
72
- When /^I write to "([^"]*)" with:$/ do |file_name, file_content|
73
- write_file(file_name, file_content)
74
- end
75
-
76
- When /^I overwrite "([^"]*)" with:$/ do |file_name, file_content|
77
- overwrite_file(file_name, file_content)
78
- end
79
-
80
- When /^I append to "([^"]*)" with:$/ do |file_name, file_content|
81
- append_to_file(file_name, file_content)
82
- end
83
-
84
- When /^I append to "([^"]*)" with "([^"]*)"$/ do |file_name, file_content|
85
- append_to_file(file_name, file_content)
86
- end
87
-
88
- When /^I remove (?:a|the) file(?: named)? "([^"]*)"$/ do |file_name|
89
- remove(file_name)
90
- end
91
-
92
- Given /^(?:a|the) file(?: named)? "([^"]*)" does not exist$/ do |file_name|
93
- remove(file_name, :force => true)
94
- end
95
-
96
- When(/^I remove (?:a|the) directory(?: named)? "(.*?)"$/) do |directory_name|
97
- remove(directory_name)
98
- end
99
-
100
- When /^I cd to "([^"]*)"$/ do |dir|
101
- cd(dir)
102
- end
103
-
104
- Given /^I set the environment variables to:/ do |table|
105
- table.hashes.each do |row|
106
- variable = row['variable'].to_s.upcase
107
- value = row['value'].to_s
108
-
109
- set_environment_variable(variable, value)
110
- end
111
- end
112
-
113
- Given /^I append the value to the environment variable:/ do |table|
114
- table.hashes.each do |row|
115
- variable = row['variable'].to_s.upcase
116
- value = row['value'].to_s
117
-
118
- append_environment_variable(variable, value)
119
- end
120
- end
121
-
122
- When /^I run "(.*)"$/ do |cmd|
123
- warn(%{\e[35m The /^I run "(.*)"$/ step definition is deprecated. Please use the `backticks` version\e[0m})
124
-
125
- cmd = unescape_text(cmd)
126
- cmd = extract_text(cmd) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
127
-
128
- run_simple(cmd, false)
129
- end
130
-
131
- When /^I run `([^`]*)`$/ do |cmd|
132
- cmd = unescape_text(cmd)
133
- cmd = extract_text(cmd) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
134
-
135
- run_simple(cmd, false)
136
- end
137
-
138
- When /^I successfully run "(.*)"$/ do |cmd|
139
- warn(%{\e[35m The /^I successfully run "(.*)"$/ step definition is deprecated. Please use the `backticks` version\e[0m})
140
-
141
- cmd = unescape_text(cmd)
142
- cmd = extract_text(cmd) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
143
-
144
- run_simple(cmd)
145
- end
146
-
147
- ## I successfully run `echo -n "Hello"`
148
- ## I successfully run `sleep 29` for up to 30 seconds
149
- When /^I successfully run `(.*?)`(?: for up to (\d+) seconds)?$/ do |cmd, secs|
150
- cmd = unescape_text(cmd)
151
- cmd = extract_text(cmd) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
152
-
153
- run_simple(cmd, true, secs && secs.to_i)
154
- end
155
-
156
- When /^I run "([^"]*)" interactively$/ do |cmd|
157
- warn(%{\e[35m The /^I run "([^"]*)" interactively$/ step definition is deprecated. Please use the `backticks` version\e[0m})
158
- step %(I run `#{cmd}` interactively)
159
- end
160
-
161
- When /^I run `([^`]*)` interactively$/ do |cmd|
162
- cmd = unescape_text(cmd)
163
- cmd = extract_text(cmd) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
164
-
165
- @interactive = run(cmd)
166
- end
167
-
168
- When /^I type "([^"]*)"$/ do |input|
169
- type(unescape_text(input))
170
- end
171
-
172
- When /^I close the stdin stream$/ do
173
- close_input
174
- end
175
-
176
- When /^I pipe in (?:a|the) file(?: named)? "([^"]*)"$/ do |file|
177
- pipe_in_file(file)
178
-
179
- close_input
180
- end
181
-
182
- When /^I wait for (?:output|stdout) to contain "([^"]*)"$/ do |expected|
183
- Timeout.timeout(exit_timeout) do
184
- loop do
185
- break if assert_partial_output_interactive(expected)
186
- sleep 0.1
187
- end
188
- end
189
- end
190
-
191
- Then /^the output should contain "([^"]*)"$/ do |expected|
192
- assert_partial_output(expected, all_output)
193
- end
194
-
195
- Then /^the output from "([^"]*)" should contain "([^"]*)"$/ do |cmd, expected|
196
- assert_partial_output(expected, output_from(cmd))
197
- end
198
-
199
- Then /^the output from "([^"]*)" should not contain "([^"]*)"$/ do |cmd, unexpected|
200
- assert_no_partial_output(unexpected, output_from(cmd))
201
- end
202
-
203
- Then /^the output should not contain "([^"]*)"$/ do |unexpected|
204
- assert_no_partial_output(unexpected, all_output)
205
- end
206
-
207
- Then /^the output should contain:$/ do |expected|
208
- assert_partial_output(expected, all_output)
209
- end
210
-
211
- Then /^the output should not contain:$/ do |unexpected|
212
- assert_no_partial_output(unexpected, all_output)
213
- end
214
-
215
- ## the output should contain exactly "output"
216
- ## the output from `echo -n "Hello"` should contain exactly "Hello"
217
- Then /^the output(?: from "(.*?)")? should contain exactly "(.*?)"$/ do |cmd, expected|
218
- assert_exact_output(expected, cmd ? output_from(cmd) : all_output)
219
- end
220
-
221
- ## the output should contain exactly:
222
- ## the output from `echo -n "Hello"` should contain exactly:
223
- Then /^the output(?: from "(.*?)")? should contain exactly:$/ do |cmd, expected|
224
- assert_exact_output(expected, cmd ? output_from(cmd) : all_output)
225
- end
226
-
227
- # "the output should match" allows regex in the partial_output, if
228
- # you don't need regex, use "the output should contain" instead since
229
- # that way, you don't have to escape regex characters that
230
- # appear naturally in the output
231
- Then /^the output should match \/([^\/]*)\/$/ do |expected|
232
- assert_matching_output(expected, all_output)
233
- end
234
-
235
- Then /^the output should match %r<([^>]*)>$/ do |expected|
236
- assert_matching_output(expected, all_output)
237
- end
238
-
239
- Then /^the output should match:$/ do |expected|
240
- assert_matching_output(expected, all_output)
241
- end
242
-
243
- # The previous two steps antagonists
244
- Then /^the output should not match \/([^\/]*)\/$/ do |expected|
245
- assert_not_matching_output(expected, all_output)
246
- end
247
-
248
- Then /^the output should not match:$/ do |expected|
249
- assert_not_matching_output(expected, all_output)
250
- end
251
-
252
- Then /^the exit status should be (\d+)$/ do |exit_status|
253
- assert_exit_status(exit_status.to_i)
254
- end
255
-
256
- Then /^the exit status should not be (\d+)$/ do |exit_status|
257
- assert_not_exit_status(exit_status.to_i)
258
- end
259
-
260
- Then /^it should (pass|fail) with:$/ do |pass_fail, partial_output|
261
- self.__send__("assert_#{pass_fail}ing_with", partial_output)
262
- end
263
-
264
- Then /^it should (pass|fail) with exactly:$/ do |pass_fail, exact_output|
265
- assert_exit_status_and_output(pass_fail == "pass", exact_output, true)
266
- end
267
-
268
- Then /^it should (pass|fail) with regexp?:$/ do |pass_fail, expected|
269
- assert_matching_output(expected, all_output)
270
- assert_success(pass_fail == 'pass')
271
- end
272
-
273
- ## the stderr should contain "hello"
274
- ## the stderr from "echo -n 'Hello'" should contain "hello"
275
- ## the stderr should contain exactly:
276
- ## the stderr from "echo -n 'Hello'" should contain exactly:
277
- Then /^the stderr(?: from "(.*?)")? should contain( exactly)? "(.*?)"$/ do |cmd, exact, expected|
278
- if exact
279
- assert_exact_output(expected, cmd ? stderr_from(cmd) : all_stderr)
280
- else
281
- assert_partial_output(expected, cmd ? stderr_from(cmd) : all_stderr)
282
- end
283
- end
284
-
285
- ## the stderr should contain:
286
- ## the stderr from "echo -n 'Hello'" should contain:
287
- ## the stderr should contain exactly:
288
- ## the stderr from "echo -n 'Hello'" should contain exactly:
289
- Then /^the stderr(?: from "(.*?)")? should contain( exactly)?:$/ do |cmd, exact, expected|
290
- if exact
291
- assert_exact_output(expected, cmd ? stderr_from(cmd) : all_stderr)
292
- else
293
- assert_partial_output(expected, cmd ? stderr_from(cmd) : all_stderr)
294
- end
295
- end
296
-
297
- ## the stdout should contain "hello"
298
- ## the stdout from "echo -n 'Hello'" should contain "hello"
299
- ## the stdout should contain exactly:
300
- ## the stdout from "echo -n 'Hello'" should contain exactly:
301
- Then /^the stdout(?: from "(.*?)")? should contain( exactly)? "(.*?)"$/ do |cmd, exact, expected|
302
- if exact
303
- assert_exact_output(expected, cmd ? stdout_from(cmd) : all_stdout)
304
- else
305
- assert_partial_output(expected, cmd ? stdout_from(cmd) : all_stdout)
306
- end
307
- end
308
-
309
- ## the stdout should contain:
310
- ## the stdout from "echo -n 'Hello'" should contain:
311
- ## the stdout should contain exactly:
312
- ## the stdout from "echo -n 'Hello'" should contain exactly:
313
- Then /^the stdout(?: from "(.*?)")? should contain( exactly)?:$/ do |cmd, exact, expected|
314
- if exact
315
- assert_exact_output(expected, cmd ? stdout_from(cmd) : all_stdout)
316
- else
317
- assert_partial_output(expected, cmd ? stdout_from(cmd) : all_stdout)
318
- end
319
- end
320
-
321
- Then /^the stderr should not contain "([^"]*)"$/ do |unexpected|
322
- assert_no_partial_output(unexpected, all_stderr)
323
- end
324
-
325
- Then /^the stderr should not contain:$/ do |unexpected|
326
- assert_no_partial_output(unexpected, all_stderr)
327
- end
328
-
329
- Then /^the (stderr|stdout) should not contain anything$/ do |stream_name|
330
- stream = self.send("all_#{stream_name}")
331
- expect(stream).to be_empty
332
- end
333
-
334
- Then /^the stdout should not contain "([^"]*)"$/ do |unexpected|
335
- assert_no_partial_output(unexpected, all_stdout)
336
- end
337
-
338
- Then /^the stdout should not contain:$/ do |unexpected|
339
- assert_no_partial_output(unexpected, all_stdout)
340
- end
341
-
342
- Then /^the stdout from "([^"]*)" should not contain "([^"]*)"$/ do |cmd, unexpected|
343
- assert_no_partial_output(unexpected, stdout_from(cmd))
344
- end
345
-
346
- Then /^the stderr from "([^"]*)" should not contain "([^"]*)"$/ do |cmd, unexpected|
347
- assert_no_partial_output(unexpected, stderr_from(cmd))
348
- end
349
-
350
- Then /^the following files should (not )?exist:$/ do |negated, files|
351
- files = files.rows.flatten
352
-
353
- if negated
354
- expect(files).not_to include an_existing_file
355
- else
356
- expect(files).to all be_an_existing_file
357
- end
358
- end
359
-
360
- Then /^(?:a|the) file(?: named)? "([^"]*)" should (not )?exist$/ do |file, expect_match|
361
- if expect_match
362
- expect(file).not_to be_an_existing_file
363
- else
364
- expect(file).to be_an_existing_file
365
- end
366
- end
367
-
368
- Then /^(?:a|the) file matching %r<(.*?)> should (not )?exist$/ do |pattern, expect_match|
369
- if expect_match
370
- expect(all_paths).not_to include match Regexp.new(pattern)
371
- else
372
- expect(all_paths).to include match Regexp.new(pattern)
373
- end
374
- end
375
-
376
- Then /^(?:a|the) (\d+) byte file(?: named)? "([^"]*)" should (not )?exist$/ do |size, file, negated|
377
- if negated
378
- expect(file).not_to have_file_size(size)
379
- else
380
- expect(file).to have_file_size(size)
381
- end
382
- end
383
-
384
- Then /^the following directories should (not )?exist:$/ do |negated, directories|
385
- directories = directories.rows.flatten
386
-
387
- if negated
388
- expect(directories).not_to include an_existing_directory
389
- else
390
- expect(directories).to all be_an_existing_directory
391
- end
392
- end
393
-
394
- Then /^(?:a|the) directory(?: named)? "([^"]*)" should (not )?exist$/ do |directory, negated|
395
- if negated
396
- expect(directory).not_to be_an_existing_directory
397
- else
398
- expect(directory).to be_an_existing_directory
399
- end
400
- end
401
-
402
- Then /^(?:a|the) file "([^"]*)" should (not )?contain "([^"]*)"$/ do |file, negated, content|
403
- if negated
404
- expect(file).not_to have_file_content Regexp.new(Regexp.escape(content))
405
- else
406
- expect(file).to have_file_content Regexp.new(Regexp.escape(content))
407
- end
408
- end
409
-
410
- Then /^(?:a|the) file "([^"]*)" should (not )?contain:$/ do |file, negated, content|
411
- if negated
412
- expect(file).not_to have_file_content Regexp.new(Regexp.escape(content.chomp))
413
- else
414
- expect(file).to have_file_content Regexp.new(Regexp.escape(content.chomp))
415
- end
416
- end
417
-
418
- Then /^(?:a|the) file "([^"]*)" should (not )?contain exactly:$/ do |file, negated, content|
419
- if negated
420
- expect(file).not_to have_file_content content
421
- else
422
- expect(file).to have_file_content content
423
- end
424
- end
425
-
426
- Then /^(?:a|the) file "([^"]*)" should (not )?match %r<([^\/]*)>$/ do |file, negated, content|
427
- if negated
428
- expect(file).not_to have_file_content Regexp.new(content)
429
- else
430
- expect(file).to have_file_content Regexp.new(content)
431
- end
432
- end
433
-
434
- Then /^(?:a|the) file "([^"]*)" should (not )?match \/([^\/]*)\/$/ do |file, negated, content|
435
- if negated
436
- expect(file).not_to have_file_content Regexp.new(content)
437
- else
438
- expect(file).to have_file_content Regexp.new(content)
439
- end
440
- end
441
-
442
- Then /^(?:a|the) file "([^"]*)" should (not )?be equal to file "([^"]*)"/ do |file, negated, reference_file|
443
- if negated
444
- expect(file).not_to have_same_file_content_like(reference_file)
445
- else
446
- expect(file).to have_same_file_content_like(reference_file)
447
- end
448
- end
449
-
450
- Then /^the mode of filesystem object "([^"]*)" should (not )?match "([^"]*)"$/ do |file, negated, permissions|
451
- if negated
452
- expect(file).not_to have_permissions(permissions)
453
- else
454
- expect(file).to have_permissions(permissions)
455
- end
456
- end