hiera 3.0.1 → 3.0.5

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 259e9f1b56334fd62e84ca94918da9726f0bae8f
4
+ data.tar.gz: 7fae6afbfbfa9ffc56e3004d80165a1b03c95d05
5
+ SHA512:
6
+ metadata.gz: 57199f18022e40b85f241b8a8f692c6d1f7ca692231db0283e8f8326fb56b57bf11e279b539fafc119f883cdd7d5e540986fdd2ea502a32fa5f1316774d86815
7
+ data.tar.gz: 6a58134a4ef75d8cd4f57cf56f9c0fd88c4a2015ef7e6bd9131103d9a278fc8cc38b8e6eefc761393df35d1c0dc72fff7efa6c3b3ea59a9246d25bdd16396227
@@ -53,7 +53,7 @@ class Hiera
53
53
  @cache[path][:data] = block_given? ? yield(data) : data
54
54
 
55
55
  if !@cache[path][:data].is_a?(expected_type)
56
- raise TypeError, "Data retrieved from #{path} is #{data.class} not #{expected_type}"
56
+ raise TypeError, "Data retrieved from #{path} is #{@cache[path][:data].class} not #{expected_type}"
57
57
  end
58
58
  end
59
59
 
@@ -7,7 +7,7 @@
7
7
 
8
8
 
9
9
  class Hiera
10
- VERSION = "3.0.1"
10
+ VERSION = "3.0.5"
11
11
 
12
12
  ##
13
13
  # version is a public API method intended to always provide a fast and
@@ -35,9 +35,9 @@ class Hiera
35
35
 
36
36
  @cache.expects(:read_file).with("/nonexisting/one.json", Hash).returns({"stringval" => "string", "boolval" => true, "numericval" => 1}).times(3)
37
37
 
38
- @backend.lookup("stringval", {}, nil, :priority, nil).should == "string"
39
- @backend.lookup("boolval", {}, nil, :priority, nil).should == true
40
- @backend.lookup("numericval", {}, nil, :priority, nil).should == 1
38
+ expect(@backend.lookup("stringval", {}, nil, :priority, nil)).to eq("string")
39
+ expect(@backend.lookup("boolval", {}, nil, :priority, nil)).to eq(true)
40
+ expect(@backend.lookup("numericval", {}, nil, :priority, nil)).to eq(1)
41
41
  end
42
42
 
43
43
  it "should pick data earliest source that has it for priority searches" do
@@ -49,7 +49,7 @@ class Hiera
49
49
  File.stubs(:exist?).with("/nonexisting/one.json").returns(true)
50
50
  @cache.expects(:read_file).with("/nonexisting/one.json", Hash).returns({"key" => "test_%{rspec}"})
51
51
 
52
- @backend.lookup("key", scope, nil, :priority, nil).should == "test_test"
52
+ expect(@backend.lookup("key", scope, nil, :priority, nil)).to eq("test_test")
53
53
  end
54
54
 
55
55
  it "should build an array of all data sources for array searches" do
@@ -66,7 +66,7 @@ class Hiera
66
66
  @cache.expects(:read_file).with("/nonexisting/one.json", Hash).returns({"key" => "answer"})
67
67
  @cache.expects(:read_file).with("/nonexisting/two.json", Hash).returns({"key" => "answer"})
68
68
 
69
- @backend.lookup("key", {}, nil, :array, nil).should == ["answer", "answer"]
69
+ expect(@backend.lookup("key", {}, nil, :array, nil)).to eq(["answer", "answer"])
70
70
  end
71
71
 
72
72
  it "should parse the answer for scope variables" do
@@ -77,7 +77,7 @@ class Hiera
77
77
  File.expects(:exist?).with("/nonexisting/one.json").returns(true)
78
78
  @cache.expects(:read_file).with("/nonexisting/one.json", Hash).returns({"key" => "test_%{rspec}"})
79
79
 
80
- @backend.lookup("key", {"rspec" => "test"}, nil, :priority, nil).should == "test_test"
80
+ expect(@backend.lookup("key", {"rspec" => "test"}, nil, :priority, nil)).to eq("test_test")
81
81
  end
82
82
  end
83
83
  end
@@ -41,7 +41,7 @@ class Hiera
41
41
  Backend.expects(:datasourcefiles).with(:yaml, {}, "yaml", nil).yields(["one", "/nonexisting/one.yaml"])
42
42
  @cache.value = "---\nkey: answer"
43
43
 
44
- @backend.lookup("key", {}, nil, :priority, nil).should == "answer"
44
+ expect(@backend.lookup("key", {}, nil, :priority, nil)).to eq("answer")
45
45
  end
46
46
 
47
47
  describe "handling unexpected YAML values" do
@@ -56,7 +56,7 @@ class Hiera
56
56
 
57
57
  it "returns nil when the YAML value is nil" do
58
58
  @cache.value = "key: ~\n"
59
- @backend.lookup("key", {}, nil, :priority, nil).should be_nil
59
+ expect(@backend.lookup("key", {}, nil, :priority, nil)).to be_nil
60
60
  end
61
61
 
62
62
  it "throws :no_such_key when the YAML file is false" do
@@ -75,7 +75,7 @@ class Hiera
75
75
  @cache.expects(:read_file).with("/nonexisting/one.yaml", Hash).returns({"key"=>"answer"})
76
76
  @cache.expects(:read_file).with("/nonexisting/two.yaml", Hash).returns({"key"=>"answer"})
77
77
 
78
- @backend.lookup("key", {}, nil, :array, nil).should == ["answer", "answer"]
78
+ expect(@backend.lookup("key", {}, nil, :array, nil)).to eq(["answer", "answer"])
79
79
  end
80
80
 
81
81
  it "should ignore empty hash of data sources for hash searches" do
@@ -84,7 +84,7 @@ class Hiera
84
84
  @cache.expects(:read_file).with("/nonexisting/one.yaml", Hash).returns({})
85
85
  @cache.expects(:read_file).with("/nonexisting/two.yaml", Hash).returns({"key"=>{"a"=>"answer"}})
86
86
 
87
- @backend.lookup("key", {}, nil, :hash, nil).should == {"a" => "answer"}
87
+ expect(@backend.lookup("key", {}, nil, :hash, nil)).to eq({"a" => "answer"})
88
88
  end
89
89
 
90
90
  it "should build a merged hash of data sources for hash searches" do
@@ -93,7 +93,7 @@ class Hiera
93
93
  @cache.expects(:read_file).with("/nonexisting/one.yaml", Hash).returns({"key"=>{"a"=>"answer"}})
94
94
  @cache.expects(:read_file).with("/nonexisting/two.yaml", Hash).returns({"key"=>{"b"=>"answer", "a"=>"wrong"}})
95
95
 
96
- @backend.lookup("key", {}, nil, :hash, nil).should == {"a" => "answer", "b" => "answer"}
96
+ expect(@backend.lookup("key", {}, nil, :hash, nil)).to eq({"a" => "answer", "b" => "answer"})
97
97
  end
98
98
 
99
99
  it "should fail when trying to << a Hash" do
@@ -119,7 +119,7 @@ class Hiera
119
119
 
120
120
  @cache.expects(:read_file).with("/nonexisting/one.yaml", Hash).returns({"key"=>"test_%{rspec}"})
121
121
 
122
- @backend.lookup("key", {"rspec" => "test"}, nil, :priority, nil).should == "test_test"
122
+ expect(@backend.lookup("key", {"rspec" => "test"}, nil, :priority, nil)).to eq("test_test")
123
123
  end
124
124
 
125
125
  it "should retain datatypes found in yaml files" do
@@ -128,9 +128,9 @@ class Hiera
128
128
 
129
129
  @cache.value = "---\nstringval: 'string'\nboolval: true\nnumericval: 1"
130
130
 
131
- @backend.lookup("stringval", {}, nil, :priority, nil).should == "string"
132
- @backend.lookup("boolval", {}, nil, :priority, nil).should == true
133
- @backend.lookup("numericval", {}, nil, :priority, nil).should == 1
131
+ expect(@backend.lookup("stringval", {}, nil, :priority, nil)).to eq("string")
132
+ expect(@backend.lookup("boolval", {}, nil, :priority, nil)).to eq(true)
133
+ expect(@backend.lookup("numericval", {}, nil, :priority, nil)).to eq(1)
134
134
  end
135
135
  end
136
136
  end
@@ -17,18 +17,18 @@ class Hiera
17
17
 
18
18
  dir = Backend.datadir(:rspec, { "interpolate" => "my_data" })
19
19
 
20
- dir.should == "/tmp/my_data"
20
+ expect(dir).to eq("/tmp/my_data")
21
21
  end
22
22
 
23
23
  it "defaults to a directory in var" do
