aruba 0.8.0.pre2 → 0.8.0.pre3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/aruba.gemspec +10 -9
- data/features/api/cd.feature +54 -0
- data/features/step_definitions/aruba_dev_steps.rb +1 -1
- data/features/steps/commands/in_process.feature +125 -32
- data/lib/aruba/api/command.rb +39 -8
- data/lib/aruba/api/core.rb +42 -6
- data/lib/aruba/api/deprecated.rb +1 -1
- data/lib/aruba/aruba_path.rb +34 -19
- data/lib/aruba/basic_configuration.rb +1 -1
- data/lib/aruba/basic_configuration/option.rb +2 -2
- data/lib/aruba/command.rb +27 -0
- data/lib/aruba/config.rb +8 -0
- data/lib/aruba/contracts/enum.rb +21 -0
- data/lib/aruba/contracts/is_a.rb +21 -0
- data/lib/aruba/cucumber.rb +4 -0
- data/lib/aruba/cucumber/hooks.rb +4 -5
- data/lib/aruba/in_process.rb +2 -1
- data/lib/aruba/matchers/command/be_successfully_executed.rb +5 -1
- data/lib/aruba/matchers/command/have_finished_in_time.rb +5 -1
- data/lib/aruba/matchers/directory/be_an_existing_directory.rb +5 -1
- data/lib/aruba/matchers/directory/have_sub_directory.rb +5 -1
- data/lib/aruba/matchers/file/be_an_existing_file.rb +5 -1
- data/lib/aruba/matchers/file/have_file_content.rb +5 -1
- data/lib/aruba/matchers/file/have_file_size.rb +5 -1
- data/lib/aruba/matchers/file/have_same_file_content.rb +5 -1
- data/lib/aruba/matchers/path/a_path_matching_pattern.rb +5 -1
- data/lib/aruba/matchers/path/be_an_absolute_path.rb +5 -1
- data/lib/aruba/matchers/path/be_an_existing_path.rb +5 -1
- data/lib/aruba/matchers/path/have_permissions.rb +5 -1
- data/lib/aruba/platform.rb +19 -1
- data/lib/aruba/processes/basic_process.rb +2 -1
- data/lib/aruba/processes/debug_process.rb +6 -13
- data/lib/aruba/processes/in_process.rb +20 -8
- data/lib/aruba/processes/spawn_process.rb +6 -1
- data/spec/aruba/api_spec.rb +1 -0
- data/spec/aruba/aruba_path_spec.rb +2 -1
- metadata +19 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c4368a692e80cba29cd8cd5d4c072883b8f0416
|
4
|
+
data.tar.gz: ee245882d6596cd1552dfb1acb5455f7d4cd9cbb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 949e77104c5fe1c9d45047f2351179816add7721326eb3a4b67701a36dec687aa38b6a3a54a7c84d163bb588b8b405704fa46322d5977df1aa57bf5ed1996658
|
7
|
+
data.tar.gz: 8aac02ac05dcd8ce10f4cb7303b146e930502e087b32b155e0f2a06ea1ee220b7bcbc82ed3cceeb2c62be57cb7de528a213e36b3f92623e6b58dadf8d551c5b8
|
data/.rubocop.yml
CHANGED
data/aruba.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'aruba'
|
5
|
-
s.version = '0.8.0.
|
5
|
+
s.version = '0.8.0.pre3'
|
6
6
|
s.authors = ["Aslak Hellesøy", "David Chelimsky", "Mike Sassak", "Matt Wynne", "Jarl Friis", "Dennis Günnewig"]
|
7
7
|
s.description = 'Extension for popular TDD and BDD frameworks like "Cucumber" and "RSpec" to make testing commandline applications meaningful, easy and fun.'
|
8
8
|
s.summary = "aruba-#{s.version}"
|
@@ -10,9 +10,9 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.email = 'cukes@googlegroups.com'
|
11
11
|
s.homepage = 'http://github.com/cucumber/aruba'
|
12
12
|
|
13
|
-
s.add_runtime_dependency 'cucumber', '
|
13
|
+
s.add_runtime_dependency 'cucumber', '~> 1.3.19'
|
14
14
|
s.add_runtime_dependency 'childprocess', '~> 0.5.6'
|
15
|
-
s.add_runtime_dependency 'rspec-expectations', '
|
15
|
+
s.add_runtime_dependency 'rspec-expectations', '>= 2.11'
|
16
16
|
s.add_runtime_dependency 'contracts', '~> 0.9'
|
17
17
|
|
18
18
|
s.add_development_dependency 'bundler', '~> 1.10.2'
|
@@ -21,14 +21,15 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.required_ruby_version = '>= 1.8.7'
|
22
22
|
s.post_install_message = <<-EOS
|
23
23
|
With aruba >= 1.0
|
24
|
-
* "ruby 1.8.7"-support is discontinued
|
25
|
-
* aruba requires "cucumber 2" for the feature steps. The rest of aruba should be usable by whatever testing framework you are using
|
26
|
-
* Overwriting methods for configuration is discontinued. You need to use `aruba.config.<variable>` or `Aruba.configure { |config| config.<variable>` instead
|
27
|
-
* "aruba/reporting" will be removed. Please use `@debug`-tag + `byebug`, `debugger`, `pry` to troubleshoot your feature tests
|
28
|
-
* Set environment variables will have only effect on `#run` and the like + `#with_environment { }
|
24
|
+
* "ruby 1.8.7"-support is discontinued.
|
25
|
+
* aruba requires "cucumber 2" for the feature steps. The rest of aruba should be usable by whatever testing framework you are using.
|
26
|
+
* Overwriting methods for configuration is discontinued. You need to use `aruba.config.<variable>` or `Aruba.configure { |config| config.<variable>` instead.
|
27
|
+
* "aruba/reporting" will be removed. Please use `@debug`-tag + `byebug`, `debugger`, `pry` to troubleshoot your feature tests.
|
28
|
+
* Set environment variables will have only effect on `#run` and the like + `#with_environment { }`.
|
29
29
|
* The process environment will be fully resetted between tests. Sharing state via ENV['VAR'] = 'shared state' between tests will not be possible anymore. Please make that obvious by using explicit steps or use the aruba API for that.
|
30
30
|
* There will be a major cleanup for command execution. There will be only `run` and `run_simple` left. `run_interactive` is replaced by `run`.
|
31
|
-
* Setting the root directory of aruba via method overwrite or configuration - this should be your project root directory where the test suite is run
|
31
|
+
* Setting the root directory of aruba via method overwrite or configuration - this should be your project root directory where the test suite is run.
|
32
|
+
* The direct use of "InProcess", "DebugProcess" and "SpawnProcess" is not supported anymore. You need to use "Command" instead. But be careful, it has a different API.
|
32
33
|
EOS
|
33
34
|
|
34
35
|
s.files = `git ls-files`.split("\n")
|
data/features/api/cd.feature
CHANGED
@@ -117,3 +117,57 @@ Feature: Change current working directory
|
|
117
117
|
"""
|
118
118
|
When I run `rspec`
|
119
119
|
Then the specs should all pass
|
120
|
+
|
121
|
+
Scenario: It changes the PWD- and OLDPWD-ENV-variable for a given block
|
122
|
+
|
123
|
+
If you need to run some code in a different directory, you can also use the
|
124
|
+
block-notation of `cd`.
|
125
|
+
|
126
|
+
Given a file named "spec/cd_spec.rb" with:
|
127
|
+
"""
|
128
|
+
require 'spec_helper'
|
129
|
+
|
130
|
+
RSpec.describe 'cd to directory', :type => :aruba do
|
131
|
+
before(:each) do
|
132
|
+
create_directory 'new_dir.d'
|
133
|
+
end
|
134
|
+
|
135
|
+
before :each do
|
136
|
+
cd('new_dir.d/') do
|
137
|
+
@pwd = ENV['PWD']
|
138
|
+
@oldpwd = ENV['OLDPWD']
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
it { expect(@pwd).to end_with 'new_dir.d' }
|
143
|
+
it { expect(@oldpwd).to end_with 'cli-app' }
|
144
|
+
end
|
145
|
+
"""
|
146
|
+
When I run `rspec`
|
147
|
+
Then the specs should all pass
|
148
|
+
|
149
|
+
Scenario: Nested cd calls
|
150
|
+
|
151
|
+
If you need to run some code in a different directory, you can also use the
|
152
|
+
block-notation of `cd`.
|
153
|
+
|
154
|
+
Given a file named "spec/cd_spec.rb" with:
|
155
|
+
"""
|
156
|
+
require 'spec_helper'
|
157
|
+
|
158
|
+
RSpec.describe 'cd to directory', :type => :aruba do
|
159
|
+
before(:each) do
|
160
|
+
create_directory 'new_dir.d/subdir.d'
|
161
|
+
end
|
162
|
+
|
163
|
+
before :each do
|
164
|
+
@pwd = cd('new_dir.d') do
|
165
|
+
cd('subdir.d') { run('pwd') }
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
it { expect(last_command.output.to_s).to include 'subdir.d' }
|
170
|
+
end
|
171
|
+
"""
|
172
|
+
When I run `rspec`
|
173
|
+
Then the specs should all pass
|
@@ -18,7 +18,7 @@ When /^I set env variable "(\w+)" to "([^"]*)"$/ do |var, value|
|
|
18
18
|
end
|
19
19
|
|
20
20
|
Then /^aruba should fail with "([^"]*)"$/ do |error_message|
|
21
|
-
expect(@aruba_exception.message).to include(unescape(error_message))
|
21
|
+
expect(@aruba_exception.message).to include(Aruba::Platform.unescape(error_message))
|
22
22
|
end
|
23
23
|
|
24
24
|
Then /^the following step should fail with Spec::Expectations::ExpectationNotMetError:$/ do |multiline_step|
|
@@ -1,4 +1,3 @@
|
|
1
|
-
@announce
|
2
1
|
Feature: Run commands in ruby process
|
3
2
|
|
4
3
|
Running a lot of scenarios where each scenario uses Aruba
|
@@ -9,6 +8,23 @@ Feature: Run commands in ruby process
|
|
9
8
|
|
10
9
|
Background:
|
11
10
|
Given I use a fixture named "cli-app"
|
11
|
+
And a file named "features/support/cli_app.rb" with:
|
12
|
+
"""
|
13
|
+
require 'cli/app/runner'
|
14
|
+
"""
|
15
|
+
And a file named "features/support/in_proccess.rb" with:
|
16
|
+
"""
|
17
|
+
require 'aruba/cucumber'
|
18
|
+
|
19
|
+
Before('@in-process') do
|
20
|
+
aruba.config.command_launcher = :in_process
|
21
|
+
aruba.config.main_class = Cli::App::Runner
|
22
|
+
end
|
23
|
+
|
24
|
+
After('@in-process') do
|
25
|
+
aruba.config.command_launcher = :spawn
|
26
|
+
end
|
27
|
+
"""
|
12
28
|
|
13
29
|
Scenario: Run custom code
|
14
30
|
Given a file named "lib/cli/app/runner.rb" with:
|
@@ -31,27 +47,9 @@ Feature: Run commands in ruby process
|
|
31
47
|
end
|
32
48
|
end
|
33
49
|
"""
|
34
|
-
And a file named "features/support/cli_app.rb" with:
|
35
|
-
"""
|
36
|
-
require 'cli/app/runner'
|
37
|
-
"""
|
38
|
-
And a file named "features/support/in_proccess.rb" with:
|
39
|
-
"""
|
40
|
-
require 'aruba/cucumber'
|
41
|
-
require 'aruba/processes/in_process'
|
42
|
-
|
43
|
-
Before('@in-process') do
|
44
|
-
Aruba.process = Aruba::Processes::InProcess
|
45
|
-
Aruba.process.main_class = Cli::App::Runner
|
46
|
-
end
|
47
|
-
|
48
|
-
After('@in-process') do
|
49
|
-
Aruba.process = Aruba::Processes::SpawnProcess
|
50
|
-
end
|
51
|
-
"""
|
52
50
|
And a file named "features/in_process.feature" with:
|
53
51
|
"""
|
54
|
-
Feature:
|
52
|
+
Feature: Run a command in process
|
55
53
|
@in-process
|
56
54
|
Scenario: Run command
|
57
55
|
When I run `reverse.rb Hello World`
|
@@ -89,11 +87,93 @@ Feature: Run commands in ruby process
|
|
89
87
|
end
|
90
88
|
end
|
91
89
|
"""
|
92
|
-
And a file named "features/
|
90
|
+
And a file named "features/in_process.feature" with:
|
93
91
|
"""
|
94
|
-
|
92
|
+
Feature: Run a command in process
|
93
|
+
@in-process
|
94
|
+
Scenario: Run command in process
|
95
|
+
When I run `reverse.rb Hello World`
|
96
|
+
Then the output should contain:
|
97
|
+
\"\"\"
|
98
|
+
olleH dlroW
|
99
|
+
\"\"\"
|
100
|
+
|
101
|
+
Scenario: Run command
|
102
|
+
When I run `cli Hello World`
|
103
|
+
Then the output should contain:
|
104
|
+
\"\"\"
|
105
|
+
Hello World
|
106
|
+
\"\"\"
|
95
107
|
"""
|
96
|
-
|
108
|
+
When I run `cucumber`
|
109
|
+
Then the features should all pass
|
110
|
+
|
111
|
+
Scenario: The current working directory is changed as well
|
112
|
+
Given a file named "lib/cli/app/runner.rb" with:
|
113
|
+
"""
|
114
|
+
module Cli
|
115
|
+
module App
|
116
|
+
class Runner
|
117
|
+
def initialize(argv, stdin, stdout, stderr, kernel)
|
118
|
+
@argv = argv
|
119
|
+
@stdin = stdin
|
120
|
+
@stdout = stdout
|
121
|
+
@stderr = stderr
|
122
|
+
@kernel = kernel
|
123
|
+
end
|
124
|
+
|
125
|
+
def execute!
|
126
|
+
@stdout.puts("PWD-ENV is " + Dir.getwd)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
"""
|
132
|
+
And a file named "features/in_process.feature" with:
|
133
|
+
"""
|
134
|
+
Feature: Run a command in process
|
135
|
+
@in-process
|
136
|
+
Scenario: Run command
|
137
|
+
When I run `pwd.rb`
|
138
|
+
Then the output should match %r<PWD-ENV.*tmp/aruba>
|
139
|
+
"""
|
140
|
+
When I run `cucumber`
|
141
|
+
Then the features should all pass
|
142
|
+
|
143
|
+
Scenario: The PWD environment is changed to current working directory
|
144
|
+
Given a file named "lib/cli/app/runner.rb" with:
|
145
|
+
"""
|
146
|
+
module Cli
|
147
|
+
module App
|
148
|
+
class Runner
|
149
|
+
def initialize(argv, stdin, stdout, stderr, kernel)
|
150
|
+
@argv = argv
|
151
|
+
@stdin = stdin
|
152
|
+
@stdout = stdout
|
153
|
+
@stderr = stderr
|
154
|
+
@kernel = kernel
|
155
|
+
end
|
156
|
+
|
157
|
+
def execute!
|
158
|
+
@stdout.puts("PWD-ENV is " + ENV['PWD'])
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
"""
|
164
|
+
And a file named "features/in_process.feature" with:
|
165
|
+
"""
|
166
|
+
Feature: Run a command in process
|
167
|
+
@in-process
|
168
|
+
Scenario: Run command
|
169
|
+
When I run `pwd.rb`
|
170
|
+
Then the output should match %r<PWD-ENV.*tmp/aruba>
|
171
|
+
"""
|
172
|
+
When I run `cucumber`
|
173
|
+
Then the features should all pass
|
174
|
+
|
175
|
+
Scenario: Set runner via "Aruba.process ="-method (deprecated)
|
176
|
+
Given a file named "features/support/in_proccess.rb" with:
|
97
177
|
"""
|
98
178
|
require 'aruba/cucumber'
|
99
179
|
require 'aruba/processes/in_process'
|
@@ -107,23 +187,36 @@ Feature: Run commands in ruby process
|
|
107
187
|
Aruba.process = Aruba::Processes::SpawnProcess
|
108
188
|
end
|
109
189
|
"""
|
190
|
+
Given a file named "lib/cli/app/runner.rb" with:
|
191
|
+
"""
|
192
|
+
module Cli
|
193
|
+
module App
|
194
|
+
class Runner
|
195
|
+
def initialize(argv, stdin, stdout, stderr, kernel)
|
196
|
+
@argv = argv
|
197
|
+
@stdin = stdin
|
198
|
+
@stdout = stdout
|
199
|
+
@stderr = stderr
|
200
|
+
@kernel = kernel
|
201
|
+
end
|
202
|
+
|
203
|
+
def execute!
|
204
|
+
@stdout.puts(@argv.map(&:reverse).join(' '))
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
"""
|
110
210
|
And a file named "features/in_process.feature" with:
|
111
211
|
"""
|
112
|
-
Feature:
|
212
|
+
Feature: Run a command in process
|
113
213
|
@in-process
|
114
|
-
Scenario: Run command
|
214
|
+
Scenario: Run command
|
115
215
|
When I run `reverse.rb Hello World`
|
116
216
|
Then the output should contain:
|
117
217
|
\"\"\"
|
118
218
|
olleH dlroW
|
119
219
|
\"\"\"
|
120
|
-
|
121
|
-
Scenario: Run command
|
122
|
-
When I run `cli Hello World`
|
123
|
-
Then the output should contain:
|
124
|
-
\"\"\"
|
125
|
-
Hello World
|
126
|
-
\"\"\"
|
127
220
|
"""
|
128
221
|
When I run `cucumber`
|
129
222
|
Then the features should all pass
|
data/lib/aruba/api/command.rb
CHANGED
@@ -2,16 +2,18 @@ require 'pathname'
|
|
2
2
|
|
3
3
|
require 'aruba/platform'
|
4
4
|
require 'aruba/process_monitor'
|
5
|
-
require 'aruba/
|
5
|
+
require 'aruba/command'
|
6
6
|
|
7
7
|
require 'win32/file' if File::ALT_SEPARATOR
|
8
8
|
|
9
9
|
module Aruba
|
10
10
|
class << self
|
11
|
+
# @deprecated
|
11
12
|
attr_accessor :process
|
12
13
|
end
|
13
14
|
|
14
|
-
|
15
|
+
# @deprecated
|
16
|
+
# self.process = Aruba::Processes::SpawnProcess
|
15
17
|
end
|
16
18
|
|
17
19
|
module Aruba
|
@@ -241,6 +243,8 @@ module Aruba
|
|
241
243
|
#
|
242
244
|
# @yield [SpawnProcess]
|
243
245
|
# Run block with process
|
246
|
+
#
|
247
|
+
# rubocop:disable Metrics/MethodLength
|
244
248
|
def run(cmd, timeout = nil)
|
245
249
|
timeout ||= exit_timeout
|
246
250
|
@commands ||= []
|
@@ -252,7 +256,33 @@ module Aruba
|
|
252
256
|
announcer.announce(:command, cmd)
|
253
257
|
announcer.announce(:timeout, 'exit', aruba.config.exit_timeout)
|
254
258
|
|
255
|
-
|
259
|
+
mode = if Aruba.process
|
260
|
+
# rubocop:disable Metrics/LineLength
|
261
|
+
Aruba::Platform.deprecated('The use of "Aruba.process = <process>" and "Aruba.process.main_class" is deprecated. Use "Aruba.configure { |config| config.command_launcher = :in_process|:debug|:spawn }" and "Aruba.configure { |config| config.main_class = <klass> }" instead.')
|
262
|
+
# rubocop:enable Metrics/LineLength
|
263
|
+
Aruba.process
|
264
|
+
else
|
265
|
+
aruba.config.command_launcher
|
266
|
+
end
|
267
|
+
|
268
|
+
main_class = if Aruba.process.respond_to?(:main_class) && Aruba.process.main_class
|
269
|
+
# rubocop:disable Metrics/LineLength
|
270
|
+
Aruba::Platform.deprecated('The use of "Aruba.process = <process>" and "Aruba.process.main_class" is deprecated. Use "Aruba.configure { |config| config.command_launcher = :in_process|:debug|:spawn }" and "Aruba.configure { |config| config.main_class = <klass> }" instead.')
|
271
|
+
# rubocop:enable Metrics/LineLength
|
272
|
+
Aruba.process.main_class
|
273
|
+
else
|
274
|
+
aruba.config.main_class
|
275
|
+
end
|
276
|
+
|
277
|
+
command = Command.new(
|
278
|
+
cmd,
|
279
|
+
:mode => mode,
|
280
|
+
:exit_timeout => timeout,
|
281
|
+
:io_wait_timeout => io_wait,
|
282
|
+
:working_directory => expand_path('.'),
|
283
|
+
:environment => aruba.environment.to_h,
|
284
|
+
:main_class => main_class
|
285
|
+
)
|
256
286
|
|
257
287
|
if aruba.config.before? :cmd
|
258
288
|
# rubocop:disable Metrics/LineLength
|
@@ -261,15 +291,16 @@ module Aruba
|
|
261
291
|
aruba.config.before(:cmd, self, cmd)
|
262
292
|
end
|
263
293
|
|
264
|
-
aruba.config.before(:command, self,
|
294
|
+
aruba.config.before(:command, self, command)
|
265
295
|
|
266
|
-
process_monitor.register_process(cmd,
|
267
|
-
|
296
|
+
process_monitor.register_process(cmd, command)
|
297
|
+
command.run!
|
268
298
|
|
269
|
-
aruba.config.after(:command, self,
|
299
|
+
aruba.config.after(:command, self, command)
|
270
300
|
|
271
|
-
block_given? ? yield(
|
301
|
+
block_given? ? yield(command) : command
|
272
302
|
end
|
303
|
+
# rubocop:enable Metrics/MethodLength
|
273
304
|
|
274
305
|
# Default exit timeout for running commands with aruba
|
275
306
|
#
|
data/lib/aruba/api/core.rb
CHANGED
@@ -7,6 +7,9 @@ require 'aruba/config/jruby'
|
|
7
7
|
|
8
8
|
module Aruba
|
9
9
|
module Api
|
10
|
+
# Core methods of aruba
|
11
|
+
#
|
12
|
+
# Those methods do not depend on any other API method of aruba
|
10
13
|
module Core
|
11
14
|
include ::RSpec::Matchers
|
12
15
|
|
@@ -42,18 +45,41 @@ module Aruba
|
|
42
45
|
# @example Run code in directory
|
43
46
|
# result = cd('some-dir') { Dir.getwd }
|
44
47
|
#
|
48
|
+
# rubocop:disable Metrics/MethodLength
|
45
49
|
def cd(dir, &block)
|
46
|
-
fail ArgumentError, "#{expand_path(dir)} is not a directory or does not exist." unless directory?(dir)
|
47
|
-
|
48
50
|
if block_given?
|
49
|
-
|
50
|
-
|
51
|
+
begin
|
52
|
+
fail ArgumentError, "#{expand_path(dir)} is not a directory or does not exist." unless Aruba::Platform.directory? expand_path(dir)
|
53
|
+
|
54
|
+
aruba.current_directory << dir
|
55
|
+
|
56
|
+
old_dir = Aruba::Platform.getwd
|
57
|
+
old_oldpwd = ENV['OLDPWD']
|
58
|
+
old_pwd = ENV['PWD']
|
59
|
+
|
60
|
+
ENV['OLDPWD'] = Aruba::Platform.getwd
|
61
|
+
ENV['PWD'] = File.join(aruba.root_directory, aruba.current_directory).sub(%r{/$}, '')
|
62
|
+
|
63
|
+
Aruba::Platform.chdir File.join(aruba.root_directory, aruba.current_directory)
|
64
|
+
|
65
|
+
result = block.call
|
66
|
+
ensure
|
67
|
+
aruba.current_directory.pop
|
68
|
+
Aruba::Platform.chdir old_dir
|
69
|
+
ENV['OLDPWD'] = old_oldpwd
|
70
|
+
ENV['PWD'] = old_pwd
|
71
|
+
end
|
72
|
+
|
73
|
+
return result
|
51
74
|
end
|
52
75
|
|
76
|
+
fail ArgumentError, "#{expand_path(dir)} is not a directory or does not exist." unless Aruba::Platform.directory? expand_path(dir)
|
77
|
+
|
53
78
|
aruba.current_directory << dir
|
54
79
|
|
55
80
|
self
|
56
81
|
end
|
82
|
+
# rubocop:enable Metrics/MethodLength
|
57
83
|
|
58
84
|
# Expand file name
|
59
85
|
#
|
@@ -86,6 +112,8 @@ module Aruba
|
|
86
112
|
# # => <path>/test/fixtures/file
|
87
113
|
# expand_path('%/file')
|
88
114
|
#
|
115
|
+
# rubocop:disable Metrics/MethodLength
|
116
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
89
117
|
def expand_path(file_name, dir_string = nil)
|
90
118
|
# rubocop:disable Metrics/LineLength
|
91
119
|
message = %(Filename "#{file_name}" needs to be a string. It cannot be nil or empty either. Please use `expand_path('.')` if you want the current directory to be expanded.)
|
@@ -103,12 +131,20 @@ module Aruba
|
|
103
131
|
|
104
132
|
if aruba.config.fixtures_path_prefix == prefix
|
105
133
|
File.join aruba.fixtures_directory, rest
|
106
|
-
|
134
|
+
elsif '~' == prefix
|
107
135
|
with_environment do
|
108
|
-
|
136
|
+
path = File.join(ENV['HOME'], aruba.current_directory.relative_path_from(Pathname.new(aruba.config.working_directory)))
|
137
|
+
|
138
|
+
fail 'Expanding "~/" to "/" is not allowed' if path == '/'
|
139
|
+
|
140
|
+
Aruba::Platform.chdir(path) { Aruba::Platform.expand_path(file_name, dir_string) }
|
109
141
|
end
|
142
|
+
else
|
143
|
+
Aruba::Platform.chdir(File.join(aruba.root_directory,aruba.current_directory)) { Aruba::Platform.expand_path(file_name, dir_string) }
|
110
144
|
end
|
111
145
|
end
|
146
|
+
# rubocop:enable Metrics/MethodLength
|
147
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
112
148
|
|
113
149
|
# Run block with environment
|
114
150
|
#
|
data/lib/aruba/api/deprecated.rb
CHANGED
@@ -22,7 +22,7 @@ module Aruba
|
|
22
22
|
def current_directory
|
23
23
|
Aruba::Platform.deprecated(%(The use of "current_directory" deprecated. Use "expand_path(".")" to get the current directory or "#cd" to run code in the current directory. #{caller.first}))
|
24
24
|
|
25
|
-
|
25
|
+
aruba.current_directory.to_s
|
26
26
|
end
|
27
27
|
|
28
28
|
# @deprecated
|
data/lib/aruba/aruba_path.rb
CHANGED
@@ -2,13 +2,21 @@ require 'pathname'
|
|
2
2
|
require 'delegate'
|
3
3
|
|
4
4
|
module Aruba
|
5
|
-
class ArubaPath <
|
5
|
+
class ArubaPath < Delegator
|
6
6
|
def initialize(path)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
obj = [path.to_s].flatten
|
8
|
+
|
9
|
+
super obj
|
10
|
+
|
11
|
+
@delegate_sd_obj = obj
|
12
|
+
end
|
13
|
+
|
14
|
+
def __getobj__
|
15
|
+
::Pathname.new(::File.join(*@delegate_sd_obj))
|
16
|
+
end
|
17
|
+
|
18
|
+
def __setobj__(obj)
|
19
|
+
@delegate_sd_obj = [obj.to_s].flatten
|
12
20
|
end
|
13
21
|
|
14
22
|
# Add directory/file to path
|
@@ -23,7 +31,7 @@ module Aruba
|
|
23
31
|
# puts path
|
24
32
|
# # => path/to/dir.d/subdir.d
|
25
33
|
def push(p)
|
26
|
-
|
34
|
+
@delegate_sd_obj << p
|
27
35
|
end
|
28
36
|
alias_method :<<, :push
|
29
37
|
|
@@ -35,16 +43,7 @@ module Aruba
|
|
35
43
|
# puts path
|
36
44
|
# # => path/to
|
37
45
|
def pop
|
38
|
-
|
39
|
-
dirs = []
|
40
|
-
__getobj__.each_filename { |f| dirs << f }
|
41
|
-
else
|
42
|
-
dirs = __getobj__.each_filename.to_a
|
43
|
-
end
|
44
|
-
|
45
|
-
dirs.pop
|
46
|
-
|
47
|
-
__setobj__ Pathname.new(File.join(*dirs))
|
46
|
+
@delegate_sd_obj.pop
|
48
47
|
end
|
49
48
|
|
50
49
|
if RUBY_VERSION < '1.9'
|
@@ -53,14 +52,30 @@ module Aruba
|
|
53
52
|
end
|
54
53
|
|
55
54
|
def relative?
|
56
|
-
!(%r{\A/} ===
|
55
|
+
!(%r{\A/} === to_s)
|
57
56
|
end
|
58
57
|
|
59
58
|
def absolute?
|
60
|
-
(%r{\A/} ===
|
59
|
+
(%r{\A/} === to_s)
|
61
60
|
end
|
62
61
|
end
|
63
62
|
|
63
|
+
# Path ends with string
|
64
|
+
#
|
65
|
+
# @param [String] string
|
66
|
+
# The string to check
|
67
|
+
def end_with?(string)
|
68
|
+
to_s.end_with? string
|
69
|
+
end
|
70
|
+
|
71
|
+
# Path starts with string
|
72
|
+
#
|
73
|
+
# @param [String] string
|
74
|
+
# The string to check
|
75
|
+
def start_with?(string)
|
76
|
+
to_s.start_with? string
|
77
|
+
end
|
78
|
+
|
64
79
|
# Return string at index
|
65
80
|
#
|
66
81
|
# @param [Integer, Range] index
|
@@ -32,7 +32,7 @@ module Aruba
|
|
32
32
|
default = opts[:default]
|
33
33
|
|
34
34
|
fail ArgumentError, 'Either use block or default value' if block_given? && default
|
35
|
-
fail ArgumentError, 'Either use block or default value' if !block_given? && default.nil? && default.empty?
|
35
|
+
# fail ArgumentError, 'Either use block or default value' if !block_given? && default.nil? && default.to_s.empty?
|
36
36
|
fail ArgumentError, 'contract-options is required' if contract.nil?
|
37
37
|
|
38
38
|
# Add writer
|
@@ -9,8 +9,8 @@ module Aruba
|
|
9
9
|
name = opts[:name]
|
10
10
|
value = opts[:value]
|
11
11
|
|
12
|
-
fail ArgumentError, '"name" is required'
|
13
|
-
fail ArgumentError, '"value" is required'
|
12
|
+
fail ArgumentError, '"name" is required' unless opts.key? :name
|
13
|
+
fail ArgumentError, '"value" is required' unless opts.key? :value
|
14
14
|
|
15
15
|
@name = name
|
16
16
|
@value = value
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'aruba/processes/spawn_process'
|
2
|
+
require 'aruba/processes/in_process'
|
3
|
+
require 'aruba/processes/debug_process'
|
4
|
+
|
5
|
+
module Aruba
|
6
|
+
class Command < SimpleDelegator
|
7
|
+
def initialize(command, opts = {})
|
8
|
+
launchers = []
|
9
|
+
launchers << Processes::DebugProcess
|
10
|
+
launchers << Processes::InProcess
|
11
|
+
launchers << Processes::SpawnProcess
|
12
|
+
|
13
|
+
launcher = launchers.find { |l| l.match? opts[:mode] }
|
14
|
+
|
15
|
+
super launcher.new(
|
16
|
+
command,
|
17
|
+
opts.fetch(:exit_timeout),
|
18
|
+
opts.fetch(:io_wait_timeout),
|
19
|
+
opts.fetch(:working_directory),
|
20
|
+
opts.fetch(:environment),
|
21
|
+
opts.fetch(:main_class)
|
22
|
+
)
|
23
|
+
rescue KeyError => e
|
24
|
+
raise ArgumentError, e.message
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/aruba/config.rb
CHANGED
@@ -3,6 +3,8 @@ require 'aruba/basic_configuration'
|
|
3
3
|
require 'aruba/config_wrapper'
|
4
4
|
require 'aruba/hooks'
|
5
5
|
require 'aruba/contracts/relative_path'
|
6
|
+
require 'aruba/contracts/enum'
|
7
|
+
require 'aruba/contracts/is_a'
|
6
8
|
|
7
9
|
module Aruba
|
8
10
|
# Aruba Configuration
|
@@ -22,8 +24,14 @@ module Aruba
|
|
22
24
|
option_accessor :io_wait_timeout, :contract => { Num => Num }, :default => 0.1
|
23
25
|
option_accessor :fixtures_directories, :contract => { Array => ArrayOf[String] }, :default => %w(features/fixtures spec/fixtures test/fixtures)
|
24
26
|
option_accessor :command_runtime_environment, :contract => { Hash => Hash }, :default => ENV.to_hash
|
27
|
+
# rubocop:disable Metrics/LineLength
|
25
28
|
option_accessor(:command_search_paths, :contract => { ArrayOf[String] => ArrayOf[String] }) { |config| [File.join(config.root_directory.value, 'bin')] }
|
29
|
+
# rubocop:enable Metrics/LineLength
|
26
30
|
option_accessor :keep_ansi, :contract => { Bool => Bool }, :default => false
|
31
|
+
# rubocop:disable Metrics/LineLength
|
32
|
+
option_accessor :command_launcher, :contract => { Aruba::Contracts::Enum[:in_process, :spawn, :debug] => Aruba::Contracts::Enum[:in_process, :spawn, :debug] }, :default => :spawn
|
33
|
+
# rubocop:enable Metrics/LineLength
|
34
|
+
option_accessor :main_class, :contract => { Aruba::Contracts::IsA[Class] => Or[Aruba::Contracts::IsA[Class], Eq[nil]] }, :default => nil
|
27
35
|
end
|
28
36
|
end
|
29
37
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'contracts'
|
2
|
+
|
3
|
+
module Aruba
|
4
|
+
module Contracts
|
5
|
+
class Enum < ::Contracts::CallableClass
|
6
|
+
private
|
7
|
+
|
8
|
+
attr_reader :vals
|
9
|
+
|
10
|
+
public
|
11
|
+
|
12
|
+
def initialize(*vals)
|
13
|
+
@vals = vals
|
14
|
+
end
|
15
|
+
|
16
|
+
def valid?(val)
|
17
|
+
vals.include? val
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'contracts'
|
2
|
+
|
3
|
+
module Aruba
|
4
|
+
module Contracts
|
5
|
+
class IsA < ::Contracts::CallableClass
|
6
|
+
private
|
7
|
+
|
8
|
+
attr_reader :vals
|
9
|
+
|
10
|
+
public
|
11
|
+
|
12
|
+
def initialize(*vals)
|
13
|
+
@vals = vals
|
14
|
+
end
|
15
|
+
|
16
|
+
def valid?(val)
|
17
|
+
vals.any? { |v| val.is_a? v }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/aruba/cucumber.rb
CHANGED
@@ -207,6 +207,10 @@ Then /^the output should match \/([^\/]*)\/$/ do |expected|
|
|
207
207
|
assert_matching_output(expected, all_output)
|
208
208
|
end
|
209
209
|
|
210
|
+
Then /^the output should match %r<([^>]*)>$/ do |expected|
|
211
|
+
assert_matching_output(expected, all_output)
|
212
|
+
end
|
213
|
+
|
210
214
|
Then /^the output should match:$/ do |expected|
|
211
215
|
assert_matching_output(expected, all_output)
|
212
216
|
end
|
data/lib/aruba/cucumber/hooks.rb
CHANGED
@@ -90,13 +90,12 @@ Before('@announce') do
|
|
90
90
|
end
|
91
91
|
|
92
92
|
Before('@debug') do
|
93
|
-
|
94
|
-
Aruba.process = Aruba::Processes::DebugProcess
|
93
|
+
aruba.config.command_launcher = :debug
|
95
94
|
end
|
96
95
|
|
97
|
-
After('@debug') do
|
98
|
-
|
99
|
-
end
|
96
|
+
# After('@debug') do
|
97
|
+
# aruba.config.command_launcher = :spawn
|
98
|
+
# end
|
100
99
|
|
101
100
|
Before('@ansi') do
|
102
101
|
@aruba_keep_ansi = true
|
data/lib/aruba/in_process.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
require 'aruba/processes/in_process'
|
2
|
+
require 'aruba/platform'
|
2
3
|
|
3
4
|
module Aruba
|
4
5
|
class InProcess < Aruba::Processes::InProcess
|
5
6
|
def initialize(*args)
|
6
|
-
|
7
|
+
Aruba::Platform.deprecated('The use of "Aruba::InProcess" is deprecated. Use "Aruba::Processes::InProcess" instead.')
|
7
8
|
|
8
9
|
super
|
9
10
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'rspec/expectations/version'
|
2
|
+
|
1
3
|
require 'aruba/matchers/command/have_exit_status'
|
2
4
|
require 'aruba/matchers/command/have_finished_in_time'
|
3
5
|
|
@@ -27,4 +29,6 @@ RSpec::Matchers.define :be_successfully_executed do
|
|
27
29
|
end
|
28
30
|
end
|
29
31
|
|
30
|
-
RSpec::
|
32
|
+
if RSpec::Expectations::Version::STRING >= '3.1'
|
33
|
+
RSpec::Matchers.define_negated_matcher :have_failed_running, :be_successfully_executed
|
34
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'rspec/expectations/version'
|
2
|
+
|
1
3
|
# @!method run_too_long
|
2
4
|
# This matchers checks if <command> run too long. Say the timeout is 10
|
3
5
|
# seconds and it takes <command> to finish in 15. This matchers will succeed.
|
@@ -39,4 +41,6 @@ RSpec::Matchers.define :have_finished_in_time do
|
|
39
41
|
end
|
40
42
|
end
|
41
43
|
|
42
|
-
RSpec::
|
44
|
+
if RSpec::Expectations::Version::STRING >= '3.1'
|
45
|
+
RSpec::Matchers.define_negated_matcher :run_too_long, :have_finished_in_time
|
46
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'rspec/expectations/version'
|
2
|
+
|
1
3
|
# @!method be_an_existing_directory
|
2
4
|
# This matchers checks if <directory> exists in filesystem
|
3
5
|
#
|
@@ -31,4 +33,6 @@ RSpec::Matchers.define :be_an_existing_directory do |_|
|
|
31
33
|
end
|
32
34
|
end
|
33
35
|
|
34
|
-
RSpec::
|
36
|
+
if RSpec::Expectations::Version::STRING >= '3.0'
|
37
|
+
RSpec::Matchers.alias_matcher :an_existing_directory, :be_an_existing_directory
|
38
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'rspec/expectations/version'
|
2
|
+
|
1
3
|
# @!method have_sub_directory(sub_directory)
|
2
4
|
# This matchers checks if <directory> has given sub-directory
|
3
5
|
#
|
@@ -46,4 +48,6 @@ RSpec::Matchers.define :have_sub_directory do |expected|
|
|
46
48
|
end
|
47
49
|
end
|
48
50
|
|
49
|
-
RSpec::
|
51
|
+
if RSpec::Expectations::Version::STRING >= '3.0'
|
52
|
+
RSpec::Matchers.alias_matcher :a_directory_having_sub_directory, :have_sub_directory
|
53
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'rspec/expectations/version'
|
2
|
+
|
1
3
|
# @!method be_an_existing_file
|
2
4
|
# This matchers checks if <file> exists in filesystem
|
3
5
|
#
|
@@ -31,4 +33,6 @@ RSpec::Matchers.define :be_an_existing_file do |_|
|
|
31
33
|
end
|
32
34
|
end
|
33
35
|
|
34
|
-
RSpec::
|
36
|
+
if RSpec::Expectations::Version::STRING >= '3.0'
|
37
|
+
RSpec::Matchers.alias_matcher :an_existing_file, :be_an_existing_file
|
38
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'rspec/expectations/version'
|
2
|
+
|
1
3
|
# @!method have_file_content(content)
|
2
4
|
# This matchers checks if <file> has content. `content` can be a string,
|
3
5
|
# regexp or an RSpec matcher.
|
@@ -55,4 +57,6 @@ RSpec::Matchers.define :have_file_content do |expected|
|
|
55
57
|
description { "have file content: #{description_of expected}" }
|
56
58
|
end
|
57
59
|
|
58
|
-
RSpec::
|
60
|
+
if RSpec::Expectations::Version::STRING >= '3.0'
|
61
|
+
RSpec::Matchers.alias_matcher :a_file_having_content, :have_file_content
|
62
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'rspec/expectations/version'
|
2
|
+
|
1
3
|
# @!method have_file_size(size)
|
2
4
|
# This matchers checks if path has file size
|
3
5
|
#
|
@@ -40,4 +42,6 @@ RSpec::Matchers.define :have_file_size do |expected|
|
|
40
42
|
end
|
41
43
|
end
|
42
44
|
|
43
|
-
RSpec::
|
45
|
+
if RSpec::Expectations::Version::STRING >= '3.0'
|
46
|
+
RSpec::Matchers.alias_matcher :a_file_of_size, :have_file_size
|
47
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'rspec/expectations/version'
|
2
|
+
|
1
3
|
require 'fileutils'
|
2
4
|
|
3
5
|
# @!method have_same_file_content_like(file_name)
|
@@ -41,4 +43,6 @@ RSpec::Matchers.define :have_same_file_content_like do |expected|
|
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
44
|
-
RSpec::
|
46
|
+
if RSpec::Expectations::Version::STRING >= '3.0'
|
47
|
+
RSpec::Matchers.alias_matcher :a_file_with_same_content_like, :have_same_file_content_like
|
48
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'rspec/expectations/version'
|
2
|
+
|
1
3
|
# @!method a_path_matching_pattern(/pattern/)
|
2
4
|
# This matchers checks if <path> matches pattern. `pattern` can be a string,
|
3
5
|
# regexp or an RSpec matcher.
|
@@ -18,4 +20,6 @@
|
|
18
20
|
# RSpec.describe do
|
19
21
|
# it { expect(files).to include a_path_matching_pattern /asdf/ }
|
20
22
|
# end
|
21
|
-
RSpec::
|
23
|
+
if RSpec::Expectations::Version::STRING >= '3.0'
|
24
|
+
RSpec::Matchers.alias_matcher :a_path_matching_pattern, :match
|
25
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'rspec/expectations/version'
|
2
|
+
|
1
3
|
# @!method be_an_absolute_path
|
2
4
|
# This matchers checks if <path> exists in filesystem
|
3
5
|
#
|
@@ -29,4 +31,6 @@ RSpec::Matchers.define :be_an_absolute_path do |_|
|
|
29
31
|
end
|
30
32
|
end
|
31
33
|
|
32
|
-
RSpec::
|
34
|
+
if RSpec::Expectations::Version::STRING >= '3.0'
|
35
|
+
RSpec::Matchers.alias_matcher :an_absolute_path, :be_an_absolute_path
|
36
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'rspec/expectations/version'
|
2
|
+
|
1
3
|
# @!method be_an_existing_path
|
2
4
|
# This matchers checks if <path> exists in filesystem
|
3
5
|
#
|
@@ -30,4 +32,6 @@ RSpec::Matchers.define :be_an_existing_path do |_|
|
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
33
|
-
RSpec::
|
35
|
+
if RSpec::Expectations::Version::STRING >= '3.0'
|
36
|
+
RSpec::Matchers.alias_matcher :an_existing_path, :be_an_existing_path
|
37
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'rspec/expectations/version'
|
2
|
+
|
1
3
|
# @!method have_permissions(permissions)
|
2
4
|
# This matchers checks if <file> or <directory> has <perm> permissions
|
3
5
|
#
|
@@ -57,4 +59,6 @@ RSpec::Matchers.define :have_permissions do |expected|
|
|
57
59
|
end
|
58
60
|
end
|
59
61
|
|
60
|
-
RSpec::
|
62
|
+
if RSpec::Expectations::Version::STRING >= '3.0'
|
63
|
+
RSpec::Matchers.alias_matcher :a_path_having_permissions, :have_permissions
|
64
|
+
end
|
data/lib/aruba/platform.rb
CHANGED
@@ -54,11 +54,28 @@ module Aruba
|
|
54
54
|
FileUtils.rm_r(paths, options)
|
55
55
|
end
|
56
56
|
|
57
|
+
def getwd
|
58
|
+
Dir.getwd
|
59
|
+
end
|
60
|
+
|
57
61
|
# Change to directory
|
58
62
|
def chdir(dir_name, &block)
|
59
63
|
dir_name = ::File.expand_path(dir_name.to_s)
|
60
64
|
|
61
|
-
|
65
|
+
begin
|
66
|
+
if RUBY_VERSION <= '1.9.3'
|
67
|
+
old_env = ENV.to_hash
|
68
|
+
else
|
69
|
+
old_env = ENV.to_h
|
70
|
+
end
|
71
|
+
|
72
|
+
ENV['OLDPWD'] = getwd
|
73
|
+
ENV['PWD'] = dir_name
|
74
|
+
::Dir.chdir(dir_name, &block)
|
75
|
+
ensure
|
76
|
+
ENV.clear
|
77
|
+
ENV.update old_env
|
78
|
+
end
|
62
79
|
end
|
63
80
|
|
64
81
|
# Touch file, directory
|
@@ -224,6 +241,7 @@ module Aruba
|
|
224
241
|
:relative_command?, \
|
225
242
|
:executable_file?, \
|
226
243
|
:unescape, \
|
244
|
+
:getwd, \
|
227
245
|
:which, \
|
228
246
|
:write_file
|
229
247
|
end
|
@@ -6,10 +6,11 @@ module Aruba
|
|
6
6
|
class BasicProcess
|
7
7
|
attr_reader :exit_status, :environment
|
8
8
|
|
9
|
-
def initialize(cmd, exit_timeout, io_wait, working_directory, environment = ENV.to_hash)
|
9
|
+
def initialize(cmd, exit_timeout, io_wait, working_directory, environment = ENV.to_hash, main_class = nil)
|
10
10
|
@cmd = cmd
|
11
11
|
@working_directory = working_directory
|
12
12
|
@environment = environment
|
13
|
+
@main_class = main_class
|
13
14
|
@exit_status = nil
|
14
15
|
end
|
15
16
|
|
@@ -2,20 +2,13 @@ require 'aruba/processes/spawn_process'
|
|
2
2
|
|
3
3
|
module Aruba
|
4
4
|
module Processes
|
5
|
-
#
|
6
|
-
#
|
7
|
-
# @params [String] cmd
|
8
|
-
# Command string
|
9
|
-
#
|
10
|
-
# @params [Integer] exit_timeout
|
11
|
-
# The timeout until we expect the command to be finished
|
12
|
-
#
|
13
|
-
# @params [Integer] io_wait
|
14
|
-
# The timeout until we expect the io to be finished
|
15
|
-
#
|
16
|
-
# @params [String] working_directory
|
17
|
-
# The directory where the command will be executed
|
5
|
+
# Debug Process
|
18
6
|
class DebugProcess < BasicProcess
|
7
|
+
# Use only if mode is :debug
|
8
|
+
def self.match?(mode)
|
9
|
+
mode == :debug || mode == DebugProcess
|
10
|
+
end
|
11
|
+
|
19
12
|
# rubocop:disable Metrics/MethodLength
|
20
13
|
# rubocop:disable Metrics/CyclomaticComplexity
|
21
14
|
def run!
|
@@ -5,6 +5,11 @@ require 'aruba/processes/basic_process'
|
|
5
5
|
module Aruba
|
6
6
|
module Processes
|
7
7
|
class InProcess < BasicProcess
|
8
|
+
# Use only if mode is in_process
|
9
|
+
def self.match?(mode)
|
10
|
+
mode == :in_process || mode == InProcess
|
11
|
+
end
|
12
|
+
|
8
13
|
attr_reader :exit_status
|
9
14
|
|
10
15
|
class FakeKernel
|
@@ -20,10 +25,13 @@ module Aruba
|
|
20
25
|
end
|
21
26
|
|
22
27
|
class << self
|
28
|
+
# @deprecated
|
23
29
|
attr_accessor :main_class
|
24
30
|
end
|
25
31
|
|
26
|
-
|
32
|
+
attr_reader :main_class
|
33
|
+
|
34
|
+
def initialize(cmd, exit_timeout, io_wait, working_directory, environment = ENV.to_hash, main_class = nil)
|
27
35
|
@cmd = cmd
|
28
36
|
@argv = arguments
|
29
37
|
@stdin = StringIO.new
|
@@ -35,13 +43,13 @@ module Aruba
|
|
35
43
|
end
|
36
44
|
|
37
45
|
def run!
|
38
|
-
|
46
|
+
fail "You need to call aruba.config.main_class = YourMainClass" unless main_class
|
39
47
|
|
40
48
|
Dir.chdir @working_directory do
|
41
49
|
before_run
|
42
50
|
|
43
|
-
|
44
|
-
|
51
|
+
in_environment 'PWD' => @working_directory do
|
52
|
+
main_class.new(@argv, @stdin, @stdout, @stderr, @kernel).execute!
|
45
53
|
end
|
46
54
|
|
47
55
|
after_run
|
@@ -83,12 +91,16 @@ module Aruba
|
|
83
91
|
|
84
92
|
private
|
85
93
|
|
86
|
-
def
|
87
|
-
|
94
|
+
def in_environment(env = {}, &block)
|
95
|
+
if RUBY_VERSION <= '1.9.3'
|
96
|
+
old_env = ENV.to_hash
|
97
|
+
else
|
98
|
+
old_env = ENV.to_h
|
99
|
+
end
|
88
100
|
|
89
|
-
ENV.update(environment)
|
101
|
+
ENV.update(environment).update(env)
|
90
102
|
|
91
|
-
block.call
|
103
|
+
block.call if block_given?
|
92
104
|
ensure
|
93
105
|
ENV.clear
|
94
106
|
ENV.update old_env
|
@@ -7,6 +7,11 @@ require 'aruba/processes/basic_process'
|
|
7
7
|
module Aruba
|
8
8
|
module Processes
|
9
9
|
class SpawnProcess < BasicProcess
|
10
|
+
# Use as default launcher
|
11
|
+
def self.match?(mode)
|
12
|
+
true
|
13
|
+
end
|
14
|
+
|
10
15
|
# Create process
|
11
16
|
#
|
12
17
|
# @params [String] cmd
|
@@ -20,7 +25,7 @@ module Aruba
|
|
20
25
|
#
|
21
26
|
# @params [String] working_directory
|
22
27
|
# The directory where the command will be executed
|
23
|
-
def initialize(cmd, exit_timeout, io_wait, working_directory, environment = ENV.to_hash)
|
28
|
+
def initialize(cmd, exit_timeout, io_wait, working_directory, environment = ENV.to_hash, main_class = nil)
|
24
29
|
super
|
25
30
|
|
26
31
|
@exit_timeout = exit_timeout
|
data/spec/aruba/api_spec.rb
CHANGED
@@ -726,6 +726,7 @@ describe Aruba::Api do
|
|
726
726
|
allow(runtime).to receive(:config).and_return config
|
727
727
|
allow(runtime).to receive(:environment).and_return environment
|
728
728
|
allow(runtime).to receive(:current_directory).and_return aruba.current_directory
|
729
|
+
allow(runtime).to receive(:root_directory).and_return aruba.root_directory
|
729
730
|
allow(runtime).to receive(:fixtures_directory).and_return File.join(aruba.root_directory, aruba.current_directory, 'spec', 'fixtures')
|
730
731
|
end
|
731
732
|
|
@@ -37,9 +37,10 @@ RSpec.describe Aruba::ArubaPath do
|
|
37
37
|
end
|
38
38
|
|
39
39
|
describe '#pop' do
|
40
|
+
before(:each) { path << 'subdir' }
|
40
41
|
before(:each) { path.pop }
|
41
42
|
|
42
|
-
it { expect(path.to_s).to eq 'path/to' }
|
43
|
+
it { expect(path.to_s).to eq 'path/to/dir' }
|
43
44
|
end
|
44
45
|
|
45
46
|
describe '#relative?' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aruba
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.0.
|
4
|
+
version: 0.8.0.pre3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aslak Hellesøy
|
@@ -13,20 +13,20 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2015-07-
|
16
|
+
date: 2015-07-13 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: cucumber
|
20
20
|
requirement: !ruby/object:Gem::Requirement
|
21
21
|
requirements:
|
22
|
-
- - "
|
22
|
+
- - "~>"
|
23
23
|
- !ruby/object:Gem::Version
|
24
24
|
version: 1.3.19
|
25
25
|
type: :runtime
|
26
26
|
prerelease: false
|
27
27
|
version_requirements: !ruby/object:Gem::Requirement
|
28
28
|
requirements:
|
29
|
-
- - "
|
29
|
+
- - "~>"
|
30
30
|
- !ruby/object:Gem::Version
|
31
31
|
version: 1.3.19
|
32
32
|
- !ruby/object:Gem::Dependency
|
@@ -47,16 +47,16 @@ dependencies:
|
|
47
47
|
name: rspec-expectations
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
49
49
|
requirements:
|
50
|
-
- - "
|
50
|
+
- - ">="
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: '
|
52
|
+
version: '2.11'
|
53
53
|
type: :runtime
|
54
54
|
prerelease: false
|
55
55
|
version_requirements: !ruby/object:Gem::Requirement
|
56
56
|
requirements:
|
57
|
-
- - "
|
57
|
+
- - ">="
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version: '
|
59
|
+
version: '2.11'
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
61
|
name: contracts
|
62
62
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,9 +178,12 @@ files:
|
|
178
178
|
- lib/aruba/aruba_path.rb
|
179
179
|
- lib/aruba/basic_configuration.rb
|
180
180
|
- lib/aruba/basic_configuration/option.rb
|
181
|
+
- lib/aruba/command.rb
|
181
182
|
- lib/aruba/config.rb
|
182
183
|
- lib/aruba/config/jruby.rb
|
183
184
|
- lib/aruba/config_wrapper.rb
|
185
|
+
- lib/aruba/contracts/enum.rb
|
186
|
+
- lib/aruba/contracts/is_a.rb
|
184
187
|
- lib/aruba/contracts/relative_path.rb
|
185
188
|
- lib/aruba/creators/aruba_file_creator.rb
|
186
189
|
- lib/aruba/creators/aruba_fixed_size_file_creator.rb
|
@@ -272,14 +275,15 @@ licenses:
|
|
272
275
|
metadata: {}
|
273
276
|
post_install_message: |
|
274
277
|
With aruba >= 1.0
|
275
|
-
* "ruby 1.8.7"-support is discontinued
|
276
|
-
* aruba requires "cucumber 2" for the feature steps. The rest of aruba should be usable by whatever testing framework you are using
|
277
|
-
* Overwriting methods for configuration is discontinued. You need to use `aruba.config.<variable>` or `Aruba.configure { |config| config.<variable>` instead
|
278
|
-
* "aruba/reporting" will be removed. Please use `@debug`-tag + `byebug`, `debugger`, `pry` to troubleshoot your feature tests
|
279
|
-
* Set environment variables will have only effect on `#run` and the like + `#with_environment { }
|
278
|
+
* "ruby 1.8.7"-support is discontinued.
|
279
|
+
* aruba requires "cucumber 2" for the feature steps. The rest of aruba should be usable by whatever testing framework you are using.
|
280
|
+
* Overwriting methods for configuration is discontinued. You need to use `aruba.config.<variable>` or `Aruba.configure { |config| config.<variable>` instead.
|
281
|
+
* "aruba/reporting" will be removed. Please use `@debug`-tag + `byebug`, `debugger`, `pry` to troubleshoot your feature tests.
|
282
|
+
* Set environment variables will have only effect on `#run` and the like + `#with_environment { }`.
|
280
283
|
* The process environment will be fully resetted between tests. Sharing state via ENV['VAR'] = 'shared state' between tests will not be possible anymore. Please make that obvious by using explicit steps or use the aruba API for that.
|
281
284
|
* There will be a major cleanup for command execution. There will be only `run` and `run_simple` left. `run_interactive` is replaced by `run`.
|
282
|
-
* Setting the root directory of aruba via method overwrite or configuration - this should be your project root directory where the test suite is run
|
285
|
+
* Setting the root directory of aruba via method overwrite or configuration - this should be your project root directory where the test suite is run.
|
286
|
+
* The direct use of "InProcess", "DebugProcess" and "SpawnProcess" is not supported anymore. You need to use "Command" instead. But be careful, it has a different API.
|
283
287
|
rdoc_options:
|
284
288
|
- "--charset=UTF-8"
|
285
289
|
require_paths:
|
@@ -299,7 +303,7 @@ rubyforge_project:
|
|
299
303
|
rubygems_version: 2.4.5
|
300
304
|
signing_key:
|
301
305
|
specification_version: 4
|
302
|
-
summary: aruba-0.8.0.
|
306
|
+
summary: aruba-0.8.0.pre3
|
303
307
|
test_files:
|
304
308
|
- features/api/cd.feature
|
305
309
|
- features/api/command/run.feature
|