Skip to content

Commit decdff8

Browse files
author
Piotr Kuczynski
committed
Fixed tests and updated documentation
1 parent 31974ed commit decdff8

3 files changed

Lines changed: 26 additions & 21 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,8 @@ located at `config/initializers/config.rb`.
252252

253253
### Merge customization
254254

255-
* `knockout_prefix` - ability to remove elements of the array set in earlier loaded settings file. Default: `nil`
256255
* `overwrite_arrays` - overwrite arrays found in previously loaded settings file. Default: `true`
256+
* `knockout_prefix` - ability to remove elements of the array set in earlier loaded settings file. Makes sense only when `overwrite_arrays = false`, otherwise array settings would be overwritten by default. Default: `nil`
257257

258258
Check [Deep Merge](https://github.com/danielsdeleo/deep_merge) for more details.
259259

spec/config_spec.rb

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -122,22 +122,6 @@
122122
end
123123
end
124124

125-
context "Deep Merging" do
126-
let(:config) do
127-
files = ["#{fixture_path}/deep_merge/config1.yml", "#{fixture_path}/deep_merge/config2.yml"]
128-
Config.load_files(files)
129-
end
130-
131-
it "should merge hashes from multiple configs" do
132-
expect(config.inner.marshal_dump.keys.size).to eq(3)
133-
expect(config.inner2.inner2_inner.marshal_dump.keys.size).to eq(3)
134-
end
135-
136-
it "should merge arrays from multiple configs" do
137-
expect(config.arraylist1.size).to eq(6)
138-
expect(config.arraylist2.inner.size).to eq(6)
139-
end
140-
end
141125

142126
context "Boolean Overrides" do
143127
let(:config) do
@@ -301,6 +285,7 @@
301285
context 'merging' do
302286
let(:config) do
303287
Config.knockout_prefix = '--'
288+
Config.overwrite_arrays = false
304289
Config.load_files(["#{fixture_path}/knockout_prefix/config1.yml",
305290
"#{fixture_path}/knockout_prefix/config2.yml",
306291
"#{fixture_path}/knockout_prefix/config3.yml"])
@@ -325,15 +310,15 @@
325310
context 'in configuration phase' do
326311
it 'should be able to assign a different overwrite_arrays value' do
327312
Config.reset
328-
Config.overwrite_arrays = true
313+
Config.overwrite_arrays = false
329314

330-
expect(Config.overwrite_arrays).to eq(true)
315+
expect(Config.overwrite_arrays).to eq(false)
331316
end
332317

333318
it 'should have the default overwrite_arrays value equal false' do
334319
Config.reset
335320

336-
expect(Config.overwrite_arrays).to eq(false)
321+
expect(Config.overwrite_arrays).to eq(true)
337322
end
338323
end
339324

@@ -351,6 +336,26 @@
351336
expect(config.array3).to eq([])
352337
end
353338
end
339+
340+
341+
context 'merging' do
342+
let(:config) do
343+
Config.overwrite_arrays = false
344+
Config.load_files(["#{fixture_path}/deep_merge/config1.yml",
345+
"#{fixture_path}/deep_merge/config2.yml"])
346+
end
347+
348+
it 'should merge hashes from multiple configs' do
349+
expect(config.inner.marshal_dump.keys.size).to eq(3)
350+
expect(config.inner2.inner2_inner.marshal_dump.keys.size).to eq(3)
351+
end
352+
353+
it 'should merge arrays from multiple configs' do
354+
expect(config.arraylist1.size).to eq(6)
355+
expect(config.arraylist2.inner.size).to eq(6)
356+
end
357+
end
358+
354359
end
355360
end
356361
end

spec/spec_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def self.reset
4646
self.const_name = 'Settings'
4747
self.use_env = false
4848
self.knockout_prefix = nil
49-
self.overwrite_arrays = false
49+
self.overwrite_arrays = true
5050
end
5151
end
5252
end

0 commit comments

Comments
 (0)