24
24
  Config.load({})
25
- Backend.datadir(:rspec, { "environment" => "foo" }).should == Hiera::Util.var_dir % { :environment => "foo"}
25
+ expect(Backend.datadir(:rspec, { "environment" => "foo" })).to eq(Hiera::Util.var_dir % { :environment => "foo"})
26
26
 
27
27
  Config.load({:rspec => nil})
28
- Backend.datadir(:rspec, { "environment" => "foo" }).should == Hiera::Util.var_dir % { :environment => "foo"}
28
+ expect(Backend.datadir(:rspec, { "environment" => "foo" })).to eq(Hiera::Util.var_dir % { :environment => "foo"})
29
29
 
30
30
  Config.load({:rspec => {}})
31
- Backend.datadir(:rspec, { "environment" => "foo" }).should == Hiera::Util.var_dir % { :environment => "foo"}
31
+ expect(Backend.datadir(:rspec, { "environment" => "foo" })).to eq(Hiera::Util.var_dir % { :environment => "foo"})
32
32
  end
33
33
 
34
34
  it "fails when the datadir is an array" do
@@ -44,13 +44,13 @@ class Hiera
44
44
  it "translates a non-existant datafile into nil" do
45
45
  Hiera.expects(:debug).with("Cannot find datafile /nonexisting/test.yaml, skipping")
46
46
  Backend.expects(:datadir).returns("/nonexisting")
47
- Backend.datafile(:yaml, {}, "test", "yaml").should == nil
47
+ expect(Backend.datafile(:yaml, {}, "test", "yaml")).to eq(nil)
48
48
  end
49
49
 
50
50
  it "concatenates the datadir and datafile and format to produce the full datafile filename" do
51
51
  Backend.expects(:datadir).returns("/nonexisting")
52
52
  File.expects(:exist?).with("/nonexisting/test.yaml").returns(true)
53
- Backend.datafile(:yaml, {}, "test", "yaml").should == "/nonexisting/test.yaml"
53
+ expect(Backend.datafile(:yaml, {}, "test", "yaml")).to eq("/nonexisting/test.yaml")
54
54
  end
55
55
  end
56
56
 
@@ -58,17 +58,17 @@ class Hiera
58
58
  it "iterates over the datasources in the order of the given hierarchy" do
59
59
  expected = ["one", "two"]
60
60
  Backend.datasources({}, nil, ["one", "two"]) do |backend|
61
- backend.should == expected.delete_at(0)
61
+ expect(backend).to eq(expected.delete_at(0))
62
62
  end
63
63
 
64
- expected.empty?.should == true
64
+ expect(expected.empty?).to eq(true)
65
65
  end
66
66
 
67
67
  it "uses the configured hierarchy no specific hierarchy is given" do
68
68
  Config.load(:hierarchy => "test")
69
69
 
70
70
  Backend.datasources({}) do |backend|
71
- backend.should == "test"
71
+ expect(backend).to eq("test")
72
72
  end
73
73
  end
74
74
 
@@ -76,7 +76,7 @@ class Hiera
76
76
  Config.load({})
77
77
 
78
78
  Backend.datasources({}) do |backend|
79
- backend.should == "common"
79
+ expect(backend).to eq("common")
80
80
  end
81
81
  end
82
82
 
@@ -85,10 +85,10 @@ class Hiera
85
85
 
86
86
  expected = ["override", "common"]
87
87
  Backend.datasources({}, "override") do |backend|
88
- backend.should == expected.delete_at(0)
88
+ expect(backend).to eq(expected.delete_at(0))
89
89
  end
90
90
 
91
- expected.empty?.should == true
91
+ expect(expected.empty?).to eq(true)
92
92
  end
93
93
 
94
94
  it "parses the names of the hierarchy levels using the given scope" do
@@ -102,29 +102,29 @@ class Hiera
102
102
 
103
103
  expected = ["common"]
104
104
  Backend.datasources({}, "%{rspec}") do |backend|
105
- backend.should == expected.delete_at(0)
105
+ expect(backend).to eq(expected.delete_at(0))
106
106
  end
107
107
 
108
- expected.empty?.should == true
108
+ expect(expected.empty?).to eq(true)
109
109
  end
110
110
  end
111
111
 
112
112
  describe "#parse_string" do
113
113
  it "passes nil through untouched" do
114
- Backend.parse_string(nil, {}).should == nil
114
+ expect(Backend.parse_string(nil, {})).to eq(nil)
115
115
  end
116
116
 
117
117
  it "does not modify the input data" do
118
118
  data = "%{value}"
119
119
  Backend.parse_string(data, { "value" => "replacement" })
120
120
 
121
- data.should == "%{value}"
121
+ expect(data).to eq("%{value}")
122
122
  end
123
123
 
124
124
  it "passes non-string data through untouched" do
125
125
  input = { "not a" => "string" }
126
126
 
127
- Backend.parse_string(input, {}).should == input
127
+ expect(Backend.parse_string(input, {})).to eq(input)
128
128
  end
129
129
 
