hiera 3.0.1-x86-mingw32 → 3.0.5-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f3b8a1a9736e611f6e592f82359713ec54dff008
4
+ data.tar.gz: 7fae6afbfbfa9ffc56e3004d80165a1b03c95d05
5
+ SHA512:
6
+ metadata.gz: 2f6639d97d5a947078ee7f099f0e6b3cab739177bdb83a6c7ae094b9e0fc76dc227cda29dc16cfa573f38cf67ca1a9f8ffe4aaa3fe0f3781e4a4ffc0a76651bf
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