nugrant 2.0.0.dev2 → 2.0.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +6 -14
  2. data/.gitignore +2 -1
  3. data/.travis.yml +2 -2
  4. data/CHANGELOG.md +148 -3
  5. data/Gemfile +8 -20
  6. data/README.md +266 -72
  7. data/Rakefile +1 -0
  8. data/lib/nugrant.rb +14 -6
  9. data/lib/nugrant/bag.rb +116 -62
  10. data/lib/nugrant/helper/bag.rb +19 -19
  11. data/lib/nugrant/helper/env/exporter.rb +208 -0
  12. data/lib/nugrant/helper/env/namer.rb +47 -0
  13. data/lib/nugrant/helper/parameters.rb +12 -0
  14. data/lib/nugrant/helper/stack.rb +86 -0
  15. data/lib/nugrant/mixin/parameters.rb +98 -0
  16. data/lib/nugrant/parameters.rb +14 -68
  17. data/lib/nugrant/vagrant/errors.rb +27 -0
  18. data/lib/nugrant/vagrant/v2/command/env.rb +101 -0
  19. data/lib/nugrant/vagrant/v2/command/helper.rb +30 -0
  20. data/lib/nugrant/vagrant/v2/command/parameters.rb +16 -4
  21. data/lib/nugrant/vagrant/v2/command/restricted_keys.rb +60 -0
  22. data/lib/nugrant/vagrant/v2/command/root.rb +12 -2
  23. data/lib/nugrant/vagrant/v2/config/user.rb +9 -21
  24. data/lib/nugrant/vagrant/v2/plugin.rb +0 -1
  25. data/lib/nugrant/version.rb +1 -1
  26. data/locales/en.yml +13 -0
  27. data/nugrant.gemspec +3 -7
  28. data/test/lib/nugrant/helper/env/test_exporter.rb +238 -0
  29. data/test/lib/nugrant/helper/test_bag.rb +16 -0
  30. data/test/lib/nugrant/helper/test_parameters.rb +17 -0
  31. data/test/lib/nugrant/helper/test_stack.rb +152 -0
  32. data/test/lib/nugrant/test_bag.rb +132 -22
  33. data/test/lib/nugrant/test_config.rb +95 -92
  34. data/test/lib/nugrant/test_parameters.rb +232 -177
  35. data/test/lib/test_helper.rb +3 -0
  36. data/test/resources/json/params_user_nil_values.json +9 -0
  37. data/test/resources/vagrantfiles/v2.defaults_mixed_string_symbols +18 -0
  38. data/test/resources/vagrantfiles/v2.defaults_null_values_in_vagrantuser +23 -0
  39. data/test/resources/vagrantfiles/v2.defaults_using_string +18 -0
  40. data/test/resources/vagrantfiles/v2.defaults_using_symbol +18 -0
  41. data/test/resources/{Vagrantfile.v2.empty → vagrantfiles/v2.empty} +0 -2
  42. data/test/resources/{Vagrantfile.v2.fake → vagrantfiles/v2.fake} +4 -3
  43. data/test/resources/vagrantfiles/v2.missing_parameter +3 -0
  44. data/test/resources/{Vagrantfile.v2.real → vagrantfiles/v2.real} +0 -2
  45. data/test/resources/yaml/params_user_nil_values.yml +5 -0
  46. metadata +55 -88
  47. data/lib/nugrant/vagrant/v1/command/parameters.rb +0 -134
  48. data/lib/nugrant/vagrant/v1/command/root.rb +0 -81
  49. data/lib/nugrant/vagrant/v1/config/user.rb +0 -37
  50. data/lib/nugrant/vagrant/v1/plugin.rb +0 -6
  51. data/lib/vagrant_init.rb +0 -2
  52. data/test/resources/Vagrantfile.v1.empty +0 -2
  53. data/test/resources/Vagrantfile.v1.fake +0 -10
  54. data/test/resources/Vagrantfile.v1.real +0 -19