130
130
  @scope_interpolation_tests = {
@@ -138,18 +138,18 @@ class Hiera
138
138
  it "replaces interpolations with data looked up in the scope" do
139
139
  scope = {"part1" => "value of part1", "part2" => "value of part2"}
140
140
 
141
- Backend.parse_string(input, scope).should == expected
141
+ expect(Backend.parse_string(input, scope)).to eq(expected)
142
142
  end
143
143
  end
144
144
 
145
145
  it "replaces interpolations with data looked up in extra_data when scope does not contain the value" do
146
146
  input = "test_%{rspec}_test"
147
- Backend.parse_string(input, {}, {"rspec" => "extra"}).should == "test_extra_test"
147
+ expect(Backend.parse_string(input, {}, {"rspec" => "extra"})).to eq("test_extra_test")
148
148
  end
149
149
 
150
150
  it "prefers data from scope over data from extra_data" do
151
151
  input = "test_%{rspec}_test"
152
- Backend.parse_string(input, {"rspec" => "test"}, {"rspec" => "fail"}).should == "test_test_test"
152
+ expect(Backend.parse_string(input, {"rspec" => "test"}, {"rspec" => "fail"})).to eq("test_test_test")
153
153
  end
154
154
 
155
155
  @interprets_nil_in_scope_tests = {
@@ -159,7 +159,7 @@ class Hiera
159
159
 
160
160
  @interprets_nil_in_scope_tests.each do |input, expected|
161
161
  it "interprets nil in scope as a non-value" do
162
- Backend.parse_string(input, {"rspec" => nil}).should == expected
162
+ expect(Backend.parse_string(input, {"rspec" => nil})).to eq(expected)
163
163
  end
164
164
  end
165
165
 
@@ -171,18 +171,18 @@ class Hiera
171
171
  @interprets_false_in_scope_tests.each do |input, expected|
172
172
  it "interprets false in scope as a real value" do
173
173
  input = "test_%{scope('rspec')}_test"
174
- Backend.parse_string(input, {"rspec" => false}).should == expected
174
+ expect(Backend.parse_string(input, {"rspec" => false})).to eq(expected)
175
175
  end
176
176
  end
177
177
 
178
178
  it "interprets false in extra_data as a real value" do
179
179
  input = "test_%{rspec}_test"
180
- Backend.parse_string(input, {}, {"rspec" => false}).should == "test_false_test"
180
+ expect(Backend.parse_string(input, {}, {"rspec" => false})).to eq("test_false_test")
181
181
  end
182
182
 
183
183
  it "interprets nil in extra_data as a non-value" do
184
184
  input = "test_%{rspec}_test"
185
- Backend.parse_string(input, {}, {"rspec" => nil}).should == "test__test"
185
+ expect(Backend.parse_string(input, {}, {"rspec" => nil})).to eq("test__test")
186
186
  end
187
187
 
188
188
  @interprets_undefined_in_scope_tests = {
@@ -197,7 +197,7 @@ class Hiera
197
197
 
198
198
  @exact_lookup_tests.each do |input, expected|
199
199
  it "looks up the interpolated value exactly as it appears in the input" do
200
- Backend.parse_string(input, {"::rspec::data" => "value"}).should == expected
200
+ expect(Backend.parse_string(input, {"::rspec::data" => "value"})).to eq(expected)
201
201
  end
202
202
  end
203
203
 
@@ -207,7 +207,7 @@ class Hiera
207
207
  }
208
208
  @surrounding_whitespace_tests.each do |input, expected|
209
209
  it "does not remove any surrounding whitespace when parsing the key to lookup" do
210
- Backend.parse_string(input, {"\trspec::data " => "value"}).should == expected
210
+ expect(Backend.parse_string(input, {"\trspec::data " => "value"})).to eq(expected)
211
211
  end
212
212
  end
213
213
 
@@ -218,7 +218,7 @@ class Hiera
218
218
 
219
219
  @leading_double_colon_tests.each do |input, expected|
220
220
  it "does not try removing leading :: when a full lookup fails (#17434)" do
221
- Backend.parse_string(input, {"rspec::data" => "value"}).should == expected
221
+ expect(Backend.parse_string(input, {"rspec::data" => "value"})).to eq(expected)
222
222
  end
223
223
  end
224
224
 
@@ -228,19 +228,19 @@ class Hiera
228
228
  }
229
229
  @double_colon_key_tests.each do |input, expected|
230
230
  it "does not try removing leading sections separated by :: when a full lookup fails (#17434)" do
231
- Backend.parse_string(input, {"data" => "value"}).should == expected
231
+ expect(Backend.parse_string(input, {"data" => "value"})).to eq(expected)
232
232
  end
233
233
  end
234
234
 
235
235
  it "does not try removing unknown, preceeding characters when looking up values" do
236
236
  input = "test_%{$var}_test"
237
- Backend.parse_string(input, {"$var" => "value"}).should == "test_value_test"
237
+ expect(Backend.parse_string(input, {"$var" => "value"})).to eq("test_value_test")
238
238
  end
239
239
 
240
240
  it "looks up recursively" do
241
241
  scope = {"rspec" => "%{first}", "first" => "%{last}", "last" => "final"}
242
242
  input = "test_%{rspec}_test"
243
- Backend.parse_string(input, scope).should == "test_final_test"
243
+ expect(Backend.parse_string(input, scope)).to eq("test_final_test")
244
244
  end
245
245
 
246
246
  it "raises an error if the recursive lookup results in an infinite loop" do
@@ -254,7 +254,7 @@ class Hiera
254
254
  it "replaces repeated occurances of the same lookup" do
255
255
  scope = {"rspec" => "value"}
256
256
  input = "it replaces %{rspec} and %{rspec}"
257
- Backend.parse_string(input, scope).should == "it replaces value and value"
257
+ expect(Backend.parse_string(input, scope)).to eq("it replaces value and value")
258
258
  end
259
259
 
260
260
  it "replaces hiera interpolations with data looked up in hiera" do
@@ -264,7 +264,7 @@ class Hiera
264
264
  Config.load_backends
265
265
  Backend::Yaml_backend.any_instance.stubs(:lookup).with("key1", scope, nil, :priority, instance_of(Hash)).returns("answer")
266
266
 
267
- Backend.parse_string(input, scope).should == "answer"
267
+ expect(Backend.parse_string(input, scope)).to eq("answer")
268
268
  end
269
269
 
270
270
  it "interpolation passes the order_override back into the backend" do
@@ -275,39 +275,39 @@ class Hiera
275
275
  it "replaces literal interpolations with their argument" do
276
276
  scope = {}
277
277
  input = "%{literal('%')}{rspec::data}"
278
- Backend.parse_string(input, scope).should == "%{rspec::data}"
278
+ expect(Backend.parse_string(input, scope)).to eq("%{rspec::data}")
279
279
  end
280
280
  end
281
281
 
282
282
  describe "#parse_answer" do
283
283
  it "interpolates values in strings" do
284
284
  input = "test_%{rspec}_test"
285
- Backend.parse_answer(input, {"rspec" => "test"}).should == "test_test_test"
285
+ expect(Backend.parse_answer(input, {"rspec" => "test"})).to eq("test_test_test")
286
286
  end
287
287
 
288
288
  it "interpolates each string in an array" do
289
289
  input = ["test_%{rspec}_test", "test_%{rspec}_test", ["test_%{rspec}_test"]]
290
- Backend.parse_answer(input, {"rspec" => "test"}).should == ["test_test_test", "test_test_test", ["test_test_test"]]
290
+ expect(Backend.parse_answer(input, {"rspec" => "test"})).to eq(["test_test_test", "test_test_test", ["test_test_test"]])
291
291
  end
292
292
 
293
293
  it "interpolates each string in a hash" do
294
294
  input = {"foo" => "test_%{rspec}_test", "bar" => "test_%{rspec}_test"}
295
- Backend.parse_answer(input, {"rspec" => "test"}).should == {"foo"=>"test_test_test", "bar"=>"test_test_test"}
295
+ expect(Backend.parse_answer(input, {"rspec" => "test"})).to eq({"foo"=>"test_test_test", "bar"=>"test_test_test"})
296
296
  end
297
297
 
298
298
  it "interpolates string in hash keys" do
299
299
  input = {"%{rspec}" => "test"}
300
- Backend.parse_answer(input, {"rspec" => "foo"}).should == {"foo"=>"test"}
300
+ expect(Backend.parse_answer(input, {"rspec" => "foo"})).to eq({"foo"=>"test"})
301
301
  end
302
302
 
303
303
  it "interpolates strings in nested hash keys" do
304
304
  input = {"topkey" => {"%{rspec}" => "test"}}
305
- Backend.parse_answer(input, {"rspec" => "foo"}).should == {"topkey"=>{"foo" => "test"}}
305
+ expect(Backend.parse_answer(input, {"rspec" => "foo"})).to eq({"topkey"=>{"foo" => "test"}})
306
306
  end
307
307
 
308
308
  it "interpolates strings in a mixed structure of arrays and hashes" do
309
309
  input = {"foo" => "test_%{rspec}_test", "bar" => ["test_%{rspec}_test", "test_%{rspec}_test"]}
310
- Backend.parse_answer(input, {"rspec" => "test"}).should == {"foo"=>"test_test_test", "bar"=>["test_test_test", "test_test_test"]}
310
+ expect(Backend.parse_answer(input, {"rspec" => "test"})).to eq({"foo"=>"test_test_test", "bar"=>["test_test_test", "test_test_test"]})
311
311
  end
312
312
 
313
313
  it "interpolates hiera lookups values in strings" do
@@ -316,7 +316,7 @@ class Hiera
316
316
  Config.load({:yaml => {:datadir => "/tmp"}})
317
317
  Config.load_backends
318
318
  Backend::Yaml_backend.any_instance.stubs(:lookup).with("rspec", scope, nil, :priority, instance_of(Hash)).returns("test")
319
- Backend.parse_answer(input, scope).should == "test_test_test"
319
+ expect(Backend.parse_answer(input, scope)).to eq("test_test_test")
320
320
  end
321
321
 
322
322
  it "interpolates alias lookups with non-string types" do
@@ -325,7 +325,7 @@ class Hiera
325
325
  Config.load({:yaml => {:datadir => "/tmp"}})
326
326
  Config.load_backends
327
327
  Backend::Yaml_backend.any_instance.stubs(:lookup).with("rspec", scope, nil, :priority, instance_of(Hash)).returns(['test', 'test'])
328
- Backend.parse_answer(input, scope).should == ['test', 'test']
328
+ expect(Backend.parse_answer(input, scope)).to eq(['test', 'test'])
329
329
  end
330
330
 
331
331
  it 'fails if alias interpolation is attempted in a string context with a prefix' do
@@ -335,7 +335,7 @@ class Hiera
335
335
  Config.load_backends
336
336
  Backend::Yaml_backend.any_instance.stubs(:lookup).with("rspec", scope, nil, :priority, instance_of(Hash)).returns(['test', 'test'])
337
337
  expect do
338
- Backend.parse_answer(input, scope).should == ['test', 'test']
338
+ expect(Backend.parse_answer(input, scope)).to eq(['test', 'test'])
339
339
  end.to raise_error(Hiera::InterpolationInvalidValue, 'Cannot call alias in the string context')
340
340
  end
341
341
 
@@ -346,7 +346,7 @@ class Hiera
346
346
  Config.load_backends
347
347
  Backend::Yaml_backend.any_instance.stubs(:lookup).with("rspec", scope, nil, :priority, instance_of(Hash)).returns(['test', 'test'])
348
348
  expect do
349
- Backend.parse_answer(input, scope).should == ['test', 'test']
349
+ expect(Backend.parse_answer(input, scope)).to eq(['test', 'test'])
350
350
  end.to raise_error(Hiera::InterpolationInvalidValue, 'Cannot call alias in the string context')
351
351
  end
352
352
 
@@ -356,7 +356,7 @@ class Hiera
356
356
  Config.load({:yaml => {:datadir => "/tmp"}})
357
357
  Config.load_backends
358
358
  Backend::Yaml_backend.any_instance.stubs(:lookup).with("rspec", scope, nil, :priority, instance_of(Hash)).returns("test")
359
- Backend.parse_answer(input, scope).should == ["test_test_test", "test_test_test", ["test_test_test"]]
359
+ expect(Backend.parse_answer(input, scope)).to eq(["test_test_test", "test_test_test", ["test_test_test"]])
360
360
  end
361
361
 
362
362
  it "interpolates hiera lookups in each string in a hash" do
@@ -365,7 +365,7 @@ class Hiera
365
365
  Config.load({:yaml => {:datadir => "/tmp"}})
366
366
  Config.load_backends
367
367
  Backend::Yaml_backend.any_instance.stubs(:lookup).with("rspec", scope, nil, :priority, instance_of(Hash)).returns("test")
368
- Backend.parse_answer(input, scope).should == {"foo"=>"test_test_test", "bar"=>"test_test_test"}
368
+ expect(Backend.parse_answer(input, scope)).to eq({"foo"=>"test_test_test", "bar"=>"test_test_test"})
369
369
  end
370
370
 
371
371
  it "interpolates hiera lookups in string in hash keys" do
@@ -374,7 +374,7 @@ class Hiera
374
374
  Config.load({:yaml => {:datadir => "/tmp"}})
375
375
  Config.load_backends
376
376
  Backend::Yaml_backend.any_instance.stubs(:lookup).with("rspec", scope, nil, :priority, instance_of(Hash)).returns("foo")
377
- Backend.parse_answer(input, scope).should == {"foo"=>"test"}
377
+ expect(Backend.parse_answer(input, scope)).to eq({"foo"=>"test"})
378
378
  end
379
379
 
380
380
  it "interpolates hiera lookups in strings in nested hash keys" do
@@ -383,7 +383,7 @@ class Hiera
383
383
  Config.load({:yaml => {:datadir => "/tmp"}})
384
384
  Config.load_backends
385
385
  Backend::Yaml_backend.any_instance.stubs(:lookup).with("rspec", scope, nil, :priority, instance_of(Hash)).returns("foo")
386
- Backend.parse_answer(input, scope).should == {"topkey"=>{"foo" => "test"}}
386
+ expect(Backend.parse_answer(input, scope)).to eq({"topkey"=>{"foo" => "test"}})
387
387
  end
388
388
 
389
389
  it "interpolates hiera lookups in strings in a mixed structure of arrays and hashes" do
@@ -392,7 +392,7 @@ class Hiera
392
392
  Config.load({:yaml => {:datadir => "/tmp"}})
393
393
  Config.load_backends
394
394
  Backend::Yaml_backend.any_instance.stubs(:lookup).with("rspec", scope, nil, :priority, instance_of(Hash)).returns("test")
395
- Backend.parse_answer(input, scope).should == {"foo"=>"test_test_test", "bar"=>["test_test_test", "test_test_test"]}
395
+ expect(Backend.parse_answer(input, scope)).to eq({"foo"=>"test_test_test", "bar"=>["test_test_test", "test_test_test"]})
396
396
  end
397
397
 
398
398
  it "interpolates hiera lookups and scope lookups in the same string" do
@@ -401,7 +401,7 @@ class Hiera
401
401
  Config.load({:yaml => {:datadir => "/tmp"}})
402
402
  Config.load_backends
403
403
  Backend::Yaml_backend.any_instance.stubs(:lookup).with("rspec", scope, nil, :priority, instance_of(Hash)).returns("hiera_rspec")
404
- Backend.parse_answer(input, scope).should == {"foo"=>"test_hiera_rspec_test", "bar"=>"test_scope_rspec_test"}
404
+ expect(Backend.parse_answer(input, scope)).to eq({"foo"=>"test_hiera_rspec_test", "bar"=>"test_scope_rspec_test"})
405
405
  end
406
406
 
407
407
  it "interpolates hiera and scope lookups with the same lookup query in a single string" do
@@ -410,43 +410,43 @@ class Hiera
410
410
  Config.load({:yaml => {:datadir => "/tmp"}})
411
411
  Config.load_backends
412
412
  Backend::Yaml_backend.any_instance.stubs(:lookup).with("rspec", scope, nil, :priority, instance_of(Hash)).returns("hiera_rspec")
413
- Backend.parse_answer(input, scope).should == "test_hiera_rspec_test_scope_rspec"
413
+ expect(Backend.parse_answer(input, scope)).to eq("test_hiera_rspec_test_scope_rspec")
414
414
  end
415
415
 
416
416
  it "passes integers unchanged" do
417
417
  input = 1
418
- Backend.parse_answer(input, {"rspec" => "test"}).should == 1
418
+ expect(Backend.parse_answer(input, {"rspec" => "test"})).to eq(1)
419
419
  end
420
420
 
421
421
  it "passes floats unchanged" do
422
422
  input = 0.233
423
- Backend.parse_answer(input, {"rspec" => "test"}).should == 0.233
423
+ expect(Backend.parse_answer(input, {"rspec" => "test"})).to eq(0.233)
424
424
  end
425
425
 
426
426
  it "passes the boolean true unchanged" do
427
427
  input = true
428
- Backend.parse_answer(input, {"rspec" => "test"}).should == true
428
+ expect(Backend.parse_answer(input, {"rspec" => "test"})).to eq(true)
429
429
  end
430
430
 
431
431
  it "passes the boolean false unchanged" do
432
432
  input = false
433
- Backend.parse_answer(input, {"rspec" => "test"}).should == false
433
+ expect(Backend.parse_answer(input, {"rspec" => "test"})).to eq(false)
434
434
  end
435
435
 
436
436
  it "interpolates lookups using single or double quotes" do
437
437
  input = "test_%{scope(\"rspec\")}_test_%{scope('rspec')}"
438
438
  scope = {"rspec" => "scope_rspec"}
439
- Backend.parse_answer(input, scope).should == "test_scope_rspec_test_scope_rspec"
439
+ expect(Backend.parse_answer(input, scope)).to eq("test_scope_rspec_test_scope_rspec")
440
440
  end
441
441
  end
442
442
 
443
443
  describe "#resolve_answer" do
444
444
  it "flattens and removes duplicate values from arrays during an array lookup" do
445
- Backend.resolve_answer(["foo", ["foo", "foo"], "bar"], :array).should == ["foo", "bar"]
445
+ expect(Backend.resolve_answer(["foo", ["foo", "foo"], "bar"], :array)).to eq(["foo", "bar"])
446
446
  end
447
447
 
448
448
  it "returns the data unchanged during a priority lookup" do
449
- Backend.resolve_answer(["foo", ["foo", "foo"], "bar"], :priority).should == ["foo", ["foo", "foo"], "bar"]
449
+ expect(Backend.resolve_answer(["foo", ["foo", "foo"], "bar"], :priority)).to eq(["foo", ["foo", "foo"], "bar"])
450
450
  end
451
451
  end
452
452
 
@@ -473,7 +473,7 @@ class Hiera
473
473
 
474
474
  Backend::Yaml_backend.any_instance.expects(:lookup).with("key", {}, nil, nil, instance_of(Hash)).returns("answer")
475
475
 
476
- Backend.lookup("key", "default", {}, nil, nil).should == "answer"
476
+ expect(Backend.lookup("key", "default", {}, nil, nil)).to eq("answer")
477
477
  end
478
478
 
479
479
  it "retains the datatypes as returned by the backend" do
@@ -484,9 +484,9 @@ class Hiera
484
484
  Backend::Yaml_backend.any_instance.expects(:lookup).with("boolval", {}, nil, nil, instance_of(Hash)).returns(false)
485
485
  Backend::Yaml_backend.any_instance.expects(:lookup).with("numericval", {}, nil, nil, instance_of(Hash)).returns(1)
486
486
 
487
- Backend.lookup("stringval", "default", {}, nil, nil).should == "string"
488
- Backend.lookup("boolval", "default", {}, nil, nil).should == false
489
- Backend.lookup("numericval", "default", {}, nil, nil).should == 1
487
+ expect(Backend.lookup("stringval", "default", {}, nil, nil)).to eq("string")
488
+ expect(Backend.lookup("boolval", "default", {}, nil, nil)).to eq(false)
489
+ expect(Backend.lookup("numericval", "default", {}, nil, nil)).to eq(1)
490
490
  end
491
491
 
492
492
  it "calls to all backends till an answer is found" do
@@ -498,7 +498,7 @@ class Hiera
498
498
  #Backend::Yaml_backend.any_instance.expects(:lookup).with("key", {"rspec" => "test"}, nil, nil)
499
499
  Backend.expects(:constants).returns(["Yaml_backend", "Rspec_backend"]).twice
500
500
 
501
- Backend.lookup("key", "test_%{rspec}", {"rspec" => "test"}, nil, nil).should == "answer"
501
+ expect(Backend.lookup("key", "test_%{rspec}", {"rspec" => "test"}, nil, nil)).to eq("answer")
502
502
  end
503
503
 
504
504
  it "calls to all backends till an answer is found when doing array lookups" do
@@ -509,7 +509,7 @@ class Hiera
509
509
  Backend.instance_variable_set("@backends", {"rspec" => backend})
510
510
  Backend.expects(:constants).returns(["Yaml_backend", "Rspec_backend"]).twice
511
511
 
512
- Backend.lookup("key", "notfound", {"rspec" => "test"}, nil, :array).should == ["answer"]
512
+ expect(Backend.lookup("key", "notfound", {"rspec" => "test"}, nil, :array)).to eq(["answer"])
513
513
  end
514
514
 
515
515
  it "calls to all backends till an answer is found when doing hash lookups" do
@@ -521,7 +521,7 @@ class Hiera
521
521
  Backend.instance_variable_set("@backends", {"rspec" => backend})
522
522
  Backend.expects(:constants).returns(["Yaml_backend", "Rspec_backend"]).twice
523
523
 
524
- Backend.lookup("key", "notfound", {"rspec" => "test"}, nil, :hash).should == thehash
524
+ expect(Backend.lookup("key", "notfound", {"rspec" => "test"}, nil, :hash)).to eq(thehash)
525
525
  end
526
526
 
527
527
  it "builds a merged hash from all backends for hash searches" do
@@ -532,7 +532,7 @@ class Hiera
532
532
  Backend.instance_variable_set("@backends", {"first" => backend1, "second" => backend2})
533
533
  Backend.stubs(:constants).returns(["First_backend", "Second_backend"])
534
534
 
535
- Backend.lookup("key", {}, {"rspec" => "test"}, nil, :hash).should == {"a" => "answer", "b" => "bnswer"}
535
+ expect(Backend.lookup("key", {}, {"rspec" => "test"}, nil, :hash)).to eq({"a" => "answer", "b" => "bnswer"})
536
536
  end
537
537
 
538
538
  it "builds an array from all backends for array searches" do
@@ -543,7 +543,7 @@ class Hiera
543
543
  Backend.instance_variable_set("@backends", {"first" => backend1, "second" => backend2})
544
544
  Backend.stubs(:constants).returns(["First_backend", "Second_backend"])
545
545
 
546
- Backend.lookup("key", {}, {"rspec" => "test"}, nil, :array).should == ["a", "b", "c", "d"]
546
+ expect(Backend.lookup("key", {}, {"rspec" => "test"}, nil, :array)).to eq(["a", "b", "c", "d"])
547
547
  end
548
548
 
549
549
  it "uses the earliest backend result for priority searches" do
@@ -556,7 +556,7 @@ class Hiera
556
556
  Backend.instance_variable_set("@backends", {"first" => backend1, "second" => backend2})
557
557
  Backend.stubs(:constants).returns(["First_backend", "Second_backend"])
558
558
 
559
- Backend.lookup("key", {}, {"rspec" => "test"}, nil, :priority).should == ["a", "b"]
559
+ expect(Backend.lookup("key", {}, {"rspec" => "test"}, nil, :priority)).to eq(["a", "b"])
560
560
  end
561
561
 
562
562
  it "parses the answers based on resolution_type" do
@@ -566,7 +566,7 @@ class Hiera
566
566
  Backend.expects(:resolve_answer).with("test_test", :priority).returns("parsed")
567
567
  Backend::Yaml_backend.any_instance.expects(:lookup).with("key", {"rspec" => "test"}, nil, :priority, instance_of(Hash)).returns("test_test")
568
568
 
569
- Backend.lookup("key", "test_%{rspec}", {"rspec" => "test"}, nil, :priority).should == "parsed"
569
+ expect(Backend.lookup("key", "test_%{rspec}", {"rspec" => "test"}, nil, :priority)).to eq("parsed")
570
570
  end
571
571
 
572
572
  it "returns the default with variables parsed if nothing is found" do
@@ -575,7 +575,7 @@ class Hiera
575
575
 
576
576
  Backend::Yaml_backend.any_instance.expects(:lookup).with("key", {"rspec" => "test"}, nil, nil, instance_of(Hash)).throws(:no_such_key)
577
577
 
578
- Backend.lookup("key", "test_%{rspec}", {"rspec" => "test"}, nil, nil).should == "test_test"
578
+ expect(Backend.lookup("key", "test_%{rspec}", {"rspec" => "test"}, nil, nil)).to eq("test_test")
579
579
  end
580
580
 
581
581
  it "returns nil instead of the default when key is found with a nil value" do
@@ -584,42 +584,42 @@ class Hiera
584
584
 
585
585
  Backend::Yaml_backend.any_instance.expects(:lookup).with("key", {"rspec" => "test"}, nil, nil, instance_of(Hash)).returns(nil)
586
586
 
587
- Backend.lookup("key", "test_%{rspec}", {"rspec" => "test"}, nil, nil).should == nil
587
+ expect(Backend.lookup("key", "test_%{rspec}", {"rspec" => "test"}, nil, nil)).to eq(nil)
588
588
  end
589
589
 
590
590
  it "keeps string default data as a string" do
591
591
  Config.load({:yaml => {:datadir => "/tmp"}})
592
592
  Config.load_backends
593
593
  Backend::Yaml_backend.any_instance.expects(:lookup).with("key", {}, nil, nil, instance_of(Hash)).throws(:no_such_key)
594
- Backend.lookup("key", "test", {}, nil, nil).should == "test"
594
+ expect(Backend.lookup("key", "test", {}, nil, nil)).to eq("test")
595
595
  end
596
596
 
597
597
  it "keeps array default data as an array" do
598
598
  Config.load({:yaml => {:datadir => "/tmp"}})
599
599
  Config.load_backends
600
600
  Backend::Yaml_backend.any_instance.expects(:lookup).with("key", {}, nil, :array, instance_of(Hash)).throws(:no_such_key)
601
- Backend.lookup("key", ["test"], {}, nil, :array).should == ["test"]
601
+ expect(Backend.lookup("key", ["test"], {}, nil, :array)).to eq(["test"])
602
602
  end
603
603
 
604
604
  it "keeps hash default data as a hash" do
605
605
  Config.load({:yaml => {:datadir => "/tmp"}})
606
606
  Config.load_backends
607
607
  Backend::Yaml_backend.any_instance.expects(:lookup).with("key", {}, nil, :hash, instance_of(Hash)).throws(:no_such_key)
608
- Backend.lookup("key", {"test" => "value"}, {}, nil, :hash).should == {"test" => "value"}
608
+ expect(Backend.lookup("key", {"test" => "value"}, {}, nil, :hash)).to eq({"test" => "value"})
609
609
  end
610
610
 
611
611
  it 'can use qualified key to lookup value in hash' do
612
612
  Config.load({:yaml => {:datadir => '/tmp'}})
613
613
  Config.load_backends
614
614
  Backend::Yaml_backend.any_instance.expects(:lookup).with('key', {}, nil, nil, instance_of(Hash)).returns({ 'test' => 'value'})
615
- Backend.lookup('key.test', 'dflt', {}, nil, nil).should == 'value'
615
+ expect(Backend.lookup('key.test', 'dflt', {}, nil, nil)).to eq('value')
616
616
  end
617
617
 
618
618
  it 'can use qualified key to lookup value in array' do
619
619
  Config.load({:yaml => {:datadir => '/tmp'}})
620
620
  Config.load_backends
621
621
  Backend::Yaml_backend.any_instance.expects(:lookup).with('key', {}, nil, nil, instance_of(Hash)).returns([ 'first', 'second'])
622
- Backend.lookup('key.1', 'dflt', {}, nil, nil).should == 'second'
622
+ expect(Backend.lookup('key.1', 'dflt', {}, nil, nil)).to eq('second')
623
623
  end
624
624
 
625
625
  it 'will fail when qualified key is partially found but not expected hash' do
@@ -647,7 +647,7 @@ class Hiera
647
647
  Config.load({:yaml => {:datadir => '/tmp'}})
648
648
  Config.load_backends
649
649
  Backend::Yaml_backend.any_instance.expects(:lookup).with('key', {}, nil, :priority, instance_of(Hash)).returns({ 'test' => 'value'})
650
- Backend.lookup('key.test', 'dflt', {}, nil, :priority).should == 'value'
650
+ expect(Backend.lookup('key.test', 'dflt', {}, nil, :priority)).to eq('value')
651
651
  end
652
652
 
653
653
  it 'will fail when qualified key is partially found but not expected array' do
@@ -663,14 +663,14 @@ class Hiera
663
663
  Config.load({:yaml => {:datadir => '/tmp'}})
664
664
  Config.load_backends
665
665
  Backend::Yaml_backend.any_instance.expects(:lookup).with('key', {}, nil, nil, instance_of(Hash)).returns(nil)
666
- Backend.lookup('key.test', 'dflt', {}, nil, nil).should == 'dflt'
666
+ expect(Backend.lookup('key.test', 'dflt', {}, nil, nil)).to eq('dflt')
667
667
  end
668
668
 
669
669
  it 'will not fail when qualified key is array index out of bounds' do
670
670
  Config.load({:yaml => {:datadir => '/tmp'}})
671
671
  Config.load_backends
672
672
  Backend::Yaml_backend.any_instance.expects(:lookup).with('key', {}, nil, nil, instance_of(Hash)).returns(['value 1', 'value 2'])
673
- Backend.lookup('key.33', 'dflt', {}, nil, nil).should == 'dflt'
673
+ expect(Backend.lookup('key.33', 'dflt', {}, nil, nil)).to eq('dflt')
674
674
  end
675
675
 
676
676
  it 'can use qualified key in interpolation to lookup value in hash' do
@@ -678,7 +678,7 @@ class Hiera
678
678
  Config.load_backends
679
679
  Hiera::Backend.stubs(:datasourcefiles).yields('foo', 'bar')
680
680
  Hiera::Filecache.any_instance.expects(:read_file).at_most(2).returns({'key' => '%{hiera(\'some.subkey\')}', 'some' => { 'subkey' => 'value' }})
681
- Backend.lookup('key', 'dflt', {}, nil, nil).should == 'value'
681
+ expect(Backend.lookup('key', 'dflt', {}, nil, nil)).to eq('value')
682
682
  end
683
683
 
684
684
  it 'can use qualified key in interpolated default and scope' do
@@ -686,7 +686,7 @@ class Hiera
686
686
  Config.load_backends
687
687
  scope = { 'some' => { 'test' => 'value'}}
688
688
  Backend::Yaml_backend.any_instance.expects(:lookup).with('key', scope, nil, nil, instance_of(Hash))
689
- Backend.lookup('key.notfound', '%{some.test}', scope, nil, nil).should == 'value'
689
+ expect(Backend.lookup('key.notfound', '%{some.test}', scope, nil, nil)).to eq('value')
690
690
  end
691
691
 
692
692
  it "handles older backend with 4 argument lookup" do
@@ -694,7 +694,7 @@ class Hiera
694
694
  Config.instance_variable_set("@config", {:backends => ["Backend1x"]})
695
695
 
696
696
  Hiera.expects(:debug).at_least_once.with(regexp_matches /Using Hiera 1.x backend/)
697
- Backend.lookup("key", {}, {"rspec" => "test"}, nil, :priority).should == ["a", "b"]
697
+ expect(Backend.lookup("key", {}, {"rspec" => "test"}, nil, :priority)).to eq(["a", "b"])
698
698
  end
699
699
  end
700
700
 
@@ -708,36 +708,36 @@ class Hiera
708
708
  it "uses Hash.merge when configured with :merge_behavior => :native" do
709
709
  Config.load({:merge_behavior => :native})
710
710
  Hash.any_instance.expects(:merge).with({"b" => "bnswer"}).returns({"a" => "answer", "b" => "bnswer"})
711
- Backend.merge_answer({"a" => "answer"},{"b" => "bnswer"}).should == {"a" => "answer", "b" => "bnswer"}
711
+ expect(Backend.merge_answer({"a" => "answer"},{"b" => "bnswer"})).to eq({"a" => "answer", "b" => "bnswer"})
712
712
  end
713
713
 
714
714
  it "uses deep_merge! when configured with :merge_behavior => :deeper" do
715
715
  Config.load({:merge_behavior => :deeper})
716
716
  Hash.any_instance.expects('deep_merge!').with({"b" => "bnswer"}, {}).returns({"a" => "answer", "b" => "bnswer"})
717
- Backend.merge_answer({"a" => "answer"},{"b" => "bnswer"}).should == {"a" => "answer", "b" => "bnswer"}
717
+ expect(Backend.merge_answer({"a" => "answer"},{"b" => "bnswer"})).to eq({"a" => "answer", "b" => "bnswer"})
718
718
  end
719
719
 
720
720
  it "uses deep_merge when configured with :merge_behavior => :deep" do
721
721
  Config.load({:merge_behavior => :deep})
722
722
  Hash.any_instance.expects('deep_merge').with({"b" => "bnswer"}, {}).returns({"a" => "answer", "b" => "bnswer"})
723
- Backend.merge_answer({"a" => "answer"},{"b" => "bnswer"}).should == {"a" => "answer", "b" => "bnswer"}
723
+ expect(Backend.merge_answer({"a" => "answer"},{"b" => "bnswer"})).to eq({"a" => "answer", "b" => "bnswer"})
724
724
  end
725
725
 
726
726
  it "disregards configuration when 'merge' parameter is given as a Hash" do
727
727
  Config.load({:merge_behavior => :deep})
728
728
  Hash.any_instance.expects('deep_merge!').with({"b" => "bnswer"}, {}).returns({"a" => "answer", "b" => "bnswer"})
729
- Backend.merge_answer({"a" => "answer"},{"b" => "bnswer"}, {:behavior => 'deeper' }).should == {"a" => "answer", "b" => "bnswer"}
729
+ expect(Backend.merge_answer({"a" => "answer"},{"b" => "bnswer"}, {:behavior => 'deeper' })).to eq({"a" => "answer", "b" => "bnswer"})
730
730
  end
731
731
 
732
732
  it "propagates deep merge options when given Hash 'merge' parameter" do
733
733
  Hash.any_instance.expects('deep_merge!').with({"b" => "bnswer"}, { :knockout_prefix => '-' }).returns({"a" => "answer", "b" => "bnswer"})
734
- Backend.merge_answer({"a" => "answer"},{"b" => "bnswer"}, {:behavior => 'deeper', :knockout_prefix => '-'}).should == {"a" => "answer", "b" => "bnswer"}
734
+ expect(Backend.merge_answer({"a" => "answer"},{"b" => "bnswer"}, {:behavior => 'deeper', :knockout_prefix => '-'})).to eq({"a" => "answer", "b" => "bnswer"})
735
735
  end
736
736
 
737
737
  it "passes Config[:deep_merge_options] into calls to deep_merge" do
738
738
  Config.load({:merge_behavior => :deep, :deep_merge_options => { :knockout_prefix => '-' } })
739
739
  Hash.any_instance.expects('deep_merge').with({"b" => "bnswer"}, {:knockout_prefix => '-'}).returns({"a" => "answer", "b" => "bnswer"})
740
- Backend.merge_answer({"a" => "answer"},{"b" => "bnswer"}).should == {"a" => "answer", "b" => "bnswer"}
740
+ expect(Backend.merge_answer({"a" => "answer"},{"b" => "bnswer"})).to eq({"a" => "answer", "b" => "bnswer"})
741
741
  end
742
742
  end
743
743
  end
@@ -12,10 +12,6 @@ class Hiera
12
12
  }
