nugrant 2.1.2 → 2.1.4
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 +5 -5
- data/.gitignore +23 -23
- data/.travis.yml +15 -10
- data/CHANGELOG.md +347 -338
- data/CONTRIBUTORS.md +7 -5
- data/Gemfile +13 -13
- data/README.md +601 -601
- data/lib/nugrant/bag.rb +264 -264
- data/lib/nugrant/config.rb +201 -201
- data/lib/nugrant/helper/bag.rb +38 -38
- data/lib/nugrant/helper/env/exporter.rb +195 -195
- data/lib/nugrant/helper/env/namer.rb +47 -47
- data/lib/nugrant/helper/parameters.rb +12 -12
- data/lib/nugrant/helper/stack.rb +86 -86
- data/lib/nugrant/mixin/parameters.rb +178 -178
- data/lib/nugrant/parameters.rb +29 -29
- data/lib/nugrant/vagrant/errors.rb +35 -35
- data/lib/nugrant/vagrant/v2/action/auto_export.rb +45 -45
- data/lib/nugrant/vagrant/v2/action.rb +17 -17
- data/lib/nugrant/vagrant/v2/command/env.rb +118 -118
- data/lib/nugrant/vagrant/v2/command/parameters.rb +153 -153
- data/lib/nugrant/vagrant/v2/command/restricted_keys.rb +64 -64
- data/lib/nugrant/vagrant/v2/command/root.rb +95 -95
- data/lib/nugrant/vagrant/v2/config/user.rb +29 -29
- data/lib/nugrant/vagrant/v2/helper.rb +96 -96
- data/lib/nugrant/vagrant/v2/plugin.rb +34 -34
- data/lib/nugrant/version.rb +3 -3
- data/lib/nugrant.rb +31 -31
- data/locales/en.yml +24 -24
- data/locales/fr.yml +24 -24
- data/nugrant.gemspec +32 -32
- data/test/lib/nugrant/helper/env/test_exporter.rb +238 -238
- data/test/lib/nugrant/helper/test_bag.rb +16 -16
- data/test/lib/nugrant/helper/test_parameters.rb +17 -17
- data/test/lib/nugrant/helper/test_stack.rb +152 -152
- data/test/lib/nugrant/test_bag.rb +450 -450
- data/test/lib/nugrant/test_config.rb +201 -201
- data/test/lib/nugrant/test_parameters.rb +438 -438
- data/test/lib/test_helper.rb +3 -3
- data/test/resources/README.md +52 -52
- data/test/resources/json/params_current_1.json +6 -6
- data/test/resources/json/params_current_2.json +29 -29
- data/test/resources/json/params_user_nil_values.json +9 -9
- data/test/resources/vagrantfiles/v2.auto_export +13 -13
- data/test/resources/vagrantfiles/v2.bag_inside_array +15 -15
- data/test/resources/vagrantfiles/v2.defaults_mixed_string_symbols +18 -18
- data/test/resources/vagrantfiles/v2.defaults_null_values_in_vagrantuser +23 -23
- data/test/resources/vagrantfiles/v2.defaults_using_string +18 -18
- data/test/resources/vagrantfiles/v2.defaults_using_symbol +18 -18
- data/test/resources/vagrantfiles/v2.empty +2 -2
- data/test/resources/vagrantfiles/v2.fake +29 -29
- data/test/resources/vagrantfiles/v2.missing_parameter +3 -3
- data/test/resources/vagrantfiles/v2.real +22 -22
- data/test/resources/yaml/params_array.yml +5 -5
- data/test/resources/yaml/params_boolean.yml +1 -1
- data/test/resources/yaml/params_combinations.yml +72 -72
- data/test/resources/yaml/params_current_1.yml +4 -4
- data/test/resources/yaml/params_current_2.yml +23 -23
- data/test/resources/yaml/params_defaults_at_root.yml +1 -1
- data/test/resources/yaml/params_defaults_not_at_root.yml +2 -2
- data/test/resources/yaml/params_list.yml +2 -2
- data/test/resources/yaml/params_numeric_key.yml +3 -3
- data/test/resources/yaml/params_simple.yml +1 -1
- data/test/resources/yaml/params_system_1.yml +4 -4
- data/test/resources/yaml/params_system_2.yml +25 -25
- data/test/resources/yaml/params_unix_eol.yml +3 -3
- data/test/resources/yaml/params_user_1.yml +4 -4
- data/test/resources/yaml/params_user_2.yml +23 -23
- data/test/resources/yaml/params_user_nil_values.yml +5 -5
- data/test/resources/yaml/params_windows_eol.yml +3 -3
- metadata +12 -13
@@ -1,238 +1,238 @@
|
|
1
|
-
require 'minitest/autorun'
|
2
|
-
|
3
|
-
require 'nugrant/bag'
|
4
|
-
require 'nugrant/helper/env/exporter'
|
5
|
-
|
6
|
-
module Nugrant
|
7
|
-
module Helper
|
8
|
-
module Env
|
9
|
-
class TestExporter < ::Minitest::Test
|
10
|
-
def create_bag(parameters)
|
11
|
-
return Nugrant::Bag.new(parameters)
|
12
|
-
end
|
13
|
-
|
14
|
-
def assert_export(expected, key, value, options = {})
|
15
|
-
actual = Env::Exporter.command(:export, key, value, options)
|
16
|
-
|
17
|
-
assert_equal(expected, actual)
|
18
|
-
end
|
19
|
-
|
20
|
-
def assert_unset(expected, key, options = {})
|
21
|
-
actual = Env::Exporter.command(:unset, key, options)
|
22
|
-
|
23
|
-
assert_equal(expected, actual)
|
24
|
-
end
|
25
|
-
|
26
|
-
def assert_autoenv_exporter(expected, bag, options = {})
|
27
|
-
io = StringIO.new()
|
28
|
-
Env::Exporter.autoenv_exporter(bag, options.merge({:io => io}))
|
29
|
-
|
30
|
-
actual = io.string().split(/\r?\n/)
|
31
|
-
|
32
|
-
assert_equal(expected, actual)
|
33
|
-
end
|
34
|
-
|
35
|
-
def assert_script_exporter(expected, bag, options = {})
|
36
|
-
io = StringIO.new()
|
37
|
-
Env::Exporter.script_exporter(bag, options.merge({:io => io}))
|
38
|
-
|
39
|
-
actual = io.string().split(/\r?\n/)
|
40
|
-
|
41
|
-
assert_equal(expected, actual)
|
42
|
-
end
|
43
|
-
|
44
|
-
def assert_terminal_exporter(expected, bag, options = {})
|
45
|
-
io = StringIO.new()
|
46
|
-
Env::Exporter.terminal_exporter(bag, options.merge({:io => io}))
|
47
|
-
|
48
|
-
actual = io.string().split(/\r?\n/)
|
49
|
-
|
50
|
-
assert_equal(expected, actual)
|
51
|
-
end
|
52
|
-
|
53
|
-
def assert_unset_commands(expected, bag, options = {})
|
54
|
-
actual = Env::Exporter.unset_commands(bag, options)
|
55
|
-
|
56
|
-
assert_equal(expected, actual)
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_valid_exporter
|
60
|
-
assert_equal(true, Env::Exporter.valid?(:autoenv))
|
61
|
-
assert_equal(true, Env::Exporter.valid?(:script))
|
62
|
-
assert_equal(true, Env::Exporter.valid?(:terminal))
|
63
|
-
assert_equal(false, Env::Exporter.valid?(:foreman))
|
64
|
-
end
|
65
|
-
|
66
|
-
def test_export_command
|
67
|
-
assert_export("export TEST=\\\"running\\ with\\ space\\\"", "TEST", "\"running with space\"")
|
68
|
-
assert_export("export TEST=running with space", "TEST", "running with space", :escape_value => false)
|
69
|
-
end
|
70
|
-
|
71
|
-
def test_unset_command
|
72
|
-
assert_unset("unset TEST", "TEST")
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_terminal_exporter_export
|
76
|
-
bag = create_bag({
|
77
|
-
:level1 => {
|
78
|
-
:level2 => {
|
79
|
-
:first => "first with space",
|
80
|
-
:second => "\"second\\"
|
81
|
-
},
|
82
|
-
:third => "third"
|
83
|
-
},
|
84
|
-
:existing => "downcase",
|
85
|
-
})
|
86
|
-
|
87
|
-
stub_env(:existing => "exist", :EXISTING => "exist") do
|
88
|
-
assert_terminal_exporter([
|
89
|
-
"export EXISTING=downcase",
|
90
|
-
"export LEVEL1_LEVEL2_FIRST=first\\ with\\ space",
|
91
|
-
"export LEVEL1_LEVEL2_SECOND=\\\"second\\\\",
|
92
|
-
"export LEVEL1_THIRD=third",
|
93
|
-
], bag)
|
94
|
-
|
95
|
-
assert_terminal_exporter([
|
96
|
-
"export LEVEL1_LEVEL2_FIRST=first\\ with\\ space",
|
97
|
-
"export LEVEL1_LEVEL2_SECOND=\\\"second\\\\",
|
98
|
-
"export LEVEL1_THIRD=third",
|
99
|
-
], bag, :override => false)
|
100
|
-
|
101
|
-
assert_terminal_exporter([
|
102
|
-
"export EXISTING=downcase",
|
103
|
-
"export LEVEL1_LEVEL2_FIRST=first with space",
|
104
|
-
"export LEVEL1_LEVEL2_SECOND=\"second\\",
|
105
|
-
"export LEVEL1_THIRD=third",
|
106
|
-
], bag, :type => :export, :override => true, :escape_value => false)
|
107
|
-
|
108
|
-
default_namer = Env::Namer.default(".")
|
109
|
-
prefix_namer = Env::Namer.prefix("CONFIG", default_namer)
|
110
|
-
|
111
|
-
assert_terminal_exporter([
|
112
|
-
"export CONFIG.EXISTING=downcase",
|
113
|
-
"export CONFIG.LEVEL1.LEVEL2.FIRST=first with space",
|
114
|
-
"export CONFIG.LEVEL1.LEVEL2.SECOND=\"second\\",
|
115
|
-
"export CONFIG.LEVEL1.THIRD=third",
|
116
|
-
], bag, :override => true, :escape_value => false, :namer => prefix_namer)
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
def test_terminal_exporter_unset
|
121
|
-
bag = create_bag({
|
122
|
-
:level1 => {
|
123
|
-
:level2 => {
|
124
|
-
:first => "first",
|
125
|
-
:second => "second"
|
126
|
-
},
|
127
|
-
:third => "third"
|
128
|
-
},
|
129
|
-
:existing => "downcase",
|
130
|
-
})
|
131
|
-
|
132
|
-
stub_env(:existing => "exist", :EXISTING => "exist") do
|
133
|
-
assert_terminal_exporter([
|
134
|
-
"unset EXISTING",
|
135
|
-
"unset LEVEL1_LEVEL2_FIRST",
|
136
|
-
"unset LEVEL1_LEVEL2_SECOND",
|
137
|
-
"unset LEVEL1_THIRD",
|
138
|
-
], bag, :type => :unset)
|
139
|
-
|
140
|
-
assert_terminal_exporter([
|
141
|
-
"unset LEVEL1_LEVEL2_FIRST",
|
142
|
-
"unset LEVEL1_LEVEL2_SECOND",
|
143
|
-
"unset LEVEL1_THIRD",
|
144
|
-
], bag, :override => false, :type => :unset)
|
145
|
-
|
146
|
-
default_namer = Env::Namer.default(".")
|
147
|
-
prefix_namer = Env::Namer.prefix("CONFIG", default_namer)
|
148
|
-
|
149
|
-
assert_terminal_exporter([
|
150
|
-
"unset CONFIG.EXISTING",
|
151
|
-
"unset CONFIG.LEVEL1.LEVEL2.FIRST",
|
152
|
-
"unset CONFIG.LEVEL1.LEVEL2.SECOND",
|
153
|
-
"unset CONFIG.LEVEL1.THIRD",
|
154
|
-
], bag, :override => true, :namer => prefix_namer, :type => :unset)
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
def test_autoenv_exporter
|
159
|
-
bag = create_bag({
|
160
|
-
:level1 => {
|
161
|
-
:level2 => {
|
162
|
-
:first => "first",
|
163
|
-
:second => "second"
|
164
|
-
},
|
165
|
-
:third => "third"
|
166
|
-
},
|
167
|
-
:existing => "downcase",
|
168
|
-
})
|
169
|
-
|
170
|
-
assert_autoenv_exporter([
|
171
|
-
"export EXISTING=downcase",
|
172
|
-
"export LEVEL1_LEVEL2_FIRST=first",
|
173
|
-
"export LEVEL1_LEVEL2_SECOND=second",
|
174
|
-
"export LEVEL1_THIRD=third",
|
175
|
-
], bag, :type => :export)
|
176
|
-
|
177
|
-
assert_autoenv_exporter([
|
178
|
-
"unset EXISTING",
|
179
|
-
"unset LEVEL1_LEVEL2_FIRST",
|
180
|
-
"unset LEVEL1_LEVEL2_SECOND",
|
181
|
-
"unset LEVEL1_THIRD",
|
182
|
-
], bag, :type => :unset)
|
183
|
-
end
|
184
|
-
|
185
|
-
def test_script_exporter
|
186
|
-
bag = create_bag({
|
187
|
-
:level1 => {
|
188
|
-
:level2 => {
|
189
|
-
:first => "first",
|
190
|
-
:second => "second"
|
191
|
-
},
|
192
|
-
:third => "third"
|
193
|
-
},
|
194
|
-
:existing => "downcase",
|
195
|
-
})
|
196
|
-
|
197
|
-
assert_script_exporter([
|
198
|
-
"#!/bin/env sh",
|
199
|
-
"",
|
200
|
-
"export EXISTING=downcase",
|
201
|
-
"export LEVEL1_LEVEL2_FIRST=first",
|
202
|
-
"export LEVEL1_LEVEL2_SECOND=second",
|
203
|
-
"export LEVEL1_THIRD=third",
|
204
|
-
], bag, :type => :export)
|
205
|
-
|
206
|
-
assert_script_exporter([
|
207
|
-
"#!/bin/env sh",
|
208
|
-
"",
|
209
|
-
"unset EXISTING",
|
210
|
-
"unset LEVEL1_LEVEL2_FIRST",
|
211
|
-
"unset LEVEL1_LEVEL2_SECOND",
|
212
|
-
"unset LEVEL1_THIRD",
|
213
|
-
], bag, :type => :unset)
|
214
|
-
end
|
215
|
-
|
216
|
-
def replace_env(variables)
|
217
|
-
ENV.clear()
|
218
|
-
|
219
|
-
variables = Hash[variables.map do |name, value|
|
220
|
-
[name.to_s, value]
|
221
|
-
end]
|
222
|
-
|
223
|
-
ENV.update(variables)
|
224
|
-
end
|
225
|
-
|
226
|
-
def stub_env(new = {})
|
227
|
-
old = ENV.to_hash()
|
228
|
-
|
229
|
-
replace_env(new)
|
230
|
-
yield
|
231
|
-
|
232
|
-
ensure
|
233
|
-
replace_env(old)
|
234
|
-
end
|
235
|
-
end
|
236
|
-
end
|
237
|
-
end
|
238
|
-
end
|
1
|
+
require 'minitest/autorun'
|
2
|
+
|
3
|
+
require 'nugrant/bag'
|
4
|
+
require 'nugrant/helper/env/exporter'
|
5
|
+
|
6
|
+
module Nugrant
|
7
|
+
module Helper
|
8
|
+
module Env
|
9
|
+
class TestExporter < ::Minitest::Test
|
10
|
+
def create_bag(parameters)
|
11
|
+
return Nugrant::Bag.new(parameters)
|
12
|
+
end
|
13
|
+
|
14
|
+
def assert_export(expected, key, value, options = {})
|
15
|
+
actual = Env::Exporter.command(:export, key, value, options)
|
16
|
+
|
17
|
+
assert_equal(expected, actual)
|
18
|
+
end
|
19
|
+
|
20
|
+
def assert_unset(expected, key, options = {})
|
21
|
+
actual = Env::Exporter.command(:unset, key, options)
|
22
|
+
|
23
|
+
assert_equal(expected, actual)
|
24
|
+
end
|
25
|
+
|
26
|
+
def assert_autoenv_exporter(expected, bag, options = {})
|
27
|
+
io = StringIO.new()
|
28
|
+
Env::Exporter.autoenv_exporter(bag, options.merge({:io => io}))
|
29
|
+
|
30
|
+
actual = io.string().split(/\r?\n/)
|
31
|
+
|
32
|
+
assert_equal(expected, actual)
|
33
|
+
end
|
34
|
+
|
35
|
+
def assert_script_exporter(expected, bag, options = {})
|
36
|
+
io = StringIO.new()
|
37
|
+
Env::Exporter.script_exporter(bag, options.merge({:io => io}))
|
38
|
+
|
39
|
+
actual = io.string().split(/\r?\n/)
|
40
|
+
|
41
|
+
assert_equal(expected, actual)
|
42
|
+
end
|
43
|
+
|
44
|
+
def assert_terminal_exporter(expected, bag, options = {})
|
45
|
+
io = StringIO.new()
|
46
|
+
Env::Exporter.terminal_exporter(bag, options.merge({:io => io}))
|
47
|
+
|
48
|
+
actual = io.string().split(/\r?\n/)
|
49
|
+
|
50
|
+
assert_equal(expected, actual)
|
51
|
+
end
|
52
|
+
|
53
|
+
def assert_unset_commands(expected, bag, options = {})
|
54
|
+
actual = Env::Exporter.unset_commands(bag, options)
|
55
|
+
|
56
|
+
assert_equal(expected, actual)
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_valid_exporter
|
60
|
+
assert_equal(true, Env::Exporter.valid?(:autoenv))
|
61
|
+
assert_equal(true, Env::Exporter.valid?(:script))
|
62
|
+
assert_equal(true, Env::Exporter.valid?(:terminal))
|
63
|
+
assert_equal(false, Env::Exporter.valid?(:foreman))
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_export_command
|
67
|
+
assert_export("export TEST=\\\"running\\ with\\ space\\\"", "TEST", "\"running with space\"")
|
68
|
+
assert_export("export TEST=running with space", "TEST", "running with space", :escape_value => false)
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_unset_command
|
72
|
+
assert_unset("unset TEST", "TEST")
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_terminal_exporter_export
|
76
|
+
bag = create_bag({
|
77
|
+
:level1 => {
|
78
|
+
:level2 => {
|
79
|
+
:first => "first with space",
|
80
|
+
:second => "\"second\\"
|
81
|
+
},
|
82
|
+
:third => "third"
|
83
|
+
},
|
84
|
+
:existing => "downcase",
|
85
|
+
})
|
86
|
+
|
87
|
+
stub_env(:existing => "exist", :EXISTING => "exist") do
|
88
|
+
assert_terminal_exporter([
|
89
|
+
"export EXISTING=downcase",
|
90
|
+
"export LEVEL1_LEVEL2_FIRST=first\\ with\\ space",
|
91
|
+
"export LEVEL1_LEVEL2_SECOND=\\\"second\\\\",
|
92
|
+
"export LEVEL1_THIRD=third",
|
93
|
+
], bag)
|
94
|
+
|
95
|
+
assert_terminal_exporter([
|
96
|
+
"export LEVEL1_LEVEL2_FIRST=first\\ with\\ space",
|
97
|
+
"export LEVEL1_LEVEL2_SECOND=\\\"second\\\\",
|
98
|
+
"export LEVEL1_THIRD=third",
|
99
|
+
], bag, :override => false)
|
100
|
+
|
101
|
+
assert_terminal_exporter([
|
102
|
+
"export EXISTING=downcase",
|
103
|
+
"export LEVEL1_LEVEL2_FIRST=first with space",
|
104
|
+
"export LEVEL1_LEVEL2_SECOND=\"second\\",
|
105
|
+
"export LEVEL1_THIRD=third",
|
106
|
+
], bag, :type => :export, :override => true, :escape_value => false)
|
107
|
+
|
108
|
+
default_namer = Env::Namer.default(".")
|
109
|
+
prefix_namer = Env::Namer.prefix("CONFIG", default_namer)
|
110
|
+
|
111
|
+
assert_terminal_exporter([
|
112
|
+
"export CONFIG.EXISTING=downcase",
|
113
|
+
"export CONFIG.LEVEL1.LEVEL2.FIRST=first with space",
|
114
|
+
"export CONFIG.LEVEL1.LEVEL2.SECOND=\"second\\",
|
115
|
+
"export CONFIG.LEVEL1.THIRD=third",
|
116
|
+
], bag, :override => true, :escape_value => false, :namer => prefix_namer)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_terminal_exporter_unset
|
121
|
+
bag = create_bag({
|
122
|
+
:level1 => {
|
123
|
+
:level2 => {
|
124
|
+
:first => "first",
|
125
|
+
:second => "second"
|
126
|
+
},
|
127
|
+
:third => "third"
|
128
|
+
},
|
129
|
+
:existing => "downcase",
|
130
|
+
})
|
131
|
+
|
132
|
+
stub_env(:existing => "exist", :EXISTING => "exist") do
|
133
|
+
assert_terminal_exporter([
|
134
|
+
"unset EXISTING",
|
135
|
+
"unset LEVEL1_LEVEL2_FIRST",
|
136
|
+
"unset LEVEL1_LEVEL2_SECOND",
|
137
|
+
"unset LEVEL1_THIRD",
|
138
|
+
], bag, :type => :unset)
|
139
|
+
|
140
|
+
assert_terminal_exporter([
|
141
|
+
"unset LEVEL1_LEVEL2_FIRST",
|
142
|
+
"unset LEVEL1_LEVEL2_SECOND",
|
143
|
+
"unset LEVEL1_THIRD",
|
144
|
+
], bag, :override => false, :type => :unset)
|
145
|
+
|
146
|
+
default_namer = Env::Namer.default(".")
|
147
|
+
prefix_namer = Env::Namer.prefix("CONFIG", default_namer)
|
148
|
+
|
149
|
+
assert_terminal_exporter([
|
150
|
+
"unset CONFIG.EXISTING",
|
151
|
+
"unset CONFIG.LEVEL1.LEVEL2.FIRST",
|
152
|
+
"unset CONFIG.LEVEL1.LEVEL2.SECOND",
|
153
|
+
"unset CONFIG.LEVEL1.THIRD",
|
154
|
+
], bag, :override => true, :namer => prefix_namer, :type => :unset)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
def test_autoenv_exporter
|
159
|
+
bag = create_bag({
|
160
|
+
:level1 => {
|
161
|
+
:level2 => {
|
162
|
+
:first => "first",
|
163
|
+
:second => "second"
|
164
|
+
},
|
165
|
+
:third => "third"
|
166
|
+
},
|
167
|
+
:existing => "downcase",
|
168
|
+
})
|
169
|
+
|
170
|
+
assert_autoenv_exporter([
|
171
|
+
"export EXISTING=downcase",
|
172
|
+
"export LEVEL1_LEVEL2_FIRST=first",
|
173
|
+
"export LEVEL1_LEVEL2_SECOND=second",
|
174
|
+
"export LEVEL1_THIRD=third",
|
175
|
+
], bag, :type => :export)
|
176
|
+
|
177
|
+
assert_autoenv_exporter([
|
178
|
+
"unset EXISTING",
|
179
|
+
"unset LEVEL1_LEVEL2_FIRST",
|
180
|
+
"unset LEVEL1_LEVEL2_SECOND",
|
181
|
+
"unset LEVEL1_THIRD",
|
182
|
+
], bag, :type => :unset)
|
183
|
+
end
|
184
|
+
|
185
|
+
def test_script_exporter
|
186
|
+
bag = create_bag({
|
187
|
+
:level1 => {
|
188
|
+
:level2 => {
|
189
|
+
:first => "first",
|
190
|
+
:second => "second"
|
191
|
+
},
|
192
|
+
:third => "third"
|
193
|
+
},
|
194
|
+
:existing => "downcase",
|
195
|
+
})
|
196
|
+
|
197
|
+
assert_script_exporter([
|
198
|
+
"#!/bin/env sh",
|
199
|
+
"",
|
200
|
+
"export EXISTING=downcase",
|
201
|
+
"export LEVEL1_LEVEL2_FIRST=first",
|
202
|
+
"export LEVEL1_LEVEL2_SECOND=second",
|
203
|
+
"export LEVEL1_THIRD=third",
|
204
|
+
], bag, :type => :export)
|
205
|
+
|
206
|
+
assert_script_exporter([
|
207
|
+
"#!/bin/env sh",
|
208
|
+
"",
|
209
|
+
"unset EXISTING",
|
210
|
+
"unset LEVEL1_LEVEL2_FIRST",
|
211
|
+
"unset LEVEL1_LEVEL2_SECOND",
|
212
|
+
"unset LEVEL1_THIRD",
|
213
|
+
], bag, :type => :unset)
|
214
|
+
end
|
215
|
+
|
216
|
+
def replace_env(variables)
|
217
|
+
ENV.clear()
|
218
|
+
|
219
|
+
variables = Hash[variables.map do |name, value|
|
220
|
+
[name.to_s, value]
|
221
|
+
end]
|
222
|
+
|
223
|
+
ENV.update(variables)
|
224
|
+
end
|
225
|
+
|
226
|
+
def stub_env(new = {})
|
227
|
+
old = ENV.to_hash()
|
228
|
+
|
229
|
+
replace_env(new)
|
230
|
+
yield
|
231
|
+
|
232
|
+
ensure
|
233
|
+
replace_env(old)
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|
@@ -1,16 +1,16 @@
|
|
1
|
-
require 'minitest/autorun'
|
2
|
-
|
3
|
-
require 'nugrant/helper/bag'
|
4
|
-
|
5
|
-
module Nugrant
|
6
|
-
module Helper
|
7
|
-
class TestBag < ::Minitest::Test
|
8
|
-
def test_restricted_keys_contains_hash_ones
|
9
|
-
keys = Helper::Bag.restricted_keys()
|
10
|
-
Hash.instance_methods.each do |method|
|
11
|
-
assert_includes(keys, method, "Restricted keys must include Hash method #{method}")
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
1
|
+
require 'minitest/autorun'
|
2
|
+
|
3
|
+
require 'nugrant/helper/bag'
|
4
|
+
|
5
|
+
module Nugrant
|
6
|
+
module Helper
|
7
|
+
class TestBag < ::Minitest::Test
|
8
|
+
def test_restricted_keys_contains_hash_ones
|
9
|
+
keys = Helper::Bag.restricted_keys()
|
10
|
+
Hash.instance_methods.each do |method|
|
11
|
+
assert_includes(keys, method, "Restricted keys must include Hash method #{method}")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -1,17 +1,17 @@
|
|
1
|
-
require 'minitest/autorun'
|
2
|
-
|
3
|
-
require 'nugrant/bag'
|
4
|
-
require 'nugrant/helper/parameters'
|
5
|
-
|
6
|
-
module Nugrant
|
7
|
-
module Helper
|
8
|
-
class TestParameters < ::Minitest::Test
|
9
|
-
def test_restricted_keys_contains_hash_ones
|
10
|
-
keys = Helper::Parameters.restricted_keys()
|
11
|
-
Nugrant::Bag.instance_methods.each do |method|
|
12
|
-
assert_includes(keys, method, "Restricted keys must include Nugrant::Bag method #{method}")
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
1
|
+
require 'minitest/autorun'
|
2
|
+
|
3
|
+
require 'nugrant/bag'
|
4
|
+
require 'nugrant/helper/parameters'
|
5
|
+
|
6
|
+
module Nugrant
|
7
|
+
module Helper
|
8
|
+
class TestParameters < ::Minitest::Test
|
9
|
+
def test_restricted_keys_contains_hash_ones
|
10
|
+
keys = Helper::Parameters.restricted_keys()
|
11
|
+
Nugrant::Bag.instance_methods.each do |method|
|
12
|
+
assert_includes(keys, method, "Restricted keys must include Nugrant::Bag method #{method}")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|