@@ -0,0 +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
@@ -0,0 +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
@@ -0,0 +1,152 @@
1
+ require 'minitest/autorun'
2
+
3
+ require 'nugrant/helper/stack'
4
+
5
+ module Nugrant
6
+ module Helper
7
+ class TestStack < ::Minitest::Test
8
+ def create_stack(options = {})
9
+ pattern = options[:pattern] || "Vagrantfile:%s"
10
+ count = options[:count] || 4
11
+
12
+ stack = []
13
+ (0..count).each do |index|
14
+ stack << pattern.gsub("%s", index.to_s())
15
+ end
16
+
17
+ stack
18
+ end
19
+
20
+ def create_location(name, line)
21
+ resource_path = File.expand_path("#{File.dirname(__FILE__)}/../../../resources/vagrantfiles")
22
+
23
+ {:file => "#{resource_path}/#{name}", :line => line}
24
+ end
25
+
26
+ def assert_error_location(expected, entry, matcher = nil)
27
+ assert_equal(expected, Stack::extract_error_location(entry, :matcher => matcher), "Not exact error location")
28
+ end
29
+
30
+ def assert_error_region(expected, region)
31
+ expected_lines = expected.split("\n")
32
+ region_lines = region.split("\n")
33
+
34
+ expected_count = expected_lines.length()
35
+ actual_count = region_lines.length()
36
+
37
+ assert_equal(expected_count, actual_count, "Region different line count")
38
+
39
+ expected_lines.each_with_index do |expected_line, index|
40
+ assert_equal(expected_line.strip(), region_lines[index].strip(), "Line ##{index} are not equals")
41
+ end
42
+ end
43
+
44
+ def test_fetch_error_region_from_location()
45
+ location = create_location("v2.defaults_using_symbol", 4)
46
+ error_region = Stack::fetch_error_region_from_location(location)
47
+ expected_region = <<-EOT
48
+ 1: Vagrant.configure("2") do |config|
49
+ 2: config.user.defaults = {
50
+ 3: :single => 1,
51
+ 4:>> :local => {
52
+ 5: :first => "value1",
53
+ 6: :second => "value2"
54
+ 7: }
55
+ 8: }
56
+ EOT
57
+
58
+ assert_error_region(expected_region, error_region)
59
+ end
60
+
61
+ def test_fetch_error_region_from_location_custom_prefix()
62
+ location = create_location("v2.defaults_using_symbol", 4)
63
+ error_region = Stack::fetch_error_region_from_location(location, :prefix => "**")
64
+ expected_region = <<-EOT
65
+ **1: Vagrant.configure(\"2\") do |config|
66
+ **2: config.user.defaults = {
67
+ **3: :single => 1,
68
+ **4:>> :local => {
69
+ **5: :first => "value1",
70
+ **6: :second => "value2"
71
+ **7: }
72
+ **8: }
73
+ EOT
74
+
75
+ assert_error_region(expected_region, error_region)
76
+ end
77
+
78
+ def test_fetch_error_region_from_location_custom_width()
79
+ location = create_location("v2.defaults_using_symbol", 4)
80
+ error_region = Stack::fetch_error_region_from_location(location, :width => 2)
81
+ expected_region = <<-EOT
82
+ 2: config.user.defaults = {
83
+ 3: :single => 1,
84
+ 4:>> :local => {
85
+ 5: :first => "value1",
86
+ 6: :second => "value2"
87
+ EOT
88
+
89
+ assert_error_region(expected_region, error_region)
90
+ end
91
+
92
+ def test_fetch_error_region_from_location_wrong_location()
93
+ location = {:file => nil, :line => nil}
94
+ assert_equal("Unknown", Stack::fetch_error_region_from_location(location))
95
+ assert_equal("Failed", Stack::fetch_error_region_from_location(location, :unknown => "Failed"))
96
+
97
+ location = {:file => "Vagrantfile", :line => nil}
98
+ assert_equal("Vagrantfile", Stack::fetch_error_region_from_location(location))
99
+
100
+ location = {:file => "NonExistingVagrantfile", :line => 4}
101
+ assert_equal("NonExistingVagrantfile:4", Stack::fetch_error_region_from_location(location))
102
+ end
103
+
104
+ def test_find_entry()
105
+ entries = ["First", "Second:", "Third:a", "Fourth:4"]
106
+
107
+ assert_equal("Fourth:4", Stack::find_entry(entries))
108
+ assert_equal("Third:a", Stack::find_entry(entries, :matcher => /^(.+):([a-z]+)/))
109
+ end
110
+
111
+ def test_extract_error_location_default_matcher()
112
+ # Matches
113
+ assert_error_location({:file => "/work/irb/workspace.rb", :line => 80}, "/work/irb/workspace.rb:80:in `eval'")
114
+ assert_error_location({:file => "workspace.rb", :line => 80}, "workspace.rb:80:in `eval'")
115
+ assert_error_location({:file => "/work/irb/workspace.rb", :line => 80}, "/work/irb/workspace.rb:80")
116
+
117
+ # No match
118
+ assert_error_location({:file => nil, :line => nil}, "/work/irb/workspace.rb?80")
119
+ assert_error_location({:file => nil, :line => nil}, "/work/irb/workspace.rb")
120
+ assert_error_location({:file =>nil, :line => nil}, "")
121
+ end
122
+
123
+ def test_extract_error_location_custom_matcher()
124
+ # Matches
125
+ assert_error_location(
126
+ {:file => "/work/Vagrantfile", :line => 80},
127
+ "/work/Vagrantfile:80:in `eval'",
128
+ /(.*Vagrantfile):([0-9]+)/
129
+ )
130
+
131
+ assert_error_location(
132
+ {:file => "Vagrantfile", :line => 80},
133
+ "Vagrantfile:80:in `eval'",
134
+ /(.*Vagrantfile):([0-9]+)/
135
+ )
136
+
137
+ assert_error_location(
138
+ {:file => "/work/irb/Vagrantfile", :line => 80},
139
+ "/work/irb/Vagrantfile:80",
140
+ /(.*Vagrantfile):([0-9]+)/
141
+ )
142
+
143
+ # Partial match
144
+ assert_error_location(
145
+ {:file => "/work/Vagrantfile", :line => nil},
146
+ "/work/Vagrantfile:80:in `eval'",
147
+ /(.*Vagrantfile)/
148
+ )
149
+ end
150
+ end
151
+ end
152
+ end
@@ -1,25 +1,36 @@
1
- require 'test/unit'
1
+ require 'minitest/autorun'
2
2
 
3
3
  require 'nugrant/bag'
4
+ require 'nugrant/helper/bag'
4
5
 
5
6
  module Nugrant
6
- class TestBag < Test::Unit::TestCase
7
- def create_bag(parameters)
8
- return Bag.new(parameters)
7
+ class TestBag < ::Minitest::Test
8
+ def create_bag(elements, options = {})
9
+ return Bag.new(elements, options)
9
10
  end
10
11
 
11
- def assert_bag(parameters, bag)
12
+ def assert_all_access_equal(expected, bag, key)
13
+ assert_equal(expected, bag.method_missing(key.to_sym), "bag.#{key.to_sym}")
14
+ assert_equal(expected, bag[key.to_s], "bag[#{key.to_s}]")
15
+ assert_equal(expected, bag[key.to_sym], "bag[#{key.to_sym}]")
16
+ end
17
+
18
+ def assert_all_access_bag(expected, bag, key)
19
+ assert_bag(expected, bag.method_missing(key.to_sym))
20
+ assert_bag(expected, bag[key.to_s])
21
+ assert_bag(expected, bag[key.to_sym])
22
+ end
23
+
24
+ def assert_bag(expected, bag)
12
25
  assert_kind_of(Bag, bag)
13
26
 
14
- parameters.each do |key, value|
15
- if not value.kind_of?(Hash)
16
- assert_equal(value, bag.send(key))
17
- assert_equal(value, bag[key])
27
+ expected.each do |key, expected_value|
28
+ if not expected_value.kind_of?(Hash)
29
+ assert_all_access_equal(expected_value, bag, key)
18
30
  next
19
31
  end
20
32
 
21
- assert_bag(value, bag.send(key))
22
- assert_bag(value, bag[key])
33
+ assert_all_access_bag(expected_value, bag, key)
23
34
  end
24
35
  end
25
36
 
@@ -74,22 +85,26 @@ module Nugrant
74
85
  def test_undefined_value()
75
86
  bag = create_bag({:value => "one"})
76
87
 
77
- assert_raise(KeyError) do
88
+ assert_raises(KeyError) do
78
89
  bag.invalid_value
79
90
  end
80
91
 
81
- assert_raise(KeyError) do
92
+ assert_raises(KeyError) do
82
93
  bag["invalid_value"]
83
94
  end
95
+
96
+ assert_raises(KeyError) do
97
+ bag[:invalid_value]
98
+ end
84
99
  end
85
100
 
86
101
  def test_to_hash()
87
- hash = create_bag({}).__to_hash()
102
+ hash = create_bag({}).to_hash()
88
103
 
89
104
  assert_kind_of(Hash, hash)
90
105
  assert_equal({}, hash)
91
106
 
92
- hash = create_bag({:value => {:one => "value", :two => "value"}}).__to_hash()
107
+ hash = create_bag({"value" => {:one => "value", "two" => "value"}}).to_hash()
93
108
 
94
109
  assert_kind_of(Hash, hash)
95
110
  assert_kind_of(Hash, hash[:value])
@@ -98,20 +113,115 @@ module Nugrant
98
113
  assert_equal({:value => {:one => "value", :two => "value"}}, hash)
99
114
  end
100
115
 
101
- def test_merge_array()
102
- bag1 = create_bag({:first => [1, 2]})
116
+ def test_merge_array_replace()
117
+ # Replace should be the default case
118
+ bag1 = create_bag({"first" => [1, 2]})
119
+ bag2 = create_bag({:first => [2, 3]})
120
+
121
+ bag1.merge!(bag2);
122
+
123
+ assert_equal({:first => [2, 3]}, bag1.to_hash())
124
+
125
+ bag1 = create_bag({"first" => [1, 2]})
126
+ bag2 = create_bag({:first => "string"})
127
+
128
+ bag1.merge!(bag2);
129
+
130
+ assert_equal({:first => "string"}, bag1.to_hash())
131
+ end
132
+
133
+ def test_merge_array_extend()
134
+ bag1 = create_bag({"first" => [1, 2]})
103
135
  bag2 = create_bag({:first => [2, 3]})
104
136
 
105
- bag1.__merge!(bag2);
137
+ bag1.merge!(bag2, :array_strategy => :extend);
106
138
 
107
- assert_equal({:first => [1, 2, 3]}, bag1.__to_hash())
139
+ assert_equal({:first => [1, 2, 3]}, bag1.to_hash())
108
140
 
109
- bag1 = create_bag({:first => [1, 2]})
141
+ bag1 = create_bag({"first" => [1, 2]})
110
142
  bag2 = create_bag({:first => "string"})
111
143
 
112
- bag1.__merge!(bag2);
144
+ bag1.merge!(bag2, :array_strategy => :extend);
145
+
146
+ assert_equal({:first => "string"}, bag1.to_hash())
147
+ end
148
+
149
+ def test_merge_array_concat()
150
+ bag1 = create_bag({"first" => [1, 2]})
151
+ bag2 = create_bag({:first => [2, 3]})
152
+
153
+ bag1.merge!(bag2, :array_strategy => :concat);
154
+
155
+ assert_equal({:first => [1, 2, 2, 3]}, bag1.to_hash())
156
+
157
+ bag1 = create_bag({"first" => [1, 2]})
158
+ bag2 = create_bag({:first => "string"})
159
+
160
+ bag1.merge!(bag2, :array_strategy => :concat);
161
+
162
+ assert_equal({:first => "string"}, bag1.to_hash())
163
+ end
164
+
165
+ def test_nil_key()
166
+ assert_raises(ArgumentError) do
167
+ create_bag({nil => "value"})
168
+ end
169
+
170
+ parameters = create_bag({})
171
+
172
+ assert_raises(ArgumentError) do
173
+ parameters[nil] = 1
174
+ end
175
+
176
+ assert_raises(ArgumentError) do
177
+ parameters[nil]
178
+ end
179
+
180
+ assert_raises(ArgumentError) do
181
+ parameters.method_missing(nil)
182
+ end
183
+ end
184
+
185
+ def test_restricted_keys_are_still_accessible
186
+ keys = Helper::Bag.restricted_keys()
187
+ bag = create_bag(Hash[
188
+ keys.map do |key|
189
+ [key, "#{key.to_s} - value"]
190
+ end
191
+ ])
192
+
193
+ keys.each do |key|
194
+ assert_equal("#{key.to_s} - value", bag[key.to_s], "bag[#{key.to_s}]")
195
+ assert_equal("#{key.to_s} - value", bag[key.to_sym], "bag[#{key.to_sym}]")
196
+ end
197
+ end
198
+
199
+ def test_custom_key_error_handler
200
+ bag = create_bag({:value => "one"}, :key_error => Proc.new do |key|
201
+ raise IndexError
202
+ end)
203
+
204
+ assert_raises(IndexError) do
205
+ bag.invalid_value
206
+ end
207
+
208
+ assert_raises(IndexError) do
209
+ bag["invalid_value"]
210
+ end
211
+
212
+ assert_raises(IndexError) do
213
+ bag[:invalid_value]
214
+ end
215
+ end
216
+
217
+ def test_custom_key_error_handler_returns_value
218
+ bag = create_bag({:value => "one"}, :key_error => Proc.new do |key|
219
+ "Some value"
220
+ end)
113
221
 
114
- assert_equal({:first => "string"}, bag1.__to_hash())
222
+ assert_equal("Some value", bag.invalid_value)
223
+ assert_equal("Some value", bag["invalid_value"])
224
+ assert_equal("Some value", bag[:invalid_value])
115
225
  end
116
226
  end
117
227
  end
@@ -1,120 +1,123 @@
1
- require 'nugrant/config'
2
- require 'test/unit'
1
+ require 'minitest/autorun'
3
2
  require 'tmpdir'
4
3
 
5
- class Nugrant::TestConfig < Test::Unit::TestCase
6
- def setup
7
- @default_param_filename = Nugrant::Config::DEFAULT_PARAMS_FILENAME
4
+ require 'nugrant/config'
8
5
 
9
- @old_working_dir = Dir.getwd()
10
- @user_dir = Nugrant::Config.default_user_path()
11
- @system_dir = Nugrant::Config.default_system_path()
6
+ module Nugrant
7
+ class TestConfig < ::Minitest::Test
8
+ def setup
9
+ @default_param_filename = Nugrant::Config::DEFAULT_PARAMS_FILENAME
12
10
 
13
- Dir.chdir(Dir.tmpdir())
11
+ @old_working_dir = Dir.getwd()
12
+ @user_dir = Nugrant::Config.default_user_path()
13
+ @system_dir = Nugrant::Config.default_system_path()
14
14
 
15
- @current_dir = Dir.getwd()
16
- end
15
+ Dir.chdir(Dir.tmpdir())
17
16
 
18
- def teardown
19
- Dir.chdir(@old_working_dir)
17
+ @current_dir = Dir.getwd()
18
+ end
20
19
 
21
- @old_working_dir = nil
22
- @current_dir = nil
23
- @user_dir = nil
24
- @system_dir = nil
25
- end
20
+ def teardown
21
+ Dir.chdir(@old_working_dir)
26
22
 
27
- def test_default_values
28
- config = Nugrant::Config.new()
23
+ @old_working_dir = nil
24
+ @current_dir = nil
25
+ @user_dir = nil
26
+ @system_dir = nil
27
+ end
29
28
 
30
- assert_equal(@default_param_filename, config.params_filename())
31
- assert_equal("#{@current_dir}/#{@default_param_filename}", config.current_path())
32
- assert_equal("#{@user_dir}/#{@default_param_filename}", config.user_path())
33
- assert_equal("#{@system_dir}/#{@default_param_filename}", config.system_path())
34
- end
29
+ def test_default_values
30
+ config = Nugrant::Config.new()
35
31
 
36
- def test_custom_params_filename
37
- config = Nugrant::Config.new({:params_filename => ".customparams"})
32
+ assert_equal(@default_param_filename, config.params_filename())
33
+ assert_equal("#{@current_dir}/#{@default_param_filename}", config.current_path())
34
+ assert_equal("#{@user_dir}/#{@default_param_filename}", config.user_path())
35
+ assert_equal("#{@system_dir}/#{@default_param_filename}", config.system_path())
36
+ end
38
37
 
39
- assert_equal(".customparams", config.params_filename())
40
- assert_equal("#{@current_dir}/.customparams", config.current_path())
41
- assert_equal("#{@user_dir}/.customparams", config.user_path())
42
- assert_equal("#{@system_dir}/.customparams", config.system_path())
43
- end
38
+ def test_custom_params_filename
39
+ config = Nugrant::Config.new({:params_filename => ".customparams"})
44
40
 
45
- def test_custom_current_path
46
- config = Nugrant::Config.new({
47
- :params_filename => ".customparams",
48
- :current_path => "#{@user_dir}/.currentcustomparams"
49
- })
41
+ assert_equal(".customparams", config.params_filename())
42
+ assert_equal("#{@current_dir}/.customparams", config.current_path())
43
+ assert_equal("#{@user_dir}/.customparams", config.user_path())
44
+ assert_equal("#{@system_dir}/.customparams", config.system_path())
45
+ end
50
46
 
51
- assert_equal(".customparams", config.params_filename())
52
- assert_equal("#{@user_dir}/.currentcustomparams", config.current_path())
53
- end
47
+ def test_custom_current_path
48
+ config = Nugrant::Config.new({
49
+ :params_filename => ".customparams",
50
+ :current_path => "#{@user_dir}/.currentcustomparams"
51
+ })
54
52
 
55
- def test_custom_user_path
56
- config = Nugrant::Config.new({
57
- :params_filename => ".customparams",
58
- :user_path => "#{@system_dir}/.usercustomparams"
59
- })
53
+ assert_equal(".customparams", config.params_filename())
54
+ assert_equal("#{@user_dir}/.currentcustomparams", config.current_path())
55
+ end
60
56
 
61
- assert_equal(".customparams", config.params_filename())
62
- assert_equal("#{@system_dir}/.usercustomparams", config.user_path()) end
57
+ def test_custom_user_path
58
+ config = Nugrant::Config.new({
59
+ :params_filename => ".customparams",
60
+ :user_path => "#{@system_dir}/.usercustomparams"
61
+ })
63
62
 
64
- def test_custom_system_path
65
- config = Nugrant::Config.new({
66
- :params_filename => ".customparams",
67
- :system_path => "#{@current_dir}/.systemcustomparams"
68
- })
63
+ assert_equal(".customparams", config.params_filename())
64
+ assert_equal("#{@system_dir}/.usercustomparams", config.user_path()) end
69
65
 
70
- assert_equal(".customparams", config.params_filename())
71
- assert_equal("#{@current_dir}/.systemcustomparams", config.system_path())
72
- end
66
+ def test_custom_system_path
67
+ config = Nugrant::Config.new({
68
+ :params_filename => ".customparams",
69
+ :system_path => "#{@current_dir}/.systemcustomparams"
70
+ })
73
71
 
74
- def test_custom_all
75
- config = Nugrant::Config.new({
76
- :params_filename => ".customparams",
77
- :current_path => "#{@user_dir}/.currentcustomparams",
78
- :user_path => "#{@system_dir}/.usercustomparams",
79
- :system_path => "#{@current_dir}/.systemcustomparams"
80
- })
81
-
82
- assert_equal(".customparams", config.params_filename())
83
- assert_equal("#{@user_dir}/.currentcustomparams", config.current_path())
84
- assert_equal("#{@system_dir}/.usercustomparams", config.user_path())
85
- assert_equal("#{@current_dir}/.systemcustomparams", config.system_path())
86
- end
72
+ assert_equal(".customparams", config.params_filename())
73
+ assert_equal("#{@current_dir}/.systemcustomparams", config.system_path())
74
+ end
87
75
 
88
- def test_nil_current
89
- config = Nugrant::Config.new({
90
- :params_filename => ".customparams",
91
- :current_path => nil,
92
- })
76
+ def test_custom_all
77
+ config = Nugrant::Config.new({
78
+ :params_filename => ".customparams",
79
+ :current_path => "#{@user_dir}/.currentcustomparams",
80
+ :user_path => "#{@system_dir}/.usercustomparams",
81
+ :system_path => "#{@current_dir}/.systemcustomparams"
82
+ })
83
+
84
+ assert_equal(".customparams", config.params_filename())
85
+ assert_equal("#{@user_dir}/.currentcustomparams", config.current_path())
86
+ assert_equal("#{@system_dir}/.usercustomparams", config.user_path())
87
+ assert_equal("#{@current_dir}/.systemcustomparams", config.system_path())
88
+ end
93
89
 
94
- assert_not_nil("#{@current_dir}/.customparams", config.current_path())
95
- end
90
+ def test_nil_current
91
+ config = Nugrant::Config.new({
92
+ :params_filename => ".customparams",
93
+ :current_path => nil,
94
+ })
96
95
 
97
- def test_nil_user
98
- config = Nugrant::Config.new({
99
- :params_filename => ".customparams",
100
- :user_path => nil,
101
- })
96
+ assert_equal("#{@current_dir}/.customparams", config.current_path())
97
+ end
102
98
 
103
- assert_equal("#{@user_dir}/.customparams", config.user_path())
104
- end
99
+ def test_nil_user
100
+ config = Nugrant::Config.new({
101
+ :params_filename => ".customparams",
102
+ :user_path => nil,
103
+ })
105
104
 
106
- def test_nil_system
107
- config = Nugrant::Config.new({
108
- :params_filename => ".customparams",
109
- :system_path => nil,
110
- })
105
+ assert_equal("#{@user_dir}/.customparams", config.user_path())
106
+ end
111
107
 
112
- assert_equal("#{@system_dir}/.customparams", config.system_path())
113
- end
108
+ def test_nil_system
109
+ config = Nugrant::Config.new({
110
+ :params_filename => ".customparams",
111
+ :system_path => nil,
112
+ })
113
+
114
+ assert_equal("#{@system_dir}/.customparams", config.system_path())
115
+ end
114
116
 
115
- def test_invalid_format
116
- assert_raise(ArgumentError) do
117
- Nugrant::Config.new({:params_format => :invalid})
117
+ def test_invalid_format
118
+ assert_raises(ArgumentError) do
119
+ Nugrant::Config.new({:params_format => :invalid})
120
+ end
118
121
  end
119
122
  end
120
123
  end