13
13
  end
14
14
 
15
- it "should treat string sources as a filename" do
16
- expect { Config.load("/nonexisting") }.to raise_error
17
- end
18
-
19
15
  it "should raise an error for missing config files" do
20
16
  File.expects(:exist?).with("/nonexisting").returns(false)
21
17
  YAML.expects(:load_file).with("/nonexisting").never
@@ -34,23 +30,23 @@ class Hiera
34
30
  File.expects(:exist?).with("/nonexisting").returns(true)
35
31
  YAML.expects(:load_file).with("/nonexisting").returns(YAML.load(""))
36
32
 
37
- Config.load("/nonexisting").should == default_config
33
+ expect(Config.load("/nonexisting")).to eq(default_config)
38
34
  end
39
35
 
40
36
  it "should use hash data as source if supplied" do
41
37
  config = Config.load({"rspec" => "test"})
42
- config["rspec"].should == "test"
38
+ expect(config["rspec"]).to eq("test")
43
39
  end
44
40
 
45
41
  it "should merge defaults with the loaded or supplied config" do
46
42
  config = Config.load({})
47
- config.should == {:backends => ["yaml"], :hierarchy => ['nodes/%{::trusted.certname}', 'common'],
48
- :logger => "console", :merge_behavior=>:native}
43
+ expect(config).to eq({:backends => ["yaml"], :hierarchy => ['nodes/%{::trusted.certname}', 'common'],
44
+ :logger => "console", :merge_behavior=>:native})
49
45
  end
