aruba 0.8.1 → 0.9.0.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/.travis.yml +3 -1
- data/Gemfile +13 -10
- data/History.md +25 -7
- data/README.md +6 -1
- data/Rakefile +16 -3
- data/aruba.gemspec +10 -2
- data/bin/aruba +7 -0
- data/cucumber.yml +11 -2
- data/features/api/command/extract_text.feature +97 -0
- data/features/api/command/unescape_text.feature +119 -0
- data/features/api/core/expand_path.feature +16 -0
- data/features/api/{cd.feature → filesystem/cd.feature} +2 -1
- data/features/api/filesystem/create_directory.feature +57 -0
- data/features/api/filesystem/disk_usage.feature +151 -0
- data/features/api/filesystem/does_exist.feature +62 -0
- data/features/api/filesystem/is_absolute.feature +48 -0
- data/features/api/filesystem/is_directory.feature +53 -0
- data/features/api/filesystem/is_file.feature +54 -0
- data/features/api/filesystem/is_relative.feature +48 -0
- data/features/cli/console.feature +52 -0
- data/features/configuration/console_history_file.feature +38 -0
- data/features/configuration/exit_timeout.feature +2 -1
- data/features/configuration/fixtures_path_prefix.feature +0 -1
- data/features/configuration/home_directory.feature +0 -1
- data/features/configuration/io_timeout.feature +0 -1
- data/features/configuration/keep_ansi.feature +1 -2
- data/features/configuration/log_level.feature +38 -0
- data/features/configuration/physical_block_size.feature +53 -0
- data/features/configuration/remove_ansi_escape_sequences.feature +38 -0
- data/features/configuration/root_directory.feature +0 -1
- data/features/configuration/working_directory.feature +2 -1
- data/features/fixtures/cli-app/README.md +5 -0
- data/features/fixtures/cli-app/lib/cli/app.rb +1 -1
- data/features/fixtures/cli-app/spec/spec_helper.rb +1 -2
- data/features/fixtures/cli-app/spec/support/aruba.rb +1 -0
- data/features/fixtures/empty-app/lib/cli/app.rb +1 -1
- data/features/fixtures/empty-app/spec/spec_helper.rb +1 -1
- data/features/step_definitions/aruba_dev_steps.rb +12 -1
- data/features/support/env.rb +1 -1
- data/lib/aruba/announcer.rb +1 -14
- data/lib/aruba/api.rb +6 -6
- data/lib/aruba/api/command.rb +74 -12
- data/lib/aruba/api/core.rb +18 -11
- data/lib/aruba/api/deprecated.rb +60 -72
- data/lib/aruba/api/filesystem.rb +41 -16
- data/lib/aruba/aruba_logger.rb +77 -0
- data/lib/aruba/aruba_path.rb +33 -0
- data/lib/aruba/basic_configuration.rb +2 -2
- data/lib/aruba/cli.rb +11 -0
- data/lib/aruba/config.rb +13 -3
- data/lib/aruba/config/jruby.rb +5 -2
- data/lib/aruba/console.rb +66 -0
- data/lib/aruba/console/help.rb +33 -0
- data/lib/aruba/contracts/is_power_of_two.rb +15 -0
- data/lib/aruba/cucumber.rb +27 -10
- data/lib/aruba/cucumber/hooks.rb +15 -8
- data/lib/aruba/disk_usage_calculator.rb +7 -0
- data/lib/aruba/file_size.rb +52 -0
- data/lib/aruba/in_process.rb +1 -1
- data/lib/aruba/jruby.rb +1 -1
- data/lib/aruba/matchers/command.rb +1 -1
- data/lib/aruba/matchers/directory.rb +1 -1
- data/lib/aruba/matchers/environment.rb +1 -1
- data/lib/aruba/matchers/file.rb +1 -1
- data/lib/aruba/matchers/path.rb +1 -1
- data/lib/aruba/matchers/path/match_path_pattern.rb +1 -1
- data/lib/aruba/matchers/rspec_matcher_include_regexp.rb +1 -1
- data/lib/aruba/platform.rb +14 -242
- data/lib/aruba/{creators → platforms}/aruba_file_creator.rb +3 -3
- data/lib/aruba/{creators → platforms}/aruba_fixed_size_file_creator.rb +2 -2
- data/lib/aruba/platforms/simple_table.rb +36 -0
- data/lib/aruba/platforms/unix_command_string.rb +24 -0
- data/lib/aruba/platforms/unix_environment_variables.rb +130 -0
- data/lib/aruba/platforms/unix_platform.rb +226 -0
- data/lib/aruba/platforms/unix_which.rb +83 -0
- data/lib/aruba/platforms/windows_command_string.rb +23 -0
- data/lib/aruba/platforms/windows_environment_variables.rb +83 -0
- data/lib/aruba/platforms/windows_platform.rb +39 -0
- data/lib/aruba/platforms/windows_which.rb +104 -0
- data/lib/aruba/process_monitor.rb +3 -3
- data/lib/aruba/processes/basic_process.rb +23 -3
- data/lib/aruba/processes/debug_process.rb +2 -2
- data/lib/aruba/processes/in_process.rb +1 -1
- data/lib/aruba/processes/spawn_process.rb +10 -4
- data/lib/aruba/reporting.rb +1 -1
- data/lib/aruba/rspec.rb +8 -6
- data/lib/aruba/runtime.rb +8 -5
- data/lib/aruba/version.rb +1 -1
- data/spec/aruba/api_spec.rb +25 -23
- data/spec/aruba/aruba_path_spec.rb +37 -0
- data/spec/aruba/jruby_spec.rb +1 -1
- data/spec/aruba/matchers/file_spec.rb +2 -2
- data/spec/aruba/matchers/path_spec.rb +3 -3
- data/spec/aruba/platform/simple_table_spec.rb +23 -0
- data/spec/aruba/platform/windows_environment_variables_spec.rb +500 -0
- data/spec/aruba/spawn_process_spec.rb +3 -1
- metadata +90 -12
- data/lib/aruba/contracts/is_a.rb +0 -21
- data/lib/aruba/environment.rb +0 -121
data/lib/aruba/version.rb
CHANGED
data/spec/aruba/api_spec.rb
CHANGED
@@ -32,7 +32,7 @@ describe Aruba::Api do
|
|
32
32
|
|
33
33
|
context 'when file exist' do
|
34
34
|
before :each do
|
35
|
-
Aruba
|
35
|
+
Aruba.platform.write_file(path, '')
|
36
36
|
end
|
37
37
|
|
38
38
|
it { expect(all_paths).to include expand_path(name) }
|
@@ -43,7 +43,7 @@ describe Aruba::Api do
|
|
43
43
|
let(:path) { File.join(@aruba.aruba.current_directory, name) }
|
44
44
|
|
45
45
|
before :each do
|
46
|
-
Aruba
|
46
|
+
Aruba.platform.mkdir(path)
|
47
47
|
end
|
48
48
|
|
49
49
|
it { expect(all_paths).to include expand_path(name) }
|
@@ -60,7 +60,7 @@ describe Aruba::Api do
|
|
60
60
|
|
61
61
|
context 'when file exist' do
|
62
62
|
before :each do
|
63
|
-
Aruba
|
63
|
+
Aruba.platform.write_file(path, '')
|
64
64
|
end
|
65
65
|
|
66
66
|
it { expect(all_files).to include expand_path(name) }
|
@@ -71,7 +71,7 @@ describe Aruba::Api do
|
|
71
71
|
let(:path) { File.join(@aruba.aruba.current_directory, name) }
|
72
72
|
|
73
73
|
before :each do
|
74
|
-
Aruba
|
74
|
+
Aruba.platform.mkdir(path)
|
75
75
|
end
|
76
76
|
|
77
77
|
it { expect(all_files).to eq [] }
|
@@ -88,7 +88,7 @@ describe Aruba::Api do
|
|
88
88
|
|
89
89
|
context 'when file exist' do
|
90
90
|
before :each do
|
91
|
-
Aruba
|
91
|
+
Aruba.platform.write_file(path, '')
|
92
92
|
end
|
93
93
|
|
94
94
|
it { expect(all_directories).to eq [] }
|
@@ -99,7 +99,7 @@ describe Aruba::Api do
|
|
99
99
|
let(:path) { File.join(@aruba.aruba.current_directory, name) }
|
100
100
|
|
101
101
|
before :each do
|
102
|
-
Aruba
|
102
|
+
Aruba.platform.mkdir(path)
|
103
103
|
end
|
104
104
|
|
105
105
|
it { expect(all_directories).to include expand_path(name) }
|
@@ -170,7 +170,7 @@ describe Aruba::Api do
|
|
170
170
|
let(:name) { 'test.d' }
|
171
171
|
|
172
172
|
before :each do
|
173
|
-
Array(path).each { |p| Aruba
|
173
|
+
Array(path).each { |p| Aruba.platform.mkdir p }
|
174
174
|
end
|
175
175
|
|
176
176
|
it { expect { @aruba.read(name) }.to raise_error ArgumentError }
|
@@ -206,11 +206,11 @@ describe Aruba::Api do
|
|
206
206
|
|
207
207
|
context 'when directory' do
|
208
208
|
before :each do
|
209
|
-
Array(path).each { |p| Aruba
|
209
|
+
Array(path).each { |p| Aruba.platform.mkdir p }
|
210
210
|
end
|
211
211
|
|
212
212
|
before :each do
|
213
|
-
Array(content).each { |p| Aruba
|
213
|
+
Array(content).each { |p| Aruba.platform.mkdir File.join(path, p) }
|
214
214
|
end
|
215
215
|
|
216
216
|
context 'when has subdirectories' do
|
@@ -298,7 +298,7 @@ describe Aruba::Api do
|
|
298
298
|
|
299
299
|
context 'when exists' do
|
300
300
|
before :each do
|
301
|
-
Array(path).each { |p| Aruba
|
301
|
+
Array(path).each { |p| Aruba.platform.mkdir p }
|
302
302
|
end
|
303
303
|
|
304
304
|
before :each do
|
@@ -396,7 +396,7 @@ describe Aruba::Api do
|
|
396
396
|
let(:path) { Array(name).map { |p| File.join(@aruba.aruba.current_directory, p) } }
|
397
397
|
|
398
398
|
context 'when exist' do
|
399
|
-
before(:each) { Array(path).each { |p| Aruba
|
399
|
+
before(:each) { Array(path).each { |p| Aruba.platform.mkdir p } }
|
400
400
|
|
401
401
|
before :each do
|
402
402
|
@aruba.touch(name, options)
|
@@ -446,7 +446,7 @@ describe Aruba::Api do
|
|
446
446
|
|
447
447
|
context 'when exists' do
|
448
448
|
before :each do
|
449
|
-
Aruba
|
449
|
+
Aruba.platform.write_file(path, '')
|
450
450
|
end
|
451
451
|
|
452
452
|
it { expect(@aruba).to be_exist(name) }
|
@@ -463,7 +463,7 @@ describe Aruba::Api do
|
|
463
463
|
|
464
464
|
context 'when exists' do
|
465
465
|
before :each do
|
466
|
-
Aruba
|
466
|
+
Aruba.platform.mkdir(path)
|
467
467
|
end
|
468
468
|
|
469
469
|
it { expect(@aruba).to be_exist(name) }
|
@@ -482,7 +482,7 @@ describe Aruba::Api do
|
|
482
482
|
|
483
483
|
context 'when exists' do
|
484
484
|
before :each do
|
485
|
-
Aruba
|
485
|
+
Aruba.platform.write_file(path, '')
|
486
486
|
end
|
487
487
|
|
488
488
|
it { expect(@aruba).to be_file(name) }
|
@@ -499,7 +499,7 @@ describe Aruba::Api do
|
|
499
499
|
|
500
500
|
context 'when exists' do
|
501
501
|
before :each do
|
502
|
-
Aruba
|
502
|
+
Aruba.platform.mkdir(path)
|
503
503
|
end
|
504
504
|
|
505
505
|
it { expect(@aruba).not_to be_file(name) }
|
@@ -518,7 +518,7 @@ describe Aruba::Api do
|
|
518
518
|
|
519
519
|
context 'when exists' do
|
520
520
|
before :each do
|
521
|
-
Aruba
|
521
|
+
Aruba.platform.write_file(path, '')
|
522
522
|
end
|
523
523
|
|
524
524
|
it { expect(@aruba).not_to be_directory(name) }
|
@@ -535,7 +535,7 @@ describe Aruba::Api do
|
|
535
535
|
|
536
536
|
context 'when exists' do
|
537
537
|
before :each do
|
538
|
-
Aruba
|
538
|
+
Aruba.platform.mkdir(path)
|
539
539
|
end
|
540
540
|
|
541
541
|
it { expect(@aruba).to be_directory(name) }
|
@@ -589,7 +589,7 @@ describe Aruba::Api do
|
|
589
589
|
let(:destination) { 'dst.d' }
|
590
590
|
|
591
591
|
before :each do
|
592
|
-
Aruba
|
592
|
+
Aruba.platform.mkdir(File.join(@aruba.aruba.current_directory, source))
|
593
593
|
end
|
594
594
|
|
595
595
|
before :each do
|
@@ -619,7 +619,7 @@ describe Aruba::Api do
|
|
619
619
|
let(:destination_files) { source.map { |s| File.join(destination, s) } }
|
620
620
|
|
621
621
|
before :each do
|
622
|
-
Aruba
|
622
|
+
Aruba.platform.mkdir(File.join(@aruba.aruba.current_directory, destination))
|
623
623
|
end
|
624
624
|
|
625
625
|
before :each do
|
@@ -714,6 +714,8 @@ describe Aruba::Api do
|
|
714
714
|
|
715
715
|
before :each do
|
716
716
|
allow(config).to receive(:fixtures_path_prefix).and_return('%')
|
717
|
+
allow(config).to receive(:root_directory).and_return aruba.config.root_directory
|
718
|
+
allow(config).to receive(:working_directory).and_return aruba.config.working_directory
|
717
719
|
end
|
718
720
|
|
719
721
|
before :each do
|
@@ -901,7 +903,7 @@ describe Aruba::Api do
|
|
901
903
|
file_name = 'nested/dir/hello_world.txt'
|
902
904
|
file_path = File.join(@aruba.aruba.current_directory, file_name)
|
903
905
|
|
904
|
-
Aruba
|
906
|
+
Aruba.platform.mkdir(File.dirname(file_path))
|
905
907
|
File.open(file_path, 'w') { |f| f << "" }
|
906
908
|
|
907
909
|
@aruba.check_file_presence(file_name)
|
@@ -914,7 +916,7 @@ describe Aruba::Api do
|
|
914
916
|
file_name = 'nested/dir/hello_world.txt'
|
915
917
|
file_path = File.join(@aruba.aruba.current_directory, file_name)
|
916
918
|
|
917
|
-
Aruba
|
919
|
+
Aruba.platform.mkdir(File.dirname(file_path))
|
918
920
|
File.open(file_path, 'w') { |f| f << "" }
|
919
921
|
|
920
922
|
@aruba.check_file_presence([ /test123/ ], false )
|
@@ -927,7 +929,7 @@ describe Aruba::Api do
|
|
927
929
|
file_name = 'nested/dir/hello_world.txt'
|
928
930
|
file_path = File.join(@aruba.aruba.current_directory, file_name)
|
929
931
|
|
930
|
-
Aruba
|
932
|
+
Aruba.platform.mkdir(File.dirname(file_path))
|
931
933
|
File.open(file_path, 'w') { |f| f << "" }
|
932
934
|
|
933
935
|
@aruba.check_file_presence([ file_name, /nested/ ], true )
|
@@ -938,7 +940,7 @@ describe Aruba::Api do
|
|
938
940
|
file_path = File.join('~', random_string)
|
939
941
|
|
940
942
|
@aruba.with_environment 'HOME' => File.expand_path(@aruba.aruba.current_directory) do
|
941
|
-
Aruba
|
943
|
+
Aruba.platform.mkdir(File.dirname(File.expand_path(file_path)))
|
942
944
|
File.open(File.expand_path(file_path), 'w') { |f| f << "" }
|
943
945
|
|
944
946
|
@aruba.check_file_presence( [ file_path ], true )
|
@@ -63,4 +63,41 @@ RSpec.describe Aruba::ArubaPath do
|
|
63
63
|
it { expect(path[0..1]).to eq 'pa' }
|
64
64
|
end
|
65
65
|
end
|
66
|
+
|
67
|
+
describe '#depth' do
|
68
|
+
context 'when relative path' do
|
69
|
+
it { expect(path.depth).to eq 3 }
|
70
|
+
end
|
71
|
+
|
72
|
+
context 'when absolute path' do
|
73
|
+
let(:new_path) { '/path/to/dir' }
|
74
|
+
it { expect(path.depth).to eq 3 }
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe '#end_with?' do
|
79
|
+
it { expect(path).to be_end_with 'dir' }
|
80
|
+
end
|
81
|
+
|
82
|
+
describe '#start_with?' do
|
83
|
+
it { expect(path).to be_start_with 'path/to' }
|
84
|
+
end
|
85
|
+
|
86
|
+
describe '#relative?' do
|
87
|
+
it { expect(path).to be_relative }
|
88
|
+
end
|
89
|
+
|
90
|
+
describe '#absolute?' do
|
91
|
+
let(:new_path) { '/path/to/dir' }
|
92
|
+
it { expect(path).to be_absolute }
|
93
|
+
end
|
94
|
+
|
95
|
+
describe '#blocks' do
|
96
|
+
let(:new_path) { expand_path('path/to/file') }
|
97
|
+
|
98
|
+
before(:each) { FileUtils.mkdir_p File.dirname(new_path) }
|
99
|
+
before(:each) { File.open(new_path, 'w') { |f| f.print 'a' } }
|
100
|
+
|
101
|
+
it { expect(path.blocks).to be > 0 }
|
102
|
+
end
|
66
103
|
end
|
data/spec/aruba/jruby_spec.rb
CHANGED
@@ -49,7 +49,7 @@ describe "Aruba JRuby Startup Helper" do
|
|
49
49
|
Aruba.config.before :command, self
|
50
50
|
end
|
51
51
|
|
52
|
-
it { expect(ENV['JRUBY_OPTS']).to eq '-X-C --1.9' }
|
52
|
+
it { expect(ENV['JRUBY_OPTS']).to eq '--dev -X-C --1.9' }
|
53
53
|
it { expect(ENV['JAVA_OPTS']).to eq '-d32 -Xdebug' }
|
54
54
|
end
|
55
55
|
end
|
@@ -38,7 +38,7 @@ RSpec.describe 'File Matchers' do
|
|
38
38
|
describe 'to_have_file_content' do
|
39
39
|
context 'when file exists' do
|
40
40
|
before :each do
|
41
|
-
Aruba
|
41
|
+
Aruba.platform.write_file(@file_path, 'aba')
|
42
42
|
end
|
43
43
|
|
44
44
|
context 'and file content is exactly equal string ' do
|
@@ -108,7 +108,7 @@ RSpec.describe 'File Matchers' do
|
|
108
108
|
describe 'to_have_file_size' do
|
109
109
|
context 'when file exists' do
|
110
110
|
before :each do
|
111
|
-
Aruba
|
111
|
+
Aruba.platform.write_file(@file_path, '')
|
112
112
|
end
|
113
113
|
|
114
114
|
context 'and file size is equal' do
|
@@ -14,7 +14,7 @@ RSpec.describe 'Path Matchers' do
|
|
14
14
|
context 'when pattern is string' do
|
15
15
|
context 'when there is file which matches path pattern' do
|
16
16
|
before :each do
|
17
|
-
Aruba
|
17
|
+
Aruba.platform.write_file(@file_path, '')
|
18
18
|
end
|
19
19
|
|
20
20
|
it { expect(all_paths).to match_path_pattern(expand_path(@file_name)) }
|
@@ -28,7 +28,7 @@ RSpec.describe 'Path Matchers' do
|
|
28
28
|
context 'when pattern is regex' do
|
29
29
|
context 'when there is file which matches path pattern' do
|
30
30
|
before :each do
|
31
|
-
Aruba
|
31
|
+
Aruba.platform.write_file(@file_path, '')
|
32
32
|
end
|
33
33
|
|
34
34
|
it { expect(all_paths).to match_path_pattern(/test/) }
|
@@ -57,7 +57,7 @@ RSpec.describe 'Path Matchers' do
|
|
57
57
|
context 'when file' do
|
58
58
|
context 'exists' do
|
59
59
|
before :each do
|
60
|
-
Aruba
|
60
|
+
Aruba.platform.write_file(@file_path, '')
|
61
61
|
end
|
62
62
|
|
63
63
|
it { expect(@file_name).to be_an_existing_path }
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'aruba/platform'
|
3
|
+
|
4
|
+
RSpec.describe '.simple_table' do
|
5
|
+
context 'when valid hash' do
|
6
|
+
let(:hash) do
|
7
|
+
{
|
8
|
+
:key1 => 'value',
|
9
|
+
:key2 => 'value'
|
10
|
+
}
|
11
|
+
end
|
12
|
+
let(:rows) { ['# key1 => value', '# key2 => value'] }
|
13
|
+
|
14
|
+
it { expect(Aruba.platform.simple_table(hash)).to eq rows }
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'when empty hash' do
|
18
|
+
let(:hash) { {} }
|
19
|
+
let(:rows) { [] }
|
20
|
+
|
21
|
+
it { expect(Aruba.platform.simple_table(hash)).to eq rows }
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,500 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'aruba/platforms/windows_environment_variables'
|
3
|
+
|
4
|
+
RSpec.describe Aruba::Platforms::WindowsEnvironmentVariables do
|
5
|
+
subject(:environment) { described_class.new(old_environment) }
|
6
|
+
|
7
|
+
describe '#[]' do
|
8
|
+
context 'when environment contains uppercase variable' do
|
9
|
+
let(:old_environment) { { 'MY_VARIABLE' => '1' } }
|
10
|
+
|
11
|
+
context 'when uppercase key is given' do
|
12
|
+
let(:variable) { 'MY_VARIABLE' }
|
13
|
+
|
14
|
+
it { expect(environment[variable]).to eq '1' }
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'when lowercase key is given' do
|
18
|
+
let(:variable) { 'my_variable' }
|
19
|
+
|
20
|
+
it { expect(environment[variable]).to eq '1' }
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'when mixed case key is given' do
|
24
|
+
let(:variable) { 'MY_variable' }
|
25
|
+
|
26
|
+
it { expect(environment[variable]).to eq '1' }
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'when unknown variable is given' do
|
30
|
+
let(:variable) { 'unknown' }
|
31
|
+
|
32
|
+
it { expect(environment[variable]).to eq nil }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'when environment contains lowercase variable' do
|
37
|
+
let(:old_environment) { { 'my_variable' => '1' } }
|
38
|
+
|
39
|
+
context 'when uppercase key is given' do
|
40
|
+
let(:variable) { 'MY_VARIABLE' }
|
41
|
+
|
42
|
+
it { expect(environment[variable]).to eq '1' }
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'when lowercase key is given' do
|
46
|
+
let(:variable) { 'my_variable' }
|
47
|
+
|
48
|
+
it { expect(environment[variable]).to eq '1' }
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'when mixed case key is given' do
|
52
|
+
let(:variable) { 'MY_variable' }
|
53
|
+
|
54
|
+
it { expect(environment[variable]).to eq '1' }
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'when unknown variable is given' do
|
58
|
+
let(:variable) { 'unknown' }
|
59
|
+
|
60
|
+
it { expect(environment[variable]).to eq nil }
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context 'when environment contains mixed case variable' do
|
65
|
+
let(:old_environment) { { 'MY_variable' => '1' } }
|
66
|
+
|
67
|
+
context 'when uppercase key is given' do
|
68
|
+
let(:variable) { 'MY_VARIABLE' }
|
69
|
+
|
70
|
+
it { expect(environment[variable]).to eq '1' }
|
71
|
+
end
|
72
|
+
|
73
|
+
context 'when lowercase key is given' do
|
74
|
+
let(:variable) { 'my_variable' }
|
75
|
+
|
76
|
+
it { expect(environment[variable]).to eq '1' }
|
77
|
+
end
|
78
|
+
|
79
|
+
context 'when mixed case key is given' do
|
80
|
+
let(:variable) { 'MY_variable' }
|
81
|
+
|
82
|
+
it { expect(environment[variable]).to eq '1' }
|
83
|
+
end
|
84
|
+
|
85
|
+
context 'when unknown variable is given' do
|
86
|
+
let(:variable) { 'unknown' }
|
87
|
+
|
88
|
+
it { expect(environment[variable]).to eq nil }
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe '#fetch' do
|
94
|
+
context 'when environment contains uppercase variable' do
|
95
|
+
let(:old_environment) { { 'MY_VARIABLE' => '1' } }
|
96
|
+
|
97
|
+
context 'when uppercase key is given' do
|
98
|
+
let(:variable) { 'MY_VARIABLE' }
|
99
|
+
|
100
|
+
it { expect(environment.fetch(variable)).to eq '1' }
|
101
|
+
end
|
102
|
+
|
103
|
+
context 'when lowercase key is given' do
|
104
|
+
let(:variable) { 'my_variable' }
|
105
|
+
|
106
|
+
it { expect(environment.fetch(variable)).to eq '1' }
|
107
|
+
end
|
108
|
+
|
109
|
+
context 'when mixed case key is given' do
|
110
|
+
let(:variable) { 'MY_variable' }
|
111
|
+
|
112
|
+
it { expect(environment.fetch(variable)).to eq '1' }
|
113
|
+
end
|
114
|
+
|
115
|
+
context 'when unknown variable is given' do
|
116
|
+
let(:variable) { 'unknown' }
|
117
|
+
|
118
|
+
context 'and no default is given' do
|
119
|
+
if RUBY_VERSION < '1.9'
|
120
|
+
it { expect { environment.fetch(variable) }.to raise_error IndexError }
|
121
|
+
else
|
122
|
+
unless defined? KeyError
|
123
|
+
class KeyError < StandardError; end
|
124
|
+
end
|
125
|
+
|
126
|
+
it { expect { environment.fetch(variable) }.to raise_error KeyError }
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
context 'and default is given' do
|
131
|
+
let(:default_value) { 'default_value' }
|
132
|
+
|
133
|
+
it { expect(environment.fetch(variable, default_value)).to eq default_value }
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
context 'when environment contains lowercase variable' do
|
139
|
+
let(:old_environment) { { 'my_variable' => '1' } }
|
140
|
+
|
141
|
+
context 'when uppercase key is given' do
|
142
|
+
let(:variable) { 'MY_VARIABLE' }
|
143
|
+
|
144
|
+
it { expect(environment.fetch(variable)).to eq '1' }
|
145
|
+
end
|
146
|
+
|
147
|
+
context 'when lowercase key is given' do
|
148
|
+
let(:variable) { 'my_variable' }
|
149
|
+
|
150
|
+
it { expect(environment.fetch(variable)).to eq '1' }
|
151
|
+
end
|
152
|
+
|
153
|
+
context 'when mixed case key is given' do
|
154
|
+
let(:variable) { 'MY_variable' }
|
155
|
+
|
156
|
+
it { expect(environment.fetch(variable)).to eq '1' }
|
157
|
+
end
|
158
|
+
|
159
|
+
context 'when unknown variable is given' do
|
160
|
+
let(:variable) { 'unknown' }
|
161
|
+
|
162
|
+
context 'and no default is given' do
|
163
|
+
if RUBY_VERSION < '1.9'
|
164
|
+
it { expect { environment.fetch(variable) }.to raise_error IndexError }
|
165
|
+
else
|
166
|
+
unless defined? KeyError
|
167
|
+
class KeyError < StandardError; end
|
168
|
+
end
|
169
|
+
|
170
|
+
it { expect { environment.fetch(variable) }.to raise_error KeyError }
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
context 'and default is given' do
|
175
|
+
let(:default_value) { 'default_value' }
|
176
|
+
|
177
|
+
it { expect(environment.fetch(variable, default_value)).to eq default_value }
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
context 'when environment contains mixed case variable' do
|
183
|
+
let(:old_environment) { { 'MY_variable' => '1' } }
|
184
|
+
|
185
|
+
context 'when uppercase key is given' do
|
186
|
+
let(:variable) { 'MY_VARIABLE' }
|
187
|
+
|
188
|
+
it { expect(environment.fetch(variable)).to eq '1' }
|
189
|
+
end
|
190
|
+
|
191
|
+
context 'when lowercase key is given' do
|
192
|
+
let(:variable) { 'my_variable' }
|
193
|
+
|
194
|
+
it { expect(environment.fetch(variable)).to eq '1' }
|
195
|
+
end
|
196
|
+
|
197
|
+
context 'when mixed case key is given' do
|
198
|
+
let(:variable) { 'MY_variable' }
|
199
|
+
|
200
|
+
it { expect(environment.fetch(variable)).to eq '1' }
|
201
|
+
end
|
202
|
+
|
203
|
+
context 'when unknown variable is given' do
|
204
|
+
let(:variable) { 'unknown' }
|
205
|
+
|
206
|
+
context 'and no default is given' do
|
207
|
+
if RUBY_VERSION < '1.9'
|
208
|
+
it { expect { environment.fetch(variable) }.to raise_error IndexError }
|
209
|
+
else
|
210
|
+
unless defined? KeyError
|
211
|
+
class KeyError < StandardError; end
|
212
|
+
end
|
213
|
+
|
214
|
+
it { expect { environment.fetch(variable) }.to raise_error KeyError }
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
context 'and default is given' do
|
219
|
+
let(:default_value) { 'default_value' }
|
220
|
+
|
221
|
+
it { expect(environment.fetch(variable, default_value)).to eq default_value }
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
describe '#key?' do
|
228
|
+
context 'when environment contains uppercase variable' do
|
229
|
+
let(:old_environment) { { 'MY_VARIABLE' => '1' } }
|
230
|
+
|
231
|
+
context 'when uppercase key is given' do
|
232
|
+
let(:variable) { 'MY_VARIABLE' }
|
233
|
+
|
234
|
+
it { expect(environment).to be_key variable }
|
235
|
+
end
|
236
|
+
|
237
|
+
context 'when lowercase key is given' do
|
238
|
+
let(:variable) { 'my_variable' }
|
239
|
+
|
240
|
+
it { expect(environment).to be_key variable }
|
241
|
+
end
|
242
|
+
|
243
|
+
context 'when mixed case key is given' do
|
244
|
+
let(:variable) { 'MY_variable' }
|
245
|
+
|
246
|
+
it { expect(environment).to be_key variable }
|
247
|
+
end
|
248
|
+
|
249
|
+
context 'when unknown variable is given' do
|
250
|
+
let(:variable) { 'unknown' }
|
251
|
+
|
252
|
+
it { expect(environment).not_to be_key variable }
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
context 'when environment contains lowercase variable' do
|
257
|
+
let(:old_environment) { { 'my_variable' => '1' } }
|
258
|
+
|
259
|
+
context 'when uppercase key is given' do
|
260
|
+
let(:variable) { 'MY_VARIABLE' }
|
261
|
+
|
262
|
+
it { expect(environment).to be_key variable }
|
263
|
+
end
|
264
|
+
|
265
|
+
context 'when lowercase key is given' do
|
266
|
+
let(:variable) { 'my_variable' }
|
267
|
+
|
268
|
+
it { expect(environment).to be_key variable }
|
269
|
+
end
|
270
|
+
|
271
|
+
context 'when mixed case key is given' do
|
272
|
+
let(:variable) { 'MY_variable' }
|
273
|
+
|
274
|
+
it { expect(environment).to be_key variable }
|
275
|
+
end
|
276
|
+
|
277
|
+
context 'when unknown variable is given' do
|
278
|
+
let(:variable) { 'unknown' }
|
279
|
+
|
280
|
+
it { expect(environment).not_to be_key variable }
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
284
|
+
context 'when environment contains mixed case variable' do
|
285
|
+
let(:old_environment) { { 'MY_variable' => '1' } }
|
286
|
+
|
287
|
+
context 'when uppercase key is given' do
|
288
|
+
let(:variable) { 'MY_VARIABLE' }
|
289
|
+
|
290
|
+
it { expect(environment).to be_key variable }
|
291
|
+
end
|
292
|
+
|
293
|
+
context 'when lowercase key is given' do
|
294
|
+
let(:variable) { 'my_variable' }
|
295
|
+
|
296
|
+
it { expect(environment).to be_key variable }
|
297
|
+
end
|
298
|
+
|
299
|
+
context 'when mixed case key is given' do
|
300
|
+
let(:variable) { 'MY_variable' }
|
301
|
+
|
302
|
+
it { expect(environment).to be_key variable }
|
303
|
+
end
|
304
|
+
|
305
|
+
context 'when unknown variable is given' do
|
306
|
+
let(:variable) { 'unknown' }
|
307
|
+
|
308
|
+
it { expect(environment).not_to be_key variable }
|
309
|
+
end
|
310
|
+
end
|
311
|
+
end
|
312
|
+
|
313
|
+
describe '#append' do
|
314
|
+
let(:value) { 'NEW_VALUE' }
|
315
|
+
|
316
|
+
context 'when environment contains uppercase variable' do
|
317
|
+
let(:old_environment) { { 'MY_VARIABLE' => '1' } }
|
318
|
+
|
319
|
+
before(:each) { environment.append(variable, value) }
|
320
|
+
|
321
|
+
context 'when uppercase key is given' do
|
322
|
+
let(:variable) { 'MY_VARIABLE' }
|
323
|
+
|
324
|
+
it { expect(environment[variable]).to eq '1NEW_VALUE' }
|
325
|
+
end
|
326
|
+
|
327
|
+
context 'when lowercase key is given' do
|
328
|
+
let(:variable) { 'my_variable' }
|
329
|
+
|
330
|
+
it { expect(environment[variable]).to eq '1NEW_VALUE' }
|
331
|
+
end
|
332
|
+
|
333
|
+
context 'when mixed case key is given' do
|
334
|
+
let(:variable) { 'MY_variable' }
|
335
|
+
|
336
|
+
it { expect(environment[variable]).to eq '1NEW_VALUE' }
|
337
|
+
end
|
338
|
+
|
339
|
+
context 'when unknown variable is given' do
|
340
|
+
let(:variable) { 'unknown' }
|
341
|
+
|
342
|
+
it { expect(environment[variable]).to eq 'NEW_VALUE' }
|
343
|
+
end
|
344
|
+
end
|
345
|
+
|
346
|
+
context 'when environment contains lowercase variable' do
|
347
|
+
let(:old_environment) { { 'my_variable' => '1' } }
|
348
|
+
|
349
|
+
before(:each) { environment.append(variable, value) }
|
350
|
+
|
351
|
+
context 'when uppercase key is given' do
|
352
|
+
let(:variable) { 'MY_VARIABLE' }
|
353
|
+
|
354
|
+
it { expect(environment[variable]).to eq '1NEW_VALUE' }
|
355
|
+
end
|
356
|
+
|
357
|
+
context 'when lowercase key is given' do
|
358
|
+
let(:variable) { 'my_variable' }
|
359
|
+
|
360
|
+
it { expect(environment[variable]).to eq '1NEW_VALUE' }
|
361
|
+
end
|
362
|
+
|
363
|
+
context 'when mixed case key is given' do
|
364
|
+
let(:variable) { 'MY_variable' }
|
365
|
+
|
366
|
+
it { expect(environment[variable]).to eq '1NEW_VALUE' }
|
367
|
+
end
|
368
|
+
|
369
|
+
context 'when unknown variable is given' do
|
370
|
+
let(:variable) { 'unknown' }
|
371
|
+
|
372
|
+
it { expect(environment[variable]).to eq 'NEW_VALUE' }
|
373
|
+
end
|
374
|
+
end
|
375
|
+
|
376
|
+
context 'when environment contains mixed case variable' do
|
377
|
+
let(:old_environment) { { 'MY_variable' => '1' } }
|
378
|
+
|
379
|
+
before(:each) { environment.append(variable, value) }
|
380
|
+
|
381
|
+
context 'when uppercase key is given' do
|
382
|
+
let(:variable) { 'MY_VARIABLE' }
|
383
|
+
|
384
|
+
it { expect(environment[variable]).to eq '1NEW_VALUE' }
|
385
|
+
end
|
386
|
+
|
387
|
+
context 'when lowercase key is given' do
|
388
|
+
let(:variable) { 'my_variable' }
|
389
|
+
|
390
|
+
it { expect(environment[variable]).to eq '1NEW_VALUE' }
|
391
|
+
end
|
392
|
+
|
393
|
+
context 'when mixed case key is given' do
|
394
|
+
let(:variable) { 'MY_variable' }
|
395
|
+
|
396
|
+
it { expect(environment[variable]).to eq '1NEW_VALUE' }
|
397
|
+
end
|
398
|
+
|
399
|
+
context 'when unknown variable is given' do
|
400
|
+
let(:variable) { 'unknown' }
|
401
|
+
|
402
|
+
it { expect(environment[variable]).to eq 'NEW_VALUE' }
|
403
|
+
end
|
404
|
+
end
|
405
|
+
end
|
406
|
+
|
407
|
+
describe '#prepend' do
|
408
|
+
let(:value) { 'NEW_VALUE' }
|
409
|
+
|
410
|
+
context 'when environment contains uppercase variable' do
|
411
|
+
let(:old_environment) { { 'MY_VARIABLE' => '1' } }
|
412
|
+
|
413
|
+
before(:each) { environment.prepend(variable, value) }
|
414
|
+
|
415
|
+
context 'when uppercase key is given' do
|
416
|
+
let(:variable) { 'MY_VARIABLE' }
|
417
|
+
|
418
|
+
it { expect(environment[variable]).to eq 'NEW_VALUE1' }
|
419
|
+
end
|
420
|
+
|
421
|
+
context 'when lowercase key is given' do
|
422
|
+
let(:variable) { 'my_variable' }
|
423
|
+
|
424
|
+
it { expect(environment[variable]).to eq 'NEW_VALUE1' }
|
425
|
+
end
|
426
|
+
|
427
|
+
context 'when mixed case key is given' do
|
428
|
+
let(:variable) { 'MY_variable' }
|
429
|
+
|
430
|
+
it { expect(environment[variable]).to eq 'NEW_VALUE1' }
|
431
|
+
end
|
432
|
+
|
433
|
+
context 'when unknown variable is given' do
|
434
|
+
let(:variable) { 'unknown' }
|
435
|
+
|
436
|
+
it { expect(environment[variable]).to eq 'NEW_VALUE' }
|
437
|
+
end
|
438
|
+
end
|
439
|
+
|
440
|
+
context 'when environment contains lowercase variable' do
|
441
|
+
let(:old_environment) { { 'my_variable' => '1' } }
|
442
|
+
|
443
|
+
before(:each) { environment.prepend(variable, value) }
|
444
|
+
|
445
|
+
context 'when uppercase key is given' do
|
446
|
+
let(:variable) { 'MY_VARIABLE' }
|
447
|
+
|
448
|
+
it { expect(environment[variable]).to eq 'NEW_VALUE1' }
|
449
|
+
end
|
450
|
+
|
451
|
+
context 'when lowercase key is given' do
|
452
|
+
let(:variable) { 'my_variable' }
|
453
|
+
|
454
|
+
it { expect(environment[variable]).to eq 'NEW_VALUE1' }
|
455
|
+
end
|
456
|
+
|
457
|
+
context 'when mixed case key is given' do
|
458
|
+
let(:variable) { 'MY_variable' }
|
459
|
+
|
460
|
+
it { expect(environment[variable]).to eq 'NEW_VALUE1' }
|
461
|
+
end
|
462
|
+
|
463
|
+
context 'when unknown variable is given' do
|
464
|
+
let(:variable) { 'unknown' }
|
465
|
+
|
466
|
+
it { expect(environment[variable]).to eq 'NEW_VALUE' }
|
467
|
+
end
|
468
|
+
end
|
469
|
+
|
470
|
+
context 'when environment contains mixed case variable' do
|
471
|
+
let(:old_environment) { { 'MY_variable' => '1' } }
|
472
|
+
|
473
|
+
before(:each) { environment.prepend(variable, value) }
|
474
|
+
|
475
|
+
context 'when uppercase key is given' do
|
476
|
+
let(:variable) { 'MY_VARIABLE' }
|
477
|
+
|
478
|
+
it { expect(environment[variable]).to eq 'NEW_VALUE1' }
|
479
|
+
end
|
480
|
+
|
481
|
+
context 'when lowercase key is given' do
|
482
|
+
let(:variable) { 'my_variable' }
|
483
|
+
|
484
|
+
it { expect(environment[variable]).to eq 'NEW_VALUE1' }
|
485
|
+
end
|
486
|
+
|
487
|
+
context 'when mixed case key is given' do
|
488
|
+
let(:variable) { 'MY_variable' }
|
489
|
+
|
490
|
+
it { expect(environment[variable]).to eq 'NEW_VALUE1' }
|
491
|
+
end
|
492
|
+
|
493
|
+
context 'when unknown variable is given' do
|
494
|
+
let(:variable) { 'unknown' }
|
495
|
+
|
496
|
+
it { expect(environment[variable]).to eq 'NEW_VALUE' }
|
497
|
+
end
|
498
|
+
end
|
499
|
+
end
|
500
|
+
end
|