aruba 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7f0ef8ad9b9057dd75bbeb89727f93f569c84a63
4
- data.tar.gz: d81765e3e79d77b131ab9385eab81acb329117fd
3
+ metadata.gz: abc9ad9b84fa8e51541f65c4fd9182308fa90b4b
4
+ data.tar.gz: 8c9a74b73102f29b11a0bb3fbc3652f52bd84492
5
5
  SHA512:
6
- metadata.gz: f4dd1b000f2356f5ba7f4e70a0c513aecdcfafecfdf0f15cb94703ae6ce608d858c43cf078f80c7fd8f2c91cdd800a3f11f6163e34a18389629759e9eea0af0c
7
- data.tar.gz: 583fb0214abe43ce3976b1b124646b2ce5139bb439689b4d191458b13d44e6462d935e968c4ff3c5813473e79bd74a9c08f641e6a294f45993f012b3890e1820
6
+ metadata.gz: 2f3fa2197e0e1aa64baa079883c9ea70ceb38df6fe7984f5bc973b15c8c46de8990384bf3cb674bf049c4619ff3484bac8e890a2301bd51e4c7766a48309d060
7
+ data.tar.gz: d063a1f78058c485fe09ecf31f66761e20104a6746e16baf2a9adce2ace692fa3c5a7d20d90b901c32399df33af78d2c1f1021efe6aa4f91803e67c1282387e3
data/.gitignore CHANGED
@@ -10,6 +10,9 @@ tmtags
10
10
  \#*
11
11
  .\#*
12
12
 
13
+ ## RUBYMINE
14
+ .idea
15
+
13
16
  ## VIM
14
17
  *.swp
15
18
  tags
@@ -25,3 +28,6 @@ tmp
25
28
  doc
26
29
  Gemfile.lock
27
30
  cucumber-pro.log
31
+
32
+ ## Ruby versioniser
33
+ .ruby-version
@@ -0,0 +1,3 @@
1
+ inherit_from:
2
+ - config/rubocop/include.yml
3
+ - config/rubocop/exclude.yml
@@ -1,5 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - 2.1.5
4
+ - 2.1.4
5
+ - 2.1.3
3
6
  - 2.1.2
4
7
  - 2.1.1
5
8
  - 2.1.0
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "http://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
  gemspec
3
3
 
4
4
  platforms :rbx do
data/History.md CHANGED
@@ -1,6 +1,11 @@
1
- ## [master](https://github.com/cucumber/aruba/compare/v0.6.1...master)
1
+ ## [master](https://github.com/cucumber/aruba/compare/v0.6.2...master)
2
2
 
3
- ## [master](https://github.com/cucumber/aruba/compare/v0.6.0...v0.6.1)
3
+ ## [v0.6.2](https://github.com/cucumber/aruba/compare/v0.6.1...v0.6.2)
4
+ * Fixed minor issue #223)
5
+ * Added support for ruby 2.1.3 -- 2.1.5
6
+ * Added support for comparison to a fixture file
7
+
8
+ ## [v0.6.1](https://github.com/cucumber/aruba/compare/v0.6.0...v0.6.1)
4
9
  * Added support for ruby 2.1.2
5
10
  * Added support for ~ expansion
6
11
  * Added support for with_env