50
46
 
51
47
  it "should force :backends to be a flattened array" do
52
- Config.load({:backends => [["foo", ["bar"]]]}).should == {:backends => ["foo", "bar"],
53
- :hierarchy => ['nodes/%{::trusted.certname}', 'common'], :logger => "console", :merge_behavior=>:native}
48
+ expect(Config.load({:backends => [["foo", ["bar"]]]})).to eq({:backends => ["foo", "bar"],
49
+ :hierarchy => ['nodes/%{::trusted.certname}', 'common'], :logger => "console", :merge_behavior=>:native})
54
50
  end
55
51
 
56
52
  it "should load the supplied logger" do
@@ -112,8 +108,8 @@ class Hiera
112
108
  describe "#include?" do
113
109
  it "should correctly report inclusion" do
114
110
  Config.load({})
115
- Config.include?(:foo).should == false
116
- Config.include?(:logger).should == true
111
+ expect(Config.include?(:foo)).to eq(false)
112
+ expect(Config.include?(:logger)).to eq(true)
117
113
  end
118
114
  end
119
115
  end
@@ -11,7 +11,7 @@ describe Hiera::FallbackLogger do
11
11
 
12
12
  logger.warn("the message")
13
13
 
14
- InMemoryLogger.warnings.should == ["the message"]
14
+ expect(InMemoryLogger.warnings).to eq(["the message"])
15
15
  end
