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 +4 -4
- data/.gitignore +6 -0
- data/.rubocop.yml +3 -0
- data/.travis.yml +3 -0
- data/Gemfile +1 -1
- data/History.md +7 -2
- data/README.md +26 -15
- data/Rakefile +4 -1
- data/aruba.gemspec +2 -1
- data/config/rubocop/exclude.yml +160 -0
- data/config/rubocop/include.yml +0 -0
- data/features/file_system_commands.feature +23 -7
- data/features/support/custom_main.rb +2 -2
- data/features/support/env.rb +0 -1
- data/features/support/jruby.rb +1 -1
- data/lib/aruba/api.rb +217 -30
- data/lib/aruba/config.rb +8 -8
- data/lib/aruba/cucumber.rb +13 -21
- data/lib/aruba/in_process.rb +1 -1
- data/lib/aruba/jruby.rb +1 -1
- data/lib/aruba/reporting.rb +7 -8
- data/spec/aruba/api_spec.rb +136 -27
- data/spec/aruba/jruby_spec.rb +19 -17
- data/spec/spec_helper.rb +2 -38
- metadata +20 -3
data/lib/aruba/config.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
module Aruba
|
2
2
|
class Config
|
3
3
|
attr_reader :hooks
|
4
|
-
|
4
|
+
|
5
5
|
def initialize
|
6
6
|
@hooks = Hooks.new
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
# Register a hook to be called before Aruba runs a command
|
10
10
|
def before_cmd(&block)
|
11
11
|
@hooks.append(:before_cmd, block)
|
12
12
|
end
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
#nodoc
|
16
16
|
class Hooks
|
17
17
|
def initialize
|
@@ -19,26 +19,26 @@ module Aruba
|
|
19
19
|
hash[key] = []
|
20
20
|
end
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
def append(label, block)
|
24
24
|
@store[label] << block
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
def execute(label, context, *args)
|
28
28
|
@store[label].each do |block|
|
29
29
|
context.instance_exec(*args, &block)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
class << self
|
35
35
|
attr_accessor :config
|
36
36
|
|
37
37
|
def configure
|
38
38
|
yield config
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
self.config = Config.new
|
44
44
|
end
|
data/lib/aruba/cucumber.rb
CHANGED
@@ -129,7 +129,7 @@ When /^I pipe in the file "([^"]*)"$/ do |file|
|
|
129
129
|
end
|
130
130
|
|
131
131
|
When /^I wait for (?:output|stdout) to contain "([^"]*)"$/ do |expected|
|
132
|
-
Timeout
|
132
|
+
Timeout.timeout(exit_timeout) do
|
133
133
|
loop do
|
134
134
|
break if assert_partial_output_interactive(expected)
|
135
135
|
sleep 0.1
|
@@ -332,36 +332,28 @@ Then /^the following directories should not exist:$/ do |directories|
|
|
332
332
|
check_directory_presence(directories.raw.map{|directory_row| directory_row[0]}, false)
|
333
333
|
end
|
334
334
|
|
335
|
-
Then /^a directory named "([^"]*)" should exist$/ do |directory|
|
336
|
-
check_directory_presence([directory],
|
335
|
+
Then /^a directory named "([^"]*)" should (not )?exist$/ do |directory, expect_match|
|
336
|
+
check_directory_presence([directory], !expect_match)
|
337
337
|
end
|
338
338
|
|
339
|
-
Then /^
|
340
|
-
|
339
|
+
Then /^the file "([^"]*)" should (not )?contain "([^"]*)"$/ do |file, expect_match, partial_content|
|
340
|
+
check_file_content(file, Regexp.compile(Regexp.escape(partial_content)), !expect_match)
|
341
341
|
end
|
342
342
|
|
343
|
-
Then /^the file "([^"]*)" should
|
344
|
-
check_file_content(file, partial_content,
|
343
|
+
Then /^the file "([^"]*)" should (not )?contain:$/ do |file, expect_match, partial_content|
|
344
|
+
check_file_content(file, Regexp.compile(Regexp.escape(partial_content)), !expect_match)
|
345
345
|
end
|
346
346
|
|
347
|
-
Then /^the file "([^"]*)" should not contain
|
348
|
-
check_file_content(file,
|
347
|
+
Then /^the file "([^"]*)" should (not )?contain exactly:$/ do |file, expect_match, exact_content|
|
348
|
+
check_file_content(file, exact_content, !expect_match)
|
349
349
|
end
|
350
350
|
|
351
|
-
Then /^the file "([^"]*)" should
|
352
|
-
check_file_content(file, partial_content
|
351
|
+
Then /^the file "([^"]*)" should (not )?match \/([^\/]*)\/$/ do |file, expect_match, partial_content|
|
352
|
+
check_file_content(file, /#{partial_content}/, !expect_match)
|
353
353
|
end
|
354
354
|
|
355
|
-
Then /^the file "([^"]*)" should
|
356
|
-
|
357
|
-
end
|
358
|
-
|
359
|
-
Then /^the file "([^"]*)" should match \/([^\/]*)\/$/ do |file, partial_content|
|
360
|
-
check_file_content(file, /#{partial_content}/, true)
|
361
|
-
end
|
362
|
-
|
363
|
-
Then /^the file "([^"]*)" should not match \/([^\/]*)\/$/ do |file, partial_content|
|
364
|
-
check_file_content(file, /#{partial_content}/, false)
|
355
|
+
Then /^the file "([^"]*)" should (not )?be equal to file "([^"]*)"/ do |file, expect_match, reference_file|
|
356
|
+
check_binary_file_content(file, reference_file, !expect_match)
|
365
357
|
end
|
366
358
|
|
367
359
|
Then /^the mode of filesystem object "([^"]*)" should match "([^"]*)"$/ do |file, mode|
|
data/lib/aruba/in_process.rb
CHANGED
data/lib/aruba/jruby.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
Aruba.configure do |config|
|
3
3
|
config.before_cmd do
|
4
4
|
# disable JIT since these processes are so short lived
|
5
|
-
set_env('JRUBY_OPTS', "-X-C #{ENV['JRUBY_OPTS']}")
|
5
|
+
set_env('JRUBY_OPTS', "-X-C #{ENV['JRUBY_OPTS']}")
|
6
6
|
# force jRuby to use client JVM for faster startup times
|
7
7
|
set_env('JAVA_OPTS', "-d32 #{ENV['JAVA_OPTS']}") if RbConfig::CONFIG['host_os'] =~ /solaris|sunos/i
|
8
8
|
end
|
data/lib/aruba/reporting.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
if(ENV['ARUBA_REPORT_DIR'])
|
2
2
|
ENV['ARUBA_REPORT_TEMPLATES'] ||= File.dirname(__FILE__) + '/../../templates'
|
3
|
-
|
3
|
+
|
4
4
|
require 'fileutils'
|
5
5
|
require 'erb'
|
6
6
|
require 'cgi'
|
@@ -17,7 +17,7 @@ if(ENV['ARUBA_REPORT_DIR'])
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
def pygmentize(file)
|
22
22
|
pygmentize = SpawnProcess.new(%{pygmentize -f html -O encoding=utf-8 "#{file}"}, 3, 0.5)
|
23
23
|
pygmentize.run! do |p|
|
@@ -28,7 +28,7 @@ if(ENV['ARUBA_REPORT_DIR'])
|
|
28
28
|
IO.read(file)
|
29
29
|
else
|
30
30
|
STDERR.puts "\e[31m#{p.stderr} - is pygments installed?\e[0m"
|
31
|
-
exit
|
31
|
+
exit $CHILD_STATUS.exitstatus
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -61,15 +61,15 @@ if(ENV['ARUBA_REPORT_DIR'])
|
|
61
61
|
erb = ERB.new(template('main.erb'), nil, '-')
|
62
62
|
erb.result(binding)
|
63
63
|
end
|
64
|
-
|
64
|
+
|
65
65
|
def files
|
66
66
|
erb = ERB.new(template('files.erb'), nil, '-')
|
67
67
|
file = current_dir
|
68
68
|
erb.result(binding)
|
69
69
|
end
|
70
|
-
|
71
|
-
def again(erb,
|
72
|
-
|
70
|
+
|
71
|
+
def again(erb, erbout, file)
|
72
|
+
erbout.concat(erb.result(binding))
|
73
73
|
end
|
74
74
|
|
75
75
|
def children(dir)
|
@@ -119,4 +119,3 @@ if(ENV['ARUBA_REPORT_DIR'])
|
|
119
119
|
end
|
120
120
|
end
|
121
121
|
end
|
122
|
-
|
data/spec/aruba/api_spec.rb
CHANGED
@@ -12,7 +12,7 @@ describe Aruba::Api do
|
|
12
12
|
include Aruba::Api
|
13
13
|
|
14
14
|
def set_tag(tag_name, value)
|
15
|
-
self.instance_variable_set "@#{tag_name
|
15
|
+
self.instance_variable_set "@#{tag_name}", value
|
16
16
|
end
|
17
17
|
|
18
18
|
def announce_or_puts(*args)
|
@@ -25,7 +25,7 @@ describe Aruba::Api do
|
|
25
25
|
@file_size = 256
|
26
26
|
@file_path = File.join(@aruba.current_dir, @file_name)
|
27
27
|
|
28
|
-
(@aruba.dirs.length-1).times do |depth| #Ensure all parent dirs exists
|
28
|
+
(@aruba.dirs.length - 1).times do |depth| #Ensure all parent dirs exists
|
29
29
|
dir = File.join(*@aruba.dirs[0..depth])
|
30
30
|
Dir.mkdir(dir) unless File.exist?(dir)
|
31
31
|
end
|
@@ -40,26 +40,36 @@ describe Aruba::Api do
|
|
40
40
|
end
|
41
41
|
|
42
42
|
it "can be cleared" do
|
43
|
-
write_file(
|
43
|
+
write_file('test', 'test test test')
|
44
44
|
|
45
45
|
in_current_dir do
|
46
|
-
expect(
|
46
|
+
expect(File.exist?('test')).to be_truthy
|
47
47
|
end
|
48
48
|
|
49
49
|
clean_current_dir
|
50
50
|
|
51
51
|
in_current_dir do
|
52
|
-
expect(
|
52
|
+
expect(File.exist?('test')).to be_falsey
|
53
53
|
end
|
54
54
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
58
|
describe 'directories' do
|
59
|
+
before(:each) do
|
60
|
+
@directory_name = 'test_dir'
|
61
|
+
@directory_path = File.join(@aruba.current_dir, @directory_name)
|
62
|
+
end
|
63
|
+
|
64
|
+
context '#create_dir' do
|
65
|
+
it 'creates a directory' do
|
66
|
+
@aruba.create_dir @directory_name
|
67
|
+
expect(File.exist?(File.expand_path(@directory_path))).to be_truthy
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
59
71
|
context '#remove_dir' do
|
60
|
-
before
|
61
|
-
@directory_name = 'test_dir'
|
62
|
-
@directory_path = File.join(@aruba.current_dir, @directory_name)
|
72
|
+
before :each do
|
63
73
|
Dir.mkdir(@directory_path)
|
64
74
|
end
|
65
75
|
|
@@ -82,6 +92,57 @@ describe Aruba::Api do
|
|
82
92
|
end
|
83
93
|
|
84
94
|
describe 'files' do
|
95
|
+
context '#touch_file' do
|
96
|
+
it 'creates an empty file' do
|
97
|
+
@aruba.touch_file(@file_name)
|
98
|
+
expect(File.exist?(@file_path)).to eq true
|
99
|
+
expect(File.size(@file_path)).to eq 0
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'supports an unexisting directory in path' do
|
103
|
+
path = 'directory/test'
|
104
|
+
full_path = File.join(@aruba.current_dir, path)
|
105
|
+
@aruba.touch_file(path)
|
106
|
+
|
107
|
+
expect(File.exist?(full_path)).to eq true
|
108
|
+
end
|
109
|
+
|
110
|
+
it "works with ~ in path name" do
|
111
|
+
file_path = File.join('~', random_string)
|
112
|
+
|
113
|
+
with_env 'HOME' => File.expand_path(current_dir) do
|
114
|
+
@aruba.touch_file(file_path)
|
115
|
+
expect(File.exist?(File.expand_path(file_path))).to eq true
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
context '#absolute_path' do
|
121
|
+
it 'expands and returns path' do
|
122
|
+
expect(@aruba.absolute_path(@file_name)).to eq File.expand_path(@file_path)
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'removes "."' do
|
126
|
+
expect(@aruba.absolute_path('.')).to eq File.expand_path(current_dir)
|
127
|
+
end
|
128
|
+
|
129
|
+
it 'removes ".."' do
|
130
|
+
expect(@aruba.absolute_path('..')).to eq File.expand_path(File.join(current_dir, '..'))
|
131
|
+
end
|
132
|
+
|
133
|
+
it 'joins multiple arguments' do
|
134
|
+
expect(@aruba.absolute_path('path', @file_name)).to eq File.expand_path(File.join(current_dir, 'path', @file_name))
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
context '#write_file' do
|
139
|
+
it 'writes file' do
|
140
|
+
@aruba.write_file(@file_name, '')
|
141
|
+
|
142
|
+
expect(File.exist?(@file_path)).to eq true
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
85
146
|
context '#write_fixed_size_file' do
|
86
147
|
it "should write a fixed sized file" do
|
87
148
|
@aruba.write_fixed_size_file(@file_name, @file_size)
|
@@ -100,6 +161,7 @@ describe Aruba::Api do
|
|
100
161
|
end
|
101
162
|
end
|
102
163
|
end
|
164
|
+
|
103
165
|
context '#check_file_size' do
|
104
166
|
it "should check an existing file size" do
|
105
167
|
@aruba.write_fixed_size_file(@file_name, @file_size)
|
@@ -125,6 +187,7 @@ describe Aruba::Api do
|
|
125
187
|
expect { @aruba.check_file_size([[@file_name, @file_size + 1]]) }.to raise_error
|
126
188
|
end
|
127
189
|
end
|
190
|
+
|
128
191
|
context '#filesystem_permissions' do
|
129
192
|
before(:each) { File.open(@file_path, 'w') { |f| f << "" } }
|
130
193
|
|
@@ -211,8 +274,10 @@ describe Aruba::Api do
|
|
211
274
|
FileUtils.mkdir_p File.dirname( file_path )
|
212
275
|
File.open(file_path, 'w') { |f| f << "" }
|
213
276
|
|
214
|
-
@aruba.check_file_presence(
|
215
|
-
@aruba.check_file_presence(
|
277
|
+
@aruba.check_file_presence(file_name)
|
278
|
+
@aruba.check_file_presence([file_name])
|
279
|
+
@aruba.check_file_presence([file_name], true)
|
280
|
+
@aruba.check_file_presence(['asdf'], false)
|
216
281
|
end
|
217
282
|
|
218
283
|
it "should check existence using regex" do
|
@@ -251,25 +316,70 @@ describe Aruba::Api do
|
|
251
316
|
end
|
252
317
|
end
|
253
318
|
|
254
|
-
context "
|
255
|
-
before :
|
319
|
+
context "check file content" do
|
320
|
+
before :example do
|
256
321
|
@aruba.write_file(@file_name, "foo bar baz")
|
257
322
|
end
|
258
323
|
|
259
|
-
|
260
|
-
|
261
|
-
|
324
|
+
context "#check_binary_file_content" do
|
325
|
+
it "succeeds if file content matches" do
|
326
|
+
@aruba.write_file("fixture", "foo bar baz")
|
327
|
+
@aruba.check_binary_file_content(@file_name, "fixture")
|
328
|
+
@aruba.check_binary_file_content(@file_name, "fixture", true)
|
329
|
+
end
|
330
|
+
|
331
|
+
it "succeeds if file content does not match" do
|
332
|
+
@aruba.write_file("wrong_fixture", "bar")
|
333
|
+
@aruba.check_binary_file_content(@file_name, "wrong_fixture", false)
|
334
|
+
end
|
262
335
|
|
263
|
-
|
264
|
-
|
336
|
+
it "raises if file does not exist" do
|
337
|
+
expect{@aruba.check_binary_file_content(@file_name, "non_existing", false)}.to raise_error
|
338
|
+
end
|
265
339
|
end
|
266
340
|
|
267
|
-
|
268
|
-
|
341
|
+
context "#check_file_content" do
|
342
|
+
context "with regexp" do
|
343
|
+
let(:matching_content){/bar/}
|
344
|
+
let(:non_matching_content){/nothing/}
|
345
|
+
it "succeeds if file content matches" do
|
346
|
+
@aruba.check_file_content(@file_name, matching_content)
|
347
|
+
@aruba.check_file_content(@file_name, matching_content, true)
|
348
|
+
end
|
269
349
|
|
270
|
-
|
271
|
-
|
272
|
-
|
350
|
+
it "succeeds if file content does not match" do
|
351
|
+
@aruba.check_file_content(@file_name, non_matching_content, false)
|
352
|
+
end
|
353
|
+
|
354
|
+
it "works with ~ in path name" do
|
355
|
+
file_path = File.join('~', random_string)
|
356
|
+
|
357
|
+
with_env 'HOME' => File.expand_path(current_dir) do
|
358
|
+
@aruba.write_file(file_path, "foo bar baz")
|
359
|
+
@aruba.check_file_content(file_path, non_matching_content, false)
|
360
|
+
end
|
361
|
+
end
|
362
|
+
end
|
363
|
+
context "with string" do
|
364
|
+
let(:matching_content){"foo bar baz"}
|
365
|
+
let(:non_matching_content){"bar"}
|
366
|
+
it "succeeds if file content matches" do
|
367
|
+
@aruba.check_file_content(@file_name, matching_content)
|
368
|
+
@aruba.check_file_content(@file_name, matching_content, true)
|
369
|
+
end
|
370
|
+
|
371
|
+
it "succeeds if file content does not match" do
|
372
|
+
@aruba.check_file_content(@file_name, non_matching_content, false)
|
373
|
+
end
|
374
|
+
|
375
|
+
it "works with ~ in path name" do
|
376
|
+
file_path = File.join('~', random_string)
|
377
|
+
|
378
|
+
with_env 'HOME' => File.expand_path(current_dir) do
|
379
|
+
@aruba.write_file(file_path, "foo bar baz")
|
380
|
+
@aruba.check_file_content(file_path, non_matching_content, false)
|
381
|
+
end
|
382
|
+
end
|
273
383
|
end
|
274
384
|
end
|
275
385
|
end
|
@@ -301,8 +411,8 @@ describe Aruba::Api do
|
|
301
411
|
it "is successful when the inner expectations match" do
|
302
412
|
expect do
|
303
413
|
@aruba.with_file_content @file_name do |full_content|
|
304
|
-
expect(full_content).to match
|
305
|
-
expect(full_content).not_to match
|
414
|
+
expect(full_content).to match(/foo/)
|
415
|
+
expect(full_content).not_to match(/zoo/)
|
306
416
|
end
|
307
417
|
end . not_to raise_error
|
308
418
|
end
|
@@ -310,8 +420,8 @@ describe Aruba::Api do
|
|
310
420
|
it "raises RSpec::Expectations::ExpectationNotMetError when the inner expectations don't match" do
|
311
421
|
expect do
|
312
422
|
@aruba.with_file_content @file_name do |full_content|
|
313
|
-
expect(full_content).to match
|
314
|
-
expect(full_content).not_to match
|
423
|
+
expect(full_content).to match(/zoo/)
|
424
|
+
expect(full_content).not_to match(/foo/)
|
315
425
|
end
|
316
426
|
end . to raise_error RSpec::Expectations::ExpectationNotMetError
|
317
427
|
end
|
@@ -444,5 +554,4 @@ describe Aruba::Api do
|
|
444
554
|
expect(@aruba.all_output).not_to include("LONG_LONG_ENV_VARIABLE")
|
445
555
|
end
|
446
556
|
end
|
447
|
-
|
448
557
|
end # Aruba::Api
|
data/spec/aruba/jruby_spec.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'aruba/config'
|
3
3
|
require 'aruba/api'
|
4
|
-
include Aruba::Api
|
5
4
|
|
6
5
|
describe "Aruba JRuby Startup Helper" do
|
7
6
|
before(:all) do
|
@@ -9,29 +8,32 @@ describe "Aruba JRuby Startup Helper" do
|
|
9
8
|
end
|
10
9
|
before(:each) do
|
11
10
|
Aruba.config = Aruba::Config.new
|
11
|
+
|
12
12
|
@fake_env['JRUBY_OPTS'] = "--1.9"
|
13
13
|
@fake_env['JAVA_OPTS'] = "-Xdebug"
|
14
|
+
|
15
|
+
stub_const('ENV', @fake_env)
|
14
16
|
end
|
15
17
|
|
16
18
|
it 'configuration does not load when RUBY_PLATFORM is not java' do
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
stub_const('RUBY_PLATFORM', 'x86_64-chocolate')
|
20
|
+
|
21
|
+
load 'aruba/jruby.rb'
|
22
|
+
Aruba.config.hooks.execute :before_cmd, self
|
23
|
+
expect(ENV['JRUBY_OPTS']).to eq "--1.9"
|
24
|
+
expect(ENV['JAVA_OPTS']).to eq "-Xdebug"
|
23
25
|
end
|
24
26
|
|
25
27
|
it 'configuration loads for java and merges existing environment variables' do
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
28
|
+
stub_const('RUBY_PLATFORM', 'java')
|
29
|
+
|
30
|
+
rb_config = double('rb_config')
|
31
|
+
allow(rb_config).to receive(:[]).and_return('solaris')
|
32
|
+
stub_const 'RbConfig::CONFIG', rb_config
|
33
|
+
|
34
|
+
load 'aruba/jruby.rb'
|
35
|
+
Aruba.config.hooks.execute :before_cmd, self
|
36
|
+
expect(ENV['JRUBY_OPTS']).to eq "-X-C --1.9"
|
37
|
+
expect(ENV['JAVA_OPTS']).to eq "-d32 -Xdebug"
|
36
38
|
end
|
37
39
|
end
|