data/README.md CHANGED
@@ -1,4 +1,7 @@
1
- [![Build Status](https://travis-ci.org/cucumber/aruba.png)](http://travis-ci.org/cucumber/aruba) [![Code Climate](https://codeclimate.com/github/cucumber/aruba.png)](https://codeclimate.com/github/cucumber/aruba)
1
+ [![Build Status](https://travis-ci.org/cucumber/aruba.png)](http://travis-ci.org/cucumber/aruba)
2
+ [![Gem Version](https://badge.fury.io/rb/aruba.svg)](http://badge.fury.io/rb/aruba)
3
+ [![Dependency Status](https://gemnasium.com/cucumber/aruba.png)](https://gemnasium.com/cucumber/aruba.png)
4
+ [![Code Climate](https://codeclimate.com/github/cucumber/aruba.png)](https://codeclimate.com/github/cucumber/aruba)
2
5
 
3
6
  Aruba is Cucumber extension for testing command line applications written in any programming language. Features at a glance:
4
7
 
@@ -32,21 +35,29 @@ well. One might want to use it together with `rspec`.
32
35
  1. Create a directory named `spec/support`
33
36
  2. Create a file named `spec/support/aruba.rb` with:
34
37
 
35
- ```
36
- require 'aruba/api
37
- require 'aruba/reporting'
38
+ ```
39
+ require 'aruba/api'
40
+ require 'aruba/reporting'
38
41
 
39
- RSpec.configure do |c|
40
- c.include Aruba::Api
41
- c.after(:each) do
42
- restore_env
43
- end
42
+ RSpec.configure do |config|
43
+ config.include Aruba::Api
44
+
45
+ config.before(:each) do
46
+ restore_env
47
+ clean_current_dir
44
48
  end
45
- ```
49
+ end
50
+ ```
51
+ 3. Add the following to your `spec/spec_helper.rb`
52
+
53
+ ```
54
+ Dir.glob(::File.expand_path('../support/*.rb', __FILE__)).each { |f| require_relative f }
55
+ ```
56
+
46
57
 
47
58
  ## API
48
59
 
49
- `aruba` provides a wonderfull api to be used in your tests:
60
+ `aruba` provides a wonderful API to be used in your tests:
50
61
 
51
62
  * Creating files/directories
52
63
  * Deleting files/directories
@@ -54,7 +65,7 @@ well. One might want to use it together with `rspec`.
54
65
  * Checking file existence/absence
55
66
  * ...
56
67
 
57
- A full documentation of the api can be found [here](http://www.rubydoc.info/github/cucumber/aruba/master/frames).
68
+ A full documentation of the API can be found [here](http://www.rubydoc.info/github/cucumber/aruba/master/frames).
58
69
 
59
70
  ## Configuration
60
71
 
@@ -73,7 +84,7 @@ end
73
84
 
74
85
  ### Modify the PATH
75
86
 
76
- Aruba will automatically add the `bin` directory of your project to the `PATH` environment variable for
87
+ Aruba will automatically add the `bin` directory of your project to the `PATH` environment variable for
77
88
  the duration of each Cucumber scenario. So if you're developing a Ruby gem with a binary command, you
78
89
  can test those commands as though the gem were already installed.
79
90
 
@@ -83,7 +94,7 @@ If you need other directories to be added to the `PATH`, you can put the followi
83
94
 
84
95
  ### Increasing timeouts
85
96
 
86
- A process sometimes takes longer than expected to terminate, and Aruba will kill them off (and fail your scenario) if it is still alive after 3 seconds. If you need more time you can modify the timeout by assigning a different value to `@aruba_timeout_seconds` in a `Before` block:
97
+ A process sometimes takes longer than expected to terminate, and Aruba will kill them off (and fail your scenario) if it is still alive after 3 seconds. If you need more time you can modify the timeout by assigning a different value to `@aruba_timeout_seconds` in a `Before` block:
87
98
 
88
99
  ```ruby
89
100
  Before do
@@ -262,7 +273,7 @@ Scenario: Make tea
262
273
  ## Making tea
263
274
  * Get a pot
264
275
  * And some hot water
265
-
276
+
266
277
  Given...
267
278
  ```
268
279
 
data/Rakefile CHANGED
@@ -23,7 +23,10 @@ RSpec::Core::RakeTask.new do |spec|
23
23
  spec.rspec_opts = ['--color', '--format documentation']
24
24
  end
25
25
 
26
+ require 'rubocop/rake_task'
27
+ RuboCop::RakeTask.new
28
+
26
29
  desc "Run tests, both RSpec and Cucumber"
27
- task :test => [:spec, :cucumber, :cucumber_wip]
30
+ task :test => [ :rubocop, :spec, :cucumber, :cucumber_wip]
28
31
 
29
32
  task :default => :test
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'aruba'
5
- s.version = '0.6.1'
5
+ s.version = '0.6.2'
6
6
  s.authors = ["Aslak Hellesøy", "David Chelimsky", "Mike Sassak", "Matt Wynne"]
7
7
  s.description = 'CLI Steps for Cucumber, hand-crafted for you in Aruba'
8
8
  s.summary = "aruba-#{s.version}"
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.add_development_dependency 'rspec', '>= 3.0.0'
20
20
  s.add_development_dependency 'fuubar', '>= 1.1.1'
21
21
  s.add_development_dependency 'cucumber-pro', '~> 0.0'
22
+ s.add_development_dependency 'rubocop', '~> 0.26.0'
22
23
 
23
24
  s.rubygems_version = ">= 1.6.1"
24
25
  s.files = `git ls-files`.split("\n")
@@ -0,0 +1,160 @@
1
+ # Cop supports --auto-correct.
2
+ # Configuration parameters: SupportedStyles.
3
+ Style/HashSyntax:
4
+ Enabled: false
5
+
6
+ Lint/AmbiguousRegexpLiteral:
7
+ Enabled: false
8
+
9
+ # Cop supports --auto-correct.
10
+ Lint/RescueException:
11
+ Enabled: false
12
+
13
+ # Cop supports --auto-correct.
14
+ Lint/UnusedBlockArgument:
15
+ Enabled: false
16
+
17
+ # Cop supports --auto-correct.
18
+ Lint/UnusedMethodArgument:
19
+ Enabled: false
20
+
21
+ Lint/UselessAssignment:
22
+ Enabled: false
23
+
24
+ # Configuration parameters: AllowURI.
25
+ Metrics/LineLength:
26
+ Max: 169
27
+
28
+ # Configuration parameters: CountComments.
29
+ Metrics/MethodLength:
30
+ Max: 18
31
+
32
+ # Cop supports --auto-correct.
33
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
34
+ Style/AlignParameters:
35
+ Enabled: false
36
+
37
+ # Cop supports --auto-correct.
38
+ Style/Blocks:
39
+ Enabled: false
40
+
41
+ Style/CaseEquality:
42
+ Enabled: false
43
+
44
+ # Cop supports --auto-correct.
45
+ Style/CharacterLiteral:
46
+ Enabled: false
47
+
48
+ # Cop supports --auto-correct.
49
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
50
+ Style/ClassCheck:
51
+ Enabled: false
52
+
53
+ Style/ClassVars:
54
+ Enabled: false
55
+
56
+ # Cop supports --auto-correct.
57
+ # Configuration parameters: PreferredMethods.
58
+ Style/CollectionMethods:
59
+ Enabled: false
60
+
61
+ Style/Documentation:
62
+ Enabled: false
63
+
64
+ # Cop supports --auto-correct.
65
+ Style/EmptyLinesAroundBody:
66
+ Enabled: false
67
+
68
+ # Configuration parameters: MinBodyLength.
69
+ Style/GuardClause:
70
+ Enabled: false
71
+
72
+ # Configuration parameters: MaxLineLength.
73
+ Style/IfUnlessModifier:
74
+ Enabled: false
75
+
76
+ Style/Lambda:
77
+ Enabled: false
78
+
79
+ # Cop supports --auto-correct.
80
+ Style/LeadingCommentSpace:
81
+ Enabled: false
82
+
83
+ # Cop supports --auto-correct.
84
+ # Configuration parameters: PreferredDelimiters.
85
+ Style/PercentLiteralDelimiters:
86
+ Enabled: false
87
+
88
+ # Configuration parameters: SupportedStyles.
89
+ Style/RaiseArgs:
90
+ EnforcedStyle: compact
91
+
92
+ # Cop supports --auto-correct.
93
+ Style/RedundantSelf:
94
+ Enabled: false
95
+
96
+ # Configuration parameters: MaxSlashes.
97
+ Style/RegexpLiteral:
98
+ Enabled: false
99
+
100
+ # Cop supports --auto-correct.
101
+ # Configuration parameters: AllowAsExpressionSeparator.
102
+ Style/Semicolon:
103
+ Enabled: false
104
+
105
+ # Cop supports --auto-correct.
106
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
107
+ Style/SignalException:
108
+ Enabled: false
109
+
110
+ # Configuration parameters: Methods.
111
+ Style/SingleLineBlockParams:
112
+ Enabled: false
113
+
114
+ # Cop supports --auto-correct.
115
+ Style/SingleSpaceBeforeFirstArg:
116
+ Enabled: false
117
+
118
+ # Cop supports --auto-correct.
119
+ Style/SpaceAfterComma:
120
+ Enabled: false
121
+
122
+ # Cop supports --auto-correct.
123
+ Style/SpaceAfterControlKeyword:
124
+ Enabled: false
125
+
126
+ # Cop supports --auto-correct.
127
+ Style/SpaceAfterNot:
128
+ Enabled: false
129
+
130
+ # Cop supports --auto-correct.
131
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
132
+ Style/SpaceBeforeBlockBraces:
133
+ Enabled: false
134
+
135
+ # Cop supports --auto-correct.
136
+ Style/SpaceBeforeComma:
137
+ Enabled: false
138
+
139
+ # Cop supports --auto-correct.
140
+ # Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
141
+ Style/SpaceInsideBlockBraces:
142
+ Enabled: false
143
+
144
+ # Cop supports --auto-correct.
145
+ Style/SpaceInsideBrackets:
146
+ Enabled: false
147
+
148
+ # Cop supports --auto-correct.
149
+ Style/SpaceInsideParens:
150
+ Enabled: false
151
+
152
+ # Cop supports --auto-correct.
153
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
154
+ Style/StringLiterals:
155
+ Enabled: false
156
+
157
+ # Cop supports --auto-correct.
158
+ # Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, Whitelist.
159
+ Style/TrivialAccessors:
160
+ Enabled: false
File without changes
@@ -3,12 +3,12 @@ Feature: file system commands
3
3
  In order to specify commands that load files
4
4
  As a developer using Cucumber
5
5
  I want to create temporary files
6
-
6
+
7
7
  Scenario: create a dir
8
8
  Given a directory named "foo/bar"
9
9
  When I run `file foo/bar`
10
10
  Then the stdout should contain "foo/bar: directory"
11
-
11
+
12
12
  Scenario: create a file
13
13
  Given a file named "foo/bar/example.txt" with:
14
14
  """
@@ -33,12 +33,12 @@ Feature: file system commands
33
33
  Given a file named "foo/bar/example.txt" with:
34
34
  """
35
35
  hello world
36
-
36
+
37
37
  """
38
38
  When I append to "foo/bar/example.txt" with:
39
39
  """
40
40
  this was appended
41
-
41
+
42
42
  """
43
43
  When I run `cat foo/bar/example.txt`
44
44
  Then the stdout should contain "hello world"
@@ -51,12 +51,12 @@ Feature: file system commands
51
51
 
52
52
  Scenario: clean up files generated in previous scenario
53
53
  Then the file "foo/bar/example.txt" should not exist
54
-
54
+
55
55
  Scenario: change to a subdir
56
56
  Given a file named "foo/bar/example.txt" with:
57
57
  """
58
58
  hello world
59
-
59
+
60
60
  """
61
61
  When I cd to "foo/bar"
62
62
  And I run `cat example.txt`
@@ -128,7 +128,7 @@ Feature: file system commands
128
128
  Then a directory named "foo/bar" should not exist
129
129
  """
130
130
 
131
- Scenario: Check file contents
131
+ Scenario: Check file contents with text
132
132
  Given a file named "foo" with:
133
133
  """
134
134
  hello world
@@ -158,6 +158,22 @@ Feature: file system commands
158
158
  baz
159
159
  """
160
160
 
161
+ Scenario: Check file contents with another file
162
+ Given a file named "foo" with:
163
+ """
164
+ hello world
165
+ """
166
+ And a file named "bar" with:
167
+ """
168
+ hello world
169
+ """
170
+ And a file named "nonbar" with:
171
+ """
172
+ hello another world
173
+ """
174
+ Then the file "foo" should be equal to file "bar"
175
+ And the file "foo" should not be equal to file "nonbar"
176
+
161
177
  Scenario: Remove file
162
178
  Given a file named "foo" with:
163
179
  """
@@ -10,7 +10,7 @@ class CustomMain
10
10
  end
11
11
 
12
12
  def execute!
13
- @stdout.puts(@argv.map{|arg| arg.reverse}.join(' '))
13
+ @stdout.puts(@argv.map(&:reverse).join(' '))
14
14
  end
15
15
  end
16
16
 
@@ -21,4 +21,4 @@ end
21
21
 
22
22
  After('~@in-process') do
23
23
  Aruba.process = Aruba::SpawnProcess
24
- end
24
+ end
@@ -2,4 +2,3 @@ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
2
2
  require 'aruba/cucumber'
3
3
  require 'fileutils'
4
4
  require 'rspec/expectations'
5
-
@@ -1,5 +1,5 @@
1
1
  if RUBY_PLATFORM == 'java'
2
2
  Before do
3
- @aruba_timeout_seconds = 10
3
+ @aruba_timeout_seconds = 15
4
4
  end
5
5
  end
@@ -10,6 +10,33 @@ module Aruba
10
10
  module Api
11
11
  include RSpec::Matchers
12
12
 
13
+ # Expand file name
14
+ #
15
+ # @param [String] file_name
16
+ # Name of file
17
+ #
18
+ # @return [String]
19
+ # The full path
20
+ #
21
+ # @example Single file name
22
+ #
23
+ # # => <path>/tmp/aruba/file
24
+ # absolute_path('file')
25
+ #
26
+ # @example Single Dot
27
+ #
28
+ # # => <path>/tmp/aruba
29
+ # absolute_path('.')
30
+ #
31
+ # @example Join and Expand path
32
+ #
33
+ # # => <path>/tmp/aruba/path/file
34
+ # absolute_path('path', 'file')
35
+ #
36
+ def absolute_path(*args)
37
+ in_current_dir { File.expand_path File.join(*args) }
38
+ end
39
+
13
40
  # Execute block in current directory
14
41
  #
15
42
  # @yield
@@ -48,7 +75,7 @@ module Aruba
48
75
  # @return [Array]
49
76
  # The directory path: Each subdirectory is a member of an array
50
77
  def dirs
51
- @dirs ||= ['tmp', 'aruba']
78
+ @dirs ||= %w(tmp aruba)
52
79
  end
53
80
 
54
81
  # Create a file with given content
@@ -65,6 +92,21 @@ module Aruba
65
92
  _create_file(file_name, file_content, false)
66
93
  end
67
94
 
95
+ # Create an empty file
96
+ #
97
+ # @param [String] file_name
98
+ # The name of the file
99
+ def touch_file(file_name)
100
+ in_current_dir do
101
+ file_name = File.expand_path(file_name)
102
+ _mkdir(File.dirname(file_name))
103
+
104
+ FileUtils.touch file_name
105
+ end
106
+
107
+ self
108
+ end
109
+
68
110
  # Create a file with the given size
69
111
  #
70
112
  # The method does not check if file already exists. If the file name is a
@@ -88,6 +130,7 @@ module Aruba
88
130
  _create_file(file_name, file_content, true)
89
131
  end
90
132
 
133
+ # @private
91
134
  def _create_file(file_name, file_content, check_presence)
92
135
  in_current_dir do
93
136
  file_name = File.expand_path(file_name)
@@ -97,6 +140,8 @@ module Aruba
97
140
  _mkdir(File.dirname(file_name))
98
141
  File.open(file_name, 'w') { |f| f << file_content }
99
142
  end
143
+
144
+ self
100
145
  end
101
146
 
102
147
  # Change file system permissions of file
@@ -119,6 +164,8 @@ module Aruba
119
164
  end
120
165
  end
121
166
 
167
+ # @private
168
+ # @deprecated
122
169
  def chmod(*args, &block)
123
170
  warn('The use of "chmod" is deprecated. Use "filesystem_permissions" instead')
124
171
 
@@ -154,12 +201,15 @@ module Aruba
154
201
  end
155
202
  end
156
203
 
204
+ # @private
205
+ # @deprecated
157
206
  def mod?(*args, &block)
158
207
  warn('The use of "mod?" is deprecated. Use "check_filesystem_permissions" instead')
159
208
 
160
209
  check_filesystem_permissions(*args, &block)
161
210
  end
162
211
 
212
+ # @private
163
213
  def _create_fixed_size_file(file_name, file_size, check_presence)
164
214
  in_current_dir do
165
215
  file_name = File.expand_path(file_name)
@@ -206,6 +256,8 @@ module Aruba
206
256
  in_current_dir do
207
257
  _mkdir(directory_name)
208
258
  end
259
+
260
+ self
209
261
  end
210
262
 
211
263
  # Remove directory
@@ -227,9 +279,9 @@ module Aruba
227
279
  #
228
280
  # @param [true,false] expect_presence
229
281
  # Should the given paths be present (true) or absent (false)
230
- def check_file_presence(paths, expect_presence)
282
+ def check_file_presence(paths, expect_presence = true)
231
283
  prep_for_fs_check do
232
- paths.each do |path|
284
+ Array(paths).each do |path|
233
285
  if path.kind_of? Regexp
234
286
  if expect_presence
235
287
  expect(Dir.glob('**/*')).to include_regexp(path)
@@ -310,34 +362,57 @@ module Aruba
310
362
  # @param [String] file
311
363
  # The file to be checked
312
364
  #
313
- # @param [String] partial_content
314
- # The content which must/must not be in the file
365
+ # @param [String, Regexp] content
366
+ # The content which must/must not be in the file. If content is
367
+ # a String exact match is done, if content is a Regexp then file
368
+ # is matched using regular expression
315
369
  #
316
370
  # @param [true, false] expect_match
317
371
  # Must the content be in the file or not
318
- def check_file_content(file, partial_content, expect_match)
319
- regexp = regexp(partial_content)
372
+ def check_file_content(file, content, expect_match = true)
373
+ match_content =
374
+ if(Regexp === content)
375
+ match(content)
376
+ else
377
+ eq(content)
378
+ end
320
379
  prep_for_fs_check do
321
- file = File.expand_path(file)
322
- content = IO.read(file)
323
-
380
+ content = IO.read(File.expand_path(file))
324
381
  if expect_match
325
- expect(content).to match regexp
382
+ expect(content).to match_content
326
383
  else
327
- expect(content).not_to match regexp
384
+ expect(content).not_to match_content
328
385
  end
329
386
  end
330
387
  end
331
388
 
332
- # Check if the exact content can be found in file
389
+ # @private
390
+ # @deprecated
391
+ def check_exact_file_content(file, exact_content, expect_match = true)
392
+ warn('The use of "check_exact_file_content" is deprecated. Use "#check_file_content" with a string instead.')
393
+
394
+ check_file_content(file, exact_content, expect_match)
395
+ end
396
+
397
+ # Check if the content of file against the content of a reference file
333
398
  #
334
399
  # @param [String] file
335
400
  # The file to be checked
336
401
  #
337
- # @param [String] exact_content
338
- # The content of the file
339
- def check_exact_file_content(file, exact_content)
340
- prep_for_fs_check { expect(IO.read(file)).to eq exact_content }
402
+ # @param [String] reference_file
403
+ # The reference file
404
+ #
405
+ # @param [true, false] expect_match
406
+ # Must the content be in the file or not
407
+ def check_binary_file_content(file, reference_file, expect_match = true)
408
+ prep_for_fs_check do
409
+ identical = FileUtils.compare_file(file, reference_file)
410
+ if expect_match
411
+ expect(identical).to be(true), "The file \"#{file}\" differs from file \"#{reference_file}\""
412
+ else
413
+ expect(identical).not_to be(true), "The file \"#{file}\" is identical to file \"#{reference_file}\""
414
+ end
415
+ end
341
416
  end
342
417
 
343
418
  # Check presence of a directory
@@ -361,17 +436,20 @@ module Aruba
361
436
  end
362
437
  end
363
438
 
439
+ # @private
364
440
  def prep_for_fs_check(&block)
365
441
  stop_processes!
366
442
  in_current_dir{ block.call }
367
443
  end
368
444
 
445
+ # @private
369
446
  def _mkdir(dir_name)
370
447
  dir_name = File.expand_path(dir_name)
371
448
 
372
449
  FileUtils.mkdir_p(dir_name) unless File.directory?(dir_name)
373
450
  end
374
451
 
452
+ # @private
375
453
  def _rm_rf(dir_name)
376
454
  dir_name = File.expand_path(dir_name)
377
455
 
@@ -391,10 +469,6 @@ module Aruba
391
469
  string
392
470
  end
393
471
 
394
- def regexp(string_or_regexp)
395
- Regexp === string_or_regexp ? string_or_regexp : Regexp.compile(Regexp.escape(string_or_regexp))
396
- end
397
-
398
472
  # Fetch output (stdout, stderr) from command
399
473
  #
400
474
  # @param [String] cmd
@@ -422,40 +496,72 @@ module Aruba
422
496
  get_process(cmd).stderr
423
497
  end
424
498
 
499
+ # Get stdout of all processes
500
+ #
501
+ # @return [String]
502
+ # The stdout of all process which have run before
425
503
  def all_stdout
426
504
  stop_processes!
427
505
  only_processes.inject("") { |out, ps| out << ps.stdout }
428
506
  end
429
507
 
508
+ # Get stderr of all processes
509
+ #
510
+ # @return [String]
511
+ # The stderr of all process which have run before
430
512
  def all_stderr
431
513
  stop_processes!
432
514
  only_processes.inject("") { |out, ps| out << ps.stderr }
433
515
  end
434
516
 
517
+ # Get stderr and stdout of all processes
518
+ #
519
+ # @return [String]
520
+ # The stderr and stdout of all process which have run before
435
521
  def all_output
436
522
  all_stdout << all_stderr
437
523
  end
438
524
 
525
+ # Full compare arg1 and arg2
526
+ #
527
+ # @return [TrueClass, FalseClass]
528
+ # If arg1 is exactly the same as arg2 return true, otherwise false
439
529
  def assert_exact_output(expected, actual)
440
530
  actual.force_encoding(expected.encoding) if RUBY_VERSION >= "1.9"
441
531
  expect(unescape(actual)).to eq unescape(expected)
442
532
  end
443
533
 
534
+ # Partial compare arg1 and arg2
535
+ #
536
+ # @return [TrueClass, FalseClass]
537
+ # If arg2 contains arg1 return true, otherwise false
444
538
  def assert_partial_output(expected, actual)
445
539
  actual.force_encoding(expected.encoding) if RUBY_VERSION >= "1.9"
446
540
  expect(unescape(actual)).to include(unescape(expected))
447
541
  end
448
542
 
543
+ # Regex Compare arg1 and arg2
544
+ #
545
+ # @return [TrueClass, FalseClass]
546
+ # If arg2 matches arg1 return true, otherwise false
449
547
  def assert_matching_output(expected, actual)
450
548
  actual.force_encoding(expected.encoding) if RUBY_VERSION >= "1.9"
451
549
  expect(unescape(actual)).to match /#{unescape(expected)}/m
452
550
  end
453
551
 
552
+ # Negative regex compare arg1 and arg2
553
+ #
554
+ # @return [TrueClass, FalseClass]
555
+ # If arg2 does not match arg1 return true, otherwise false
454
556
  def assert_not_matching_output(expected, actual)
455
557
  actual.force_encoding(expected.encoding) if RUBY_VERSION >= "1.9"
456
- expect(unescape(actual)).not_to match /#{unescape(expected)}/m
558
+ expect(unescape(actual)).not_to match(/#{unescape(expected)}/m)
457
559
  end
458
560
 
561
+ # Negative partial compare arg1 and arg2
562
+ #
563
+ # @return [TrueClass, FalseClass]
564
+ # If arg2 does not match/include arg1 return true, otherwise false
459
565
  def assert_no_partial_output(unexpected, actual)
460
566
  actual.force_encoding(unexpected.encoding) if RUBY_VERSION >= "1.9"
461
567
  if Regexp === unexpected
@@ -465,24 +571,44 @@ module Aruba
465
571
  end
466
572
  end
467
573
 
574
+ # Partial compare output of interactive command and arg1
575
+ #
576
+ # @return [TrueClass, FalseClass]
577
+ # If output of interactive command includes arg1 return true, otherwise false
468
578
  def assert_partial_output_interactive(expected)
469
579
  unescape(_read_interactive).include?(unescape(expected)) ? true : false
470
580
  end
471
581
 
582
+ # Check if command succeeded and if arg1 is included in output
583
+ #
584
+ # @return [TrueClass, FalseClass]
585
+ # If exit status is 0 and arg1 is included in output return true, otherwise false
472
586
  def assert_passing_with(expected)
473
- assert_exit_status_and_partial_output(true, expected)
587
+ assert_success(true)
588
+ assert_partial_output(expected, all_output)
474
589
  end
475
590
 
591
+ # Check if command failed and if arg1 is included in output
592
+ #
593
+ # @return [TrueClass, FalseClass]
594
+ # If exit status is not equal 0 and arg1 is included in output return true, otherwise false
476
595
  def assert_failing_with(expected)
477
- assert_exit_status_and_partial_output(false, expected)
596
+ assert_success(false)
597
+ assert_partial_output(expected, all_output)
478
598
  end
479
599
 
600
+ # @private
601
+ # @deprecated
480
602
  def assert_exit_status_and_partial_output(expect_to_pass, expected)
603
+ warn('The use of "assert_exit_status_and_partial_output" is deprecated. Use "#assert_access" and "#assert_partial_output" instead.')
604
+
481
605
  assert_success(expect_to_pass)
482
606
  assert_partial_output(expected, all_output)
483
607
  end
484
608
 
485
609
  # TODO: Remove this. Call more methods elsewhere instead. Reveals more intent.
610
+ # @private
611
+ # @deprecated
486
612
  def assert_exit_status_and_output(expect_to_pass, expected_output, expect_exact_output)
487
613
  assert_success(expect_to_pass)
488
614
  if expect_exact_output
@@ -492,34 +618,45 @@ module Aruba
492
618
  end
493
619
  end
494
620
 
621
+ # Check exit status of process
622
+ #
623
+ # @return [TrueClass, FalseClass]
624
+ # If arg1 is true, return true if command was successful
625
+ # If arg1 is false, return true if command failed
495
626
  def assert_success(success)
496
627
  success ? assert_exit_status(0) : assert_not_exit_status(0)
497
628
  end
498
629
 
630
+ # @private
499
631
  def assert_exit_status(status)
500
632
  expect(last_exit_status).to eq(status),
501
633
  append_output_to("Exit status was #{last_exit_status} but expected it to be #{status}.")
502
634
  end
503
635
 
636
+ # @private
504
637
  def assert_not_exit_status(status)
505
638
  expect(last_exit_status).not_to eq(status),
506
639
  append_output_to("Exit status was #{last_exit_status} which was not expected.")
507
640
  end
508
641
 
642
+ # @private
509
643
  def append_output_to(message)
510
644
  "#{message} Output:\n\n#{all_output}\n"
511
645
  end
512
646
 
647
+ # @private
513
648
  def processes
514
649
  @processes ||= []
515
650
  end
516
651
 
652
+ # @private
517
653
  def stop_processes!
518
654
  processes.each do |_, process|
519
655
  stop_process(process)
520
656
  end
521
657
  end
522
658
 
659
+ # Terminate all running processes
523
660
  def terminate_processes!
524
661
  processes.each do |_, process|
525
662
  terminate_process(process)
@@ -527,16 +664,19 @@ module Aruba
527
664
  end
528
665
  end
529
666
 
667
+ # @private
530
668
  def register_process(name, process)
531
669
  processes << [name, process]
532
670
  end
533
671
 
672
+ # @private
534
673
  def get_process(wanted)
535
674
  matching_processes = processes.reverse.find{ |name, _| name == wanted }
536
675
  raise ArgumentError.new("No process named '#{wanted}' has been started") unless matching_processes
537
676
  matching_processes.last
538
677
  end
539
678
 
679
+ # @private
540
680
  def only_processes
541
681
  processes.collect{ |_, process| process }
542
682
  end
@@ -571,17 +711,38 @@ module Aruba
571
711
 
572
712
  DEFAULT_TIMEOUT_SECONDS = 3
573
713
 
714
+ # Default exit timeout for running commands with aruba
715
+ #
716
+ # Overwrite this method if you want a different timeout or set
717
+ # `@aruba_timeout_seconds`.
574
718
  def exit_timeout
575
719
  @aruba_timeout_seconds || DEFAULT_TIMEOUT_SECONDS
576
720
  end
577
721
 
578
722
  DEFAULT_IO_WAIT_SECONDS = 0.1
579
723
 
724
+ # Default io wait timeout
725
+ #
726
+ # Overwrite this method if you want a different timeout or set
727
+ # `@aruba_io_wait_seconds
580
728
  def io_wait
581
729
  @aruba_io_wait_seconds || DEFAULT_IO_WAIT_SECONDS
582
730
  end
583
731
 
584
- def run_simple(cmd, fail_on_error=true, timeout = nil)
732
+ # Run a command with aruba
733
+ #
734
+ # Checks for error during command execution and checks the output to detect
735
+ # an timeout error.
736
+ #
737
+ # @param [String] cmd
738
+ # The command to be executed
739
+ #
740
+ # @param [TrueClass,FalseClass] fail_on_error
741
+ # Should aruba fail on error?
742
+ #
743
+ # @param [Integer] timeout
744
+ # Timeout for execution
745
+ def run_simple(cmd, fail_on_error = true, timeout = nil)
585
746
  run(cmd, timeout) do |process|
586
747
  stop_process(process)
587
748
  end
@@ -593,6 +754,8 @@ module Aruba
593
754
  #
594
755
  # @param [String] cmd
595
756
  # The command to by run
757
+ #
758
+ # @see #cmd
596
759
  def run_interactive(cmd)
597
760
  @interactive = run(cmd)
598
761
  end
@@ -611,24 +774,30 @@ module Aruba
611
774
  @interactive.stdin.close
612
775
  end
613
776
 
777
+ # @deprecated
778
+ # @private
614
779
  def eot
615
780
  warn(%{\e[35m The \"#eot\"-method is deprecated. It will be deleted with the next major version. Please use \"#close_input\"-method instead.\e[0m})
616
781
  close_input
617
782
  end
618
783
 
784
+ # @private
619
785
  def _write_interactive(input)
620
786
  @interactive.stdin.write(input)
621
787
  @interactive.stdin.flush
622
788
  end
623
789
 
790
+ # @private
624
791
  def _read_interactive
625
792
  @interactive.read_stdout
626
793
  end
627
794
 
795
+ # @private
628
796
  def _ensure_newline(str)
629
797
  str.chomp << "\n"
630
798
  end
631
799
 
800
+ # @private
632
801
  def announce_or_puts(msg)
633
802
  if(@puts)
634
803
  Kernel.puts(msg)
@@ -637,6 +806,7 @@ module Aruba
637
806
  end
638
807
  end
639
808
 
809
+ # @private
640
810
  def detect_ruby(cmd)
641
811
  if cmd =~ /^ruby\s/
642
812
  cmd.gsub(/^ruby\s/, "#{current_ruby} ")
@@ -645,14 +815,21 @@ module Aruba
645
815
  end
646
816
  end
647
817
 
818
+ # @private
648
819
  def current_ruby
649
820
  File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
650
821
  end
651
822
 
823
+ # Use a clean rvm gemset
824
+ #
825
+ # Please make sure that you've got [rvm](http://rvm.io/) installed.
826
+ #
827
+ # @param [String] gemset
828
+ # The name of the gemset to be used
652
829
  def use_clean_gemset(gemset)
653
830
  run_simple(%{rvm gemset create "#{gemset}"}, true)
654
831
  if all_stdout =~ /'#{gemset}' gemset created \((.*)\)\./
655
- gem_home = $1
832
+ gem_home = Regexp.last_match[1]
656
833
  set_env('GEM_HOME', gem_home)
657
834
  set_env('GEM_PATH', gem_home)
658
835
  set_env('BUNDLE_PATH', gem_home)
@@ -667,6 +844,7 @@ module Aruba
667
844
  end
668
845
  end
669
846
 
847
+ # Unset variables used by bundler
670
848
  def unset_bundler_env_vars
671
849
  %w[RUBYOPT BUNDLE_PATH BUNDLE_BIN_PATH BUNDLE_GEMFILE].each do |key|
672
850
  set_env(key, nil)
@@ -697,20 +875,29 @@ module Aruba
697
875
  end
698
876
  end
699
877
 
878
+ # @private
700
879
  def original_env
701
880
  @original_env ||= {}
702
881
  end
703
882
 
883
+ # Run block with environment
884
+ #
885
+ # @param [Hash] env
886
+ # The variables to be used for block.
887
+ #
888
+ # @yield
889
+ # The block of code which should be run with the modified environment variables
704
890
  def with_env(env = {}, &block)
705
891
  env.each do |k,v|
706
892
  set_env k, v
707
- block.call
708
- restore_env
709
893
  end
894
+ block.call
895
+ restore_env
710
896
  end
711
897
 
712
- # TODO: move some more methods under here!
713
- private
898
+ # TODO: move some more methods under here!
899
+
900
+ private
714
901
 
715
902
  def last_exit_status
716
903
  return @last_exit_status if @last_exit_status