16
16
 
17
17
  it "delegates #debug to the logger implemenation" do
@@ -19,7 +19,7 @@ describe Hiera::FallbackLogger do
19
19
 
20
20
  logger.debug("the message")
21
21
 
22
- InMemoryLogger.debugs.should == ["the message"]
22
+ expect(InMemoryLogger.debugs).to eq(["the message"])
23
23
  end
24
24
 
25
25
  it "chooses the first logger that is suitable" do
@@ -27,7 +27,7 @@ describe Hiera::FallbackLogger do
27
27
 
28
28
  logger.warn("for the suitable logger")
29
29
 
30
- SuitableLogger.warnings.should include("for the suitable logger")
30
+ expect(SuitableLogger.warnings).to include("for the suitable logger")
31
31
  end
32
32
 
33
33
  it "raises an error if no implementation is suitable" do
@@ -39,9 +39,9 @@ describe Hiera::FallbackLogger do
39
39
  it "issues a warning for each implementation that is not suitable" do
40
40
  Hiera::FallbackLogger.new(UnsuitableLogger, UnsuitableLogger, SuitableLogger)
41
41
 
42
- SuitableLogger.warnings.should == [
42
+ expect(SuitableLogger.warnings).to eq([
43
43
  "Not using UnsuitableLogger. It does not report itself to be suitable.",
44
- "Not using UnsuitableLogger. It does not report itself to be suitable."]
44
+ "Not using UnsuitableLogger. It does not report itself to be suitable."])
45
45
  end
46
46
 
47
47
  # Preserves log messages in memory
@@ -19,7 +19,7 @@ class Hiera
19
19
  file = File.join(dir, "testing")
20
20
  write_file(file, "my data")
21
21
 
22
- @cache.read(file).should == "my data"
22
+ expect(@cache.read(file)).to eq("my data")
23
23
  end
24
24
  end
25
25
 
@@ -27,10 +27,10 @@ class Hiera
27
27
  Dir.mktmpdir do |dir|
28
28
  file = File.join(dir, "testing")
29
29
  write_file(file, "my data")
30
- @cache.read(file).should == "my data"
30
+ expect(@cache.read(file)).to eq("my data")
31
31
 
32
32
  write_file(file, "changed data")
33
- @cache.read(file).should == "changed data"
33
+ expect(@cache.read(file)).to eq("changed data")
34
34
  end
35
35
  end
36
36
 
@@ -43,7 +43,7 @@ class Hiera
43
43
  "a string"
44
44
  end
45
45
 
46
- data.should == { :testing => "hash" }
46
+ expect(data).to eq({ :testing => "hash" })
47
47
  end
48
48
  end
49
49
 
@@ -56,7 +56,7 @@ class Hiera
56
56
  raise ArgumentError, "testing error"
57
57
  end
58
58
 
59
- data.should == { :testing => "hash" }
59
+ expect(data).to eq({ :testing => "hash" })
60
60
  end
61
61
  end
62
62
 
@@ -80,7 +80,7 @@ class Hiera
80
80
  file = File.join(dir, "testing")
81
81
  write_file(file, "my data")
82
82
 
83
- @cache.read_file(file).should == "my data"
83
+ expect(@cache.read_file(file)).to eq("my data")
84
84
  end
85
85
  end
86
86
 
@@ -88,10 +88,10 @@ class Hiera
88
88
  Dir.mktmpdir do |dir|
89
89
  file = File.join(dir, "testing")
90
90
  write_file(file, "my data")
91
- @cache.read_file(file).should == "my data"
91
+ expect(@cache.read_file(file)).to eq("my data")
92
92
 
93
93
  write_file(file, "changed data")
94
- @cache.read_file(file).should == "changed data"
94
+ expect(@cache.read_file(file)).to eq("changed data")
95
95
  end
96
96
  end
97
97
 
@@ -113,9 +113,9 @@ class Hiera
113
113
  file = File.join(dir, "testing")
114
114
  write_file(file, "my data")
115
115
 
116
- @cache.read_file(file, Hash) do |data|
116
+ expect(@cache.read_file(file, Hash) do |data|
117
117
  { :data => data }
118
- end.should == { :data => "my data" }
118
+ end).to eq({ :data => "my data" })
119
119
  end
120
120
  end
121
121
 
@@ -18,7 +18,7 @@ describe "Hiera" do
18
18
 
19
19
  Hiera.logger = "no_such_logger"
20
20
 
21
- Hiera.logger.should be Hiera::Console_logger
21
+ expect(Hiera.logger).to be Hiera::Console_logger
22
22
  end
23
23
 
24
24
  it "falls back to the Console logger when the logger class could not be found" do
@@ -27,7 +27,7 @@ describe "Hiera" do
27
27
 
28
28
  Hiera.logger = "no_constant"
29
29
 
30
- Hiera.logger.should be Hiera::Console_logger
30
+ expect(Hiera.logger).to be Hiera::Console_logger
31
31
  end
32
32
  end
33
33
 
@@ -4,13 +4,13 @@ describe Hiera::Puppet_logger do
4
4
  it "is not suitable when Puppet is not defined" do
5
5
  ensure_puppet_not_defined
6
6
 
7
- Hiera::Puppet_logger.suitable?.should == false
7
+ expect(Hiera::Puppet_logger.suitable?).to eq(false)
8
8
  end
9
9
 
10
10
  it "is suitable when Puppet is defined" do
11
11
  ensure_puppet_defined
12
12
 
13
- Hiera::Puppet_logger.suitable?.should == true
13
+ expect(Hiera::Puppet_logger.suitable?).to eq(true)
14
14
  end
15
15
 
16
16
  after :each do
@@ -4,45 +4,45 @@ describe Hiera::Util do
4
4
  describe 'Hiera::Util.posix?' do
5
5
  it 'should return true on posix systems' do
6
6
  Etc.expects(:getpwuid).with(0).returns(true)
7
- Hiera::Util.posix?.should be_true
7
+ expect(Hiera::Util.posix?).to be_truthy
8
8
  end
9
9
 
10
10
  it 'should return false on non posix systems' do
11
11
  Etc.expects(:getpwuid).with(0).returns(nil)
12
- Hiera::Util.posix?.should be_false
12
+ expect(Hiera::Util.posix?).to be_falsey
13
13
  end
14
14
  end
15
15
 
16
16
  describe 'Hiera::Util.microsoft_windows?' do
17
17
  it 'should return false on posix systems' do
18
18
  Hiera::Util.expects(:file_alt_separator).returns(nil)
19
- Hiera::Util.microsoft_windows?.should be_false
19
+ expect(Hiera::Util.microsoft_windows?).to be_falsey
20
20
  end
21
21
  end
22
22
 
23
23
  describe 'Hiera::Util.config_dir' do
24
24
  it 'should return the correct path for posix systems' do
25
25
  Hiera::Util.expects(:file_alt_separator).returns(nil)
26
- Hiera::Util.config_dir.should == '/etc/puppetlabs/code'
26
+ expect(Hiera::Util.config_dir).to eq('/etc/puppetlabs/code')
27
27
  end
28
28
 
29
29
  it 'should return the correct path for microsoft windows systems' do
30
30
  Hiera::Util.expects(:microsoft_windows?).returns(true)
31
31
  Hiera::Util.expects(:common_appdata).returns('C:\\ProgramData')
32
- Hiera::Util.config_dir.should == 'C:\\ProgramData/PuppetLabs/code'
32
+ expect(Hiera::Util.config_dir).to eq('C:\\ProgramData/PuppetLabs/code')
33
33
  end
34
34
  end
35
35
 
36
36
  describe 'Hiera::Util.var_dir' do
37
37
  it 'should return the correct path for posix systems' do
38
38
  Hiera::Util.expects(:file_alt_separator).returns(nil)
39
- Hiera::Util.var_dir.should == '/etc/puppetlabs/code/environments/%{environment}/hieradata'
39
+ expect(Hiera::Util.var_dir).to eq('/etc/puppetlabs/code/environments/%{environment}/hieradata')
40
40
  end
41
41
 
42
42
  it 'should return the correct path for microsoft windows systems' do
43
43
  Hiera::Util.expects(:microsoft_windows?).returns(true)
44
44
  Hiera::Util.expects(:common_appdata).returns('C:\\ProgramData')
45
- Hiera::Util.var_dir.should == 'C:\\ProgramData/PuppetLabs/code/environments/%{environment}/hieradata'
45
+ expect(Hiera::Util.var_dir).to eq('C:\\ProgramData/PuppetLabs/code/environments/%{environment}/hieradata')
46
46
  end
47
47
  end
48
48
  end
@@ -19,11 +19,11 @@ describe "Hiera.version Public API" do
19
19
  end
20
20
 
21
21
  it "is Hiera::VERSION" do
22
- subject.version.should == Hiera::VERSION
22
+ expect(subject.version).to eq(Hiera::VERSION)
23
23
  end
24
24
  it "respects the version= setter" do
25
25
  subject.version = '1.2.3'
26
- subject.version.should == '1.2.3'
26
+ expect(subject.version).to eq('1.2.3')
27
27
  end
28
28
  end
29
29
 
@@ -34,11 +34,11 @@ describe "Hiera.version Public API" do
34
34
  pathname.basename.to_s == "VERSION"
35
35
  end.returns('1.2.1-9-g9fda440')
36
36
 
37
- subject.version.should == '1.2.1-9-g9fda440'
37
+ expect(subject.version).to eq('1.2.1-9-g9fda440')
38
38
  end
39
39
  it "respects the version= setter" do
40
40
  subject.version = '1.2.3'
41
- subject.version.should == '1.2.3'
41
+ expect(subject.version).to eq('1.2.3')
42
42
  end
43
43
  end
44
44
  end
metadata CHANGED
@@ -1,30 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hiera
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
5
- prerelease:
4
+ version: 3.0.5
6
5
  platform: ruby
7
6
  authors:
8
7
  - Puppet Labs
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2015-06-23 00:00:00.000000000 Z
11
+ date: 2015-11-16 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: json_pure
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  description: A pluggable data store for hierarcical data
@@ -35,84 +32,83 @@ extensions: []
35
32
  extra_rdoc_files: []
36
33
  files:
37
34
  - bin/hiera
38
- - lib/hiera/version.rb
39
- - lib/hiera/noop_logger.rb
40
- - lib/hiera/error.rb
41
- - lib/hiera/fallback_logger.rb
42
- - lib/hiera/recursive_guard.rb
43
- - lib/hiera/backend/yaml_backend.rb
35
+ - lib/hiera/backend.rb
44
36
  - lib/hiera/backend/json_backend.rb
37
+ - lib/hiera/backend/yaml_backend.rb
45
38
  - lib/hiera/config.rb
39
+ - lib/hiera/console_logger.rb
40
+ - lib/hiera/error.rb
41
+ - lib/hiera/fallback_logger.rb
46
42
  - lib/hiera/filecache.rb
47
43
  - lib/hiera/interpolate.rb
48
- - lib/hiera/console_logger.rb
44
+ - lib/hiera/noop_logger.rb
49
45
  - lib/hiera/puppet_logger.rb
46
+ - lib/hiera/recursive_guard.rb
50
47
  - lib/hiera/util.rb
51
- - lib/hiera/backend.rb
48
+ - lib/hiera/version.rb
52
49
  - lib/hiera.rb
53
50
  - COPYING
54
51
  - README.md
55
52
  - LICENSE
56
- - spec/unit/interpolate_spec.rb
57
- - spec/unit/fixtures/override/config/hiera.yaml
58
- - spec/unit/fixtures/override/data/alternate.yaml
59
- - spec/unit/fixtures/override/data/common.yaml
60
- - spec/unit/fixtures/interpolate/config/hiera.yaml
61
- - spec/unit/fixtures/interpolate/data/niltest.yaml
62
- - spec/unit/fixtures/interpolate/data/recursive.yaml
53
+ - spec/spec_helper.rb
54
+ - spec/unit/backend/json_backend_spec.rb
55
+ - spec/unit/backend/yaml_backend_spec.rb
63
56
  - spec/unit/backend_spec.rb
64
- - spec/unit/filecache_spec.rb
65
57
  - spec/unit/config_spec.rb
66
- - spec/unit/backend/yaml_backend_spec.rb
67
- - spec/unit/backend/json_backend_spec.rb
68
- - spec/unit/puppet_logger_spec.rb
69
58
  - spec/unit/console_logger_spec.rb
70
- - spec/unit/version_spec.rb
71
59
  - spec/unit/fallback_logger_spec.rb
72
- - spec/unit/util_spec.rb
60
+ - spec/unit/filecache_spec.rb
61
+ - spec/unit/fixtures/interpolate/config/hiera.yaml
62
+ - spec/unit/fixtures/interpolate/data/niltest.yaml
63
+ - spec/unit/fixtures/interpolate/data/recursive.yaml
64
+ - spec/unit/fixtures/override/config/hiera.yaml
65
+ - spec/unit/fixtures/override/data/alternate.yaml
66
+ - spec/unit/fixtures/override/data/common.yaml
73
67
  - spec/unit/hiera_spec.rb
74
- - spec/spec_helper.rb
68
+ - spec/unit/interpolate_spec.rb
69
+ - spec/unit/puppet_logger_spec.rb
70
+ - spec/unit/util_spec.rb
71
+ - spec/unit/version_spec.rb
75
72
  homepage: https://github.com/puppetlabs/hiera
76
73
  licenses: []
74
+ metadata: {}
77
75
  post_install_message:
78
76
  rdoc_options: []
79
77
  require_paths:
80
78
  - lib
81
79
  required_ruby_version: !ruby/object:Gem::Requirement
82
- none: false
83
80
  requirements:
84
- - - ! '>='
81
+ - - '>='
85
82
  - !ruby/object:Gem::Version
86
83
  version: '0'
87
84
  required_rubygems_version: !ruby/object:Gem::Requirement
88
- none: false
89
85
  requirements:
90
- - - ! '>='
86
+ - - '>='
91
87
  - !ruby/object:Gem::Version
92
88
  version: '0'
93
89
  requirements: []
94
90
  rubyforge_project:
95
- rubygems_version: 1.8.23
91
+ rubygems_version: 2.0.14
96
92
  signing_key:
97
- specification_version: 3
93
+ specification_version: 4
98
94
  summary: Light weight hierarchical data store
99
95
  test_files:
100
- - spec/unit/interpolate_spec.rb
101
- - spec/unit/fixtures/override/config/hiera.yaml
102
- - spec/unit/fixtures/override/data/alternate.yaml
103
- - spec/unit/fixtures/override/data/common.yaml
104
- - spec/unit/fixtures/interpolate/config/hiera.yaml
105
- - spec/unit/fixtures/interpolate/data/niltest.yaml
106
- - spec/unit/fixtures/interpolate/data/recursive.yaml
96
+ - spec/spec_helper.rb
97
+ - spec/unit/backend/json_backend_spec.rb
98
+ - spec/unit/backend/yaml_backend_spec.rb
107
99
  - spec/unit/backend_spec.rb
108
- - spec/unit/filecache_spec.rb
109
100
  - spec/unit/config_spec.rb
110
- - spec/unit/backend/yaml_backend_spec.rb
111
- - spec/unit/backend/json_backend_spec.rb
112
- - spec/unit/puppet_logger_spec.rb
113
101
  - spec/unit/console_logger_spec.rb
114
- - spec/unit/version_spec.rb
115
102
  - spec/unit/fallback_logger_spec.rb
116
- - spec/unit/util_spec.rb
103
+ - spec/unit/filecache_spec.rb
104
+ - spec/unit/fixtures/interpolate/config/hiera.yaml
105
+ - spec/unit/fixtures/interpolate/data/niltest.yaml
106
+ - spec/unit/fixtures/interpolate/data/recursive.yaml
107
+ - spec/unit/fixtures/override/config/hiera.yaml
108
+ - spec/unit/fixtures/override/data/alternate.yaml
109
+ - spec/unit/fixtures/override/data/common.yaml
117
110
  - spec/unit/hiera_spec.rb
118
- - spec/spec_helper.rb
111
+ - spec/unit/interpolate_spec.rb
112
+ - spec/unit/puppet_logger_spec.rb
113
+ - spec/unit/util_spec.rb
114
+ - spec/unit/version_spec.rb