mixlib-config 2.2.2 → 2.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9a3b6ad6191a68a770d664217782576fa3f99174
4
- data.tar.gz: 37892ffb3b86d0331353473ef9a018411fd87844
3
+ metadata.gz: ebf0bd30e24aaeef0c7f79e0e4ce25adc6bef352
4
+ data.tar.gz: 800fd90f845685bd25aedc76fa6a5fc93bd0b485
5
5
  SHA512:
6
- metadata.gz: 4a5dbeb190acc013e73d094a75495b066f3c53ea8b9f7bc66808dfc0e1ba6dba52cc7955a8e66f2aedd1fe445f5b8136f2a2a27b7f367c819da52979f6f75028
7
- data.tar.gz: e88d63510083684bea77e3c7e3ea9f09c4aad9b84a7282efd0304c334980a6fd1b2d626de2650736df25272d3e2f9e5a32d0af646d3c08b202320866398f2361
6
+ metadata.gz: db587efec382225f4f1f8655b7f0d364825c34b3897913b516f8398e0b2b18a94d025e85f0f4ee83d3237f5b5f94c498b80036262f11a9036ff75bae12be2ef6
7
+ data.tar.gz: 6d06502f5e374fe48227ac4f82eba7dd330ecdfeba2becfadf5f078c3fa3a25eec7043a736dd23279d656eec13108507d4ece022beba8e002e0d404821022fd2
data/NOTICE CHANGED
@@ -1,25 +1,25 @@
1
- Mixin::Config NOTICE
1
+ Mixlib::Config NOTICE
2
2
  =================
3
3
 
4
- Developed at Opscode (http://www.opscode.com).
4
+ Developed at Chef (http://www.chef.io).
5
5
 
6
- * Copyright 2009, Opscode, Inc. <legal@opscode.com>
6
+ * Copyright 2009-2016, Chef Software, Inc. <legal@chef.io>
7
7
 
8
- Mixin::Config incorporates code from Chef. The Chef notice file follows:
8
+ Mixlib::Config incorporates code from Chef. The Chef notice file follows:
9
9
 
10
10
  Chef NOTICE
11
11
  ===========
12
12
 
13
- Developed at Opscode (http://www.opscode.com).
13
+ Developed at Chef (http://www.chef.io).
14
14
 
15
15
  Contributors and Copyright holders:
16
16
 
17
- * Copyright 2008, Adam Jacob <adam@opscode.com>
17
+ * Copyright 2008, Adam Jacob <adam@chef.io>
18
18
  * Copyright 2008, Arjuna Christensen <aj@hjksolutions.com>
19
19
  * Copyright 2008, Bryan McLellan <btm@loftninjas.org>
20
20
  * Copyright 2008, Ezra Zygmuntowicz <ezra@engineyard.com>
21
21
  * Copyright 2009, Sean Cribbs <seancribbs@gmail.com>
22
- * Copyright 2009, Christopher Brown <cb@opscode.com>
22
+ * Copyright 2009, Christopher Brown <cb@chef.io>
23
23
  * Copyright 2009, Thom May <thom@clearairturbulence.org>
24
24
 
25
25
  Chef incorporates code modified from Open4 (http://www.codeforpeople.com/lib/ruby/open4/), which was written by Ara T. Howard.
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
- # Mixlib::Config #
1
+ # Mixlib::Config
2
2
 
3
- Mixlib::Config provides a class-based configuration object, as used in Chef. To use in your project:
3
+ [![Build Status](https://travis-ci.org/chef/mixlib-config.svg?branch=master)](https://travis-ci.org/chef/mixlib-config)[![Gem Version](https://badge.fury.io/rb/mixlib-config.svg)](https://badge.fury.io/rb/mixlib-config)
4
+
5
+ Mixlib::Config provides a class-based configuration object, as used in Chef. To use in your project:
4
6
 
5
7
  ```ruby
6
8
  require 'mixlib/config'
@@ -13,7 +15,7 @@ Mixlib::Config provides a class-based configuration object, as used in Chef. To
13
15
  end
14
16
  ```
15
17
 
16
- You can use this to provide a configuration file for a user. For example, if you do this:
18
+ You can use this to provide a configuration file for a user. For example, if you do this:
17
19
 
18
20
  ```ruby
19
21
  MyConfig.from_file('~/.myconfig.rb')
@@ -32,6 +34,7 @@ Inside your app, you can check configuration values with this syntax:
32
34
  MyConfig.first_value # returns 'something'
33
35
  MyConfig[:first_value] # returns 'something'
34
36
  ```
37
+
35
38
  And you can modify configuration values with this syntax:
36
39
 
37
40
  ```ruby
@@ -40,9 +43,9 @@ And you can modify configuration values with this syntax:
40
43
  MyConfig[:first_value] = 'foobar' # sets first_value to 'foobar'
41
44
  ```
42
45
 
43
- ## Nested Configuration ##
46
+ ## Nested Configuration
44
47
 
45
- Often you want to be able to group configuration options to provide a common context. Mixlib::Config supports this thus:
48
+ Often you want to be able to group configuration options to provide a common context. Mixlib::Config supports this thus:
46
49
 
47
50
  ```ruby
48
51
  require 'mixlib/config'
@@ -70,9 +73,9 @@ You can access these variables thus:
70
73
  MyConfig[:logging][:max_log_files]
71
74
  ```
72
75
 
73
- ## Default Values ##
76
+ ## Default Values
74
77
 
75
- Mixlib::Config has a powerful default value facility. In addition to being able to specify explicit default values, you can even specify Ruby code blocks that will run if the config value is not set. This can allow you to build options whose values are based on other options.
78
+ Mixlib::Config has a powerful default value facility. In addition to being able to specify explicit default values, you can even specify Ruby code blocks that will run if the config value is not set. This can allow you to build options whose values are based on other options.
76
79
 
77
80
  ```ruby
78
81
  require 'mixlib/config'
@@ -93,9 +96,9 @@ This allows the user to quickly specify a number of values with one default, whi
93
96
  print_network_requests false
94
97
  ```
95
98
 
96
- ## Strict Mode ##
99
+ ## Strict Mode
97
100
 
98
- Misspellings are a common configuration problem, and Mixlib::Config has an answer: `config_strict_mode`. Setting `config_strict_mode` to `true` will cause any misspelled or incorrect configuration option references to throw `Mixlib::Config::UnknownConfigOptionError`.
101
+ Misspellings are a common configuration problem, and Mixlib::Config has an answer: `config_strict_mode`. Setting `config_strict_mode` to `true` will cause any misspelled or incorrect configuration option references to throw `Mixlib::Config::UnknownConfigOptionError`.
99
102
 
100
103
  ```ruby
101
104
  require 'mixlib/config'
@@ -112,18 +115,16 @@ Misspellings are a common configuration problem, and Mixlib::Config has an answ
112
115
  end
113
116
  ```
114
117
 
115
- Now if a user types `fielname "~/output-mine.txt"` in their configuration file, it will toss an exception telling them that the option "fielname" is unknown. If you do not set config_strict_mode, the fielname option will be merrily set and the application just won't know about it.
116
-
117
- Different config_contexts can have different strict modes; but they inherit the strict mode of their parent if you don't explicitly set it. So setting it once at the top level is sufficient. In the above example, `logging.base_naem 'mylog'` will raise an error.
118
+ Now if a user types `fielname "~/output-mine.txt"` in their configuration file, it will toss an exception telling them that the option "fielname" is unknown. If you do not set config_strict_mode, the fielname option will be merrily set and the application just won't know about it.
118
119
 
119
- In conclusion: *always set config_strict_mode to true*. You know you want to.
120
+ Different config_contexts can have different strict modes; but they inherit the strict mode of their parent if you don't explicitly set it. So setting it once at the top level is sufficient. In the above example, `logging.base_naem 'mylog'` will raise an error.
120
121
 
121
- ## Testing and Reset ##
122
+ In conclusion: _always set config_strict_mode to true_. You know you want to.
122
123
 
123
- Testing your application with different sets of arguments can by simplified with `reset`. Call `MyConfig.reset` before each test and all configuration will be reset to its default value. There's no need to explicitly unset all your options between each run.
124
+ ## Testing and Reset
124
125
 
125
- NOTE: if you have arrays of arrays, or other deep nesting, we suggest you use code blocks to set up your default values (`default(:option) { [ [ 1, 2 ], [ 3, 4 ] ] }`). Deep children will not always be reset to their default values.
126
+ Testing your application with different sets of arguments can by simplified with `reset`. Call `MyConfig.reset` before each test and all configuration will be reset to its default value. There's no need to explicitly unset all your options between each run.
126
127
 
127
- Report bugs [here](https://tickets.opscode.com).
128
+ NOTE: if you have arrays of arrays, or other deep nesting, we suggest you use code blocks to set up your default values (`default(:option) { [ [ 1, 2 ], [ 3, 4 ] ] }`). Deep children will not always be reset to their default values.
128
129
 
129
130
  Enjoy!
data/lib/mixlib/config.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  #
2
- # Author:: Adam Jacob (<adam@opscode.com>)
3
- # Author:: Nuo Yan (<nuo@opscode.com>)
4
- # Author:: Christopher Brown (<cb@opscode.com>)
5
- # Copyright:: Copyright (c) 2008 Opscode, Inc.
2
+ # Author:: Adam Jacob (<adam@chef.io>)
3
+ # Author:: Nuo Yan (<nuo@chef.io>)
4
+ # Author:: Christopher Brown (<cb@chef.io>)
5
+ # Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
6
6
  # License:: Apache License, Version 2.0
7
7
  #
8
8
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -177,16 +177,20 @@ module Mixlib
177
177
 
178
178
  # Restore non-default values from the given hash.
179
179
  #
180
- # This method is the equivalent of +reset+ followed by +merge!(hash)+.
181
- #
182
180
  # === Parameters
183
181
  # hash<Hash>: a hash in the same format as output by save.
184
- #
182
+ #
185
183
  # === Returns
186
184
  # self
187
185
  def restore(hash)
188
- reset
189
- merge!(hash)
186
+ self.configuration = hash.reject { |key, value| config_contexts.has_key?(key) }
187
+ config_contexts.each do |key, config_context|
188
+ if hash.has_key?(key)
189
+ config_context.restore(hash[key])
190
+ else
191
+ config_context.reset
192
+ end
193
+ end
190
194
  end
191
195
 
192
196
  # Merge an incoming hash with our config options
@@ -1,6 +1,6 @@
1
1
  #
2
- # Author:: John Keiser (<jkeiser@opscode.com>)
3
- # Copyright:: Copyright (c) 2013 Opscode, Inc.
2
+ # Author:: John Keiser (<jkeiser@chef.io>)
3
+ # Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,6 +1,6 @@
1
1
  #
2
- # Author:: John Keiser (<jkeiser@opscode.com>)
3
- # Copyright:: Copyright (c) 2013 Opscode, Inc.
2
+ # Author:: John Keiser (<jkeiser@chef.io>)
3
+ # Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,6 +1,6 @@
1
1
  #
2
- # Author:: John Keiser (<jkeiser@opscode.com>)
3
- # Copyright:: Copyright (c) 2013 Opscode, Inc.
2
+ # Author:: John Keiser (<jkeiser@chef.io>)
3
+ # Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,6 +1,6 @@
1
1
  #
2
- # Author:: John Keiser (<jkeiser@opscode.com>)
3
- # Copyright:: Copyright (c) 2013 Opscode, Inc.
2
+ # Author:: John Keiser (<jkeiser@chef.io>)
3
+ # Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,6 +1,6 @@
1
1
  #
2
- # Author:: Daniel DeLeo (<dan@opscode.com>)
3
- # Copyright:: Copyright (c) 2013 Opscode, Inc.
2
+ # Author:: Daniel DeLeo (<dan@chef.io>)
3
+ # Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -19,7 +19,7 @@
19
19
  module Mixlib
20
20
  module Config
21
21
 
22
- VERSION = "2.2.2"
22
+ VERSION = "2.2.3"
23
23
 
24
24
  end
25
25
  end
@@ -23,6 +23,6 @@ Gem::Specification.new do |s|
23
23
  s.license = "Apache-2.0"
24
24
 
25
25
  s.add_development_dependency "rake"
26
- s.add_development_dependency "rspec", "~> 2.99"
26
+ s.add_development_dependency "rspec", "~> 3.0"
27
27
  s.add_development_dependency "rdoc"
28
28
  end
@@ -1,6 +1,6 @@
1
1
  #
2
- # Author:: Adam Jacob (<adam@opscode.com>)
3
- # Copyright:: Copyright (c) 2008 Opscode, Inc.
2
+ # Author:: Adam Jacob (<adam@chef.io>)
3
+ # Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -26,62 +26,62 @@ describe Mixlib::Config do
26
26
  end
27
27
  end
28
28
 
29
- it "should load a config file" do
30
- File.stub(:exists?).and_return(true)
31
- File.stub(:readable?).and_return(true)
32
- IO.stub(:read).with("config.rb").and_return("alpha = 'omega'\nfoo = 'bar'")
33
- lambda {
29
+ it "loads a config file" do
30
+ allow(File).to receive(:exists?).and_return(true)
31
+ allow(File).to receive(:readable?).and_return(true)
32
+ allow(IO).to receive(:read).with("config.rb").and_return("alpha = 'omega'\nfoo = 'bar'")
33
+ expect(lambda {
34
34
  ConfigIt.from_file("config.rb")
35
- }.should_not raise_error
35
+ }).to_not raise_error
36
36
  end
37
37
 
38
- it "should not raise an ArgumentError with an explanation if you try and set a non-existent variable" do
39
- lambda {
38
+ it "doesn't raise an ArgumentError with an explanation if you try and set a non-existent variable" do
39
+ expect(lambda {
40
40
  ConfigIt[:foobar] = "blah"
41
- }.should_not raise_error
41
+ }).to_not raise_error
42
42
  end
43
43
 
44
- it "should raise an Errno::ENOENT if it can't find the file" do
45
- lambda {
44
+ it "raises an Errno::ENOENT if it can't find the file" do
45
+ expect(lambda {
46
46
  ConfigIt.from_file("/tmp/timmytimmytimmy")
47
- }.should raise_error(Errno::ENOENT)
47
+ }).to raise_error(Errno::ENOENT)
48
48
  end
49
49
 
50
- it "should allow the error to bubble up when it's anything other than IOError" do
51
- IO.stub(:read).with("config.rb").and_return("@#asdf")
52
- lambda {
50
+ it "allows the error to bubble up when it's anything other than IOError" do
51
+ allow(IO).to receive(:read).with("config.rb").and_return("@#asdf")
52
+ expect(lambda {
53
53
  ConfigIt.from_file("config.rb")
54
- }.should raise_error(SyntaxError)
54
+ }).to raise_error(SyntaxError)
55
55
  end
56
56
 
57
- it "should allow you to reference a value by index" do
58
- ConfigIt[:alpha].should == "omega"
57
+ it "allows you to reference a value by index" do
58
+ expect(ConfigIt[:alpha]).to eql("omega")
59
59
  end
60
60
 
61
- it "should allow you to reference a value by string index" do
62
- ConfigIt["alpha"].should == "omega"
61
+ it "allows you to reference a value by string index" do
62
+ expect(ConfigIt["alpha"]).to eql("omega")
63
63
  end
64
64
 
65
- it "should allow you to set a value by index" do
65
+ it "allows you to set a value by index" do
66
66
  ConfigIt[:alpha] = "one"
67
- ConfigIt[:alpha].should == "one"
67
+ expect(ConfigIt[:alpha]).to eql("one")
68
68
  end
69
69
 
70
- it "should allow you to set a value by string index" do
70
+ it "allows you to set a value by string index" do
71
71
  ConfigIt["alpha"] = "one"
72
- ConfigIt[:alpha].should == "one"
72
+ expect(ConfigIt[:alpha]).to eql("one")
73
73
  end
74
74
 
75
- it "should allow setting a value with attribute form" do
75
+ it "allows setting a value with attribute form" do
76
76
  ConfigIt.arbitrary_value = 50
77
- ConfigIt.arbitrary_value.should == 50
78
- ConfigIt[:arbitrary_value].should == 50
77
+ expect(ConfigIt.arbitrary_value).to eql(50)
78
+ expect(ConfigIt[:arbitrary_value]).to eql(50)
79
79
  end
80
80
 
81
- it "should allow setting a value with method form" do
81
+ it "allows setting a value with method form" do
82
82
  ConfigIt.arbitrary_value 50
83
- ConfigIt.arbitrary_value.should == 50
84
- ConfigIt[:arbitrary_value].should == 50
83
+ expect(ConfigIt.arbitrary_value).to eql(50)
84
+ expect(ConfigIt[:arbitrary_value]).to eql(50)
85
85
  end
86
86
 
87
87
  describe "when strict mode is on" do
@@ -97,23 +97,23 @@ describe Mixlib::Config do
97
97
  end
98
98
 
99
99
  it "raises an error when you get an arbitrary config option with .y" do
100
- lambda { StrictClass.y }.should raise_error(Mixlib::Config::UnknownConfigOptionError, "Reading unsupported config value y.")
100
+ expect(lambda { StrictClass.y }).to raise_error(Mixlib::Config::UnknownConfigOptionError, "Reading unsupported config value y.")
101
101
  end
102
102
 
103
103
  it "raises an error when you get an arbitrary config option with [:y]" do
104
- lambda { StrictClass[:y] }.should raise_error(Mixlib::Config::UnknownConfigOptionError, "Reading unsupported config value y.")
104
+ expect(lambda { StrictClass[:y] }).to raise_error(Mixlib::Config::UnknownConfigOptionError, "Reading unsupported config value y.")
105
105
  end
106
106
 
107
107
  it "raises an error when you set an arbitrary config option with .y = 10" do
108
- lambda { StrictClass.y = 10 }.should raise_error(Mixlib::Config::UnknownConfigOptionError, "Cannot set unsupported config value y.")
108
+ expect(lambda { StrictClass.y = 10 }).to raise_error(Mixlib::Config::UnknownConfigOptionError, "Cannot set unsupported config value y.")
109
109
  end
110
110
 
111
111
  it "raises an error when you set an arbitrary config option with .y 10" do
112
- lambda { StrictClass.y 10 }.should raise_error(Mixlib::Config::UnknownConfigOptionError, "Cannot set unsupported config value y.")
112
+ expect(lambda { StrictClass.y 10 }).to raise_error(Mixlib::Config::UnknownConfigOptionError, "Cannot set unsupported config value y.")
113
113
  end
114
114
 
115
115
  it "raises an error when you set an arbitrary config option with [:y] = 10" do
116
- lambda { StrictClass[:y] = 10 }.should raise_error(Mixlib::Config::UnknownConfigOptionError, "Cannot set unsupported config value y.")
116
+ expect(lambda { StrictClass[:y] = 10 }).to raise_error(Mixlib::Config::UnknownConfigOptionError, "Cannot set unsupported config value y.")
117
117
  end
118
118
  end
119
119
 
@@ -123,23 +123,23 @@ describe Mixlib::Config do
123
123
  end
124
124
 
125
125
  { :cookbook_path => "monkey_rabbit", :otherthing => "boo" }.each do |k, v|
126
- it "should allow you to retrieve the config value for #{k} via []" do
127
- ConfigIt[k].should == v
126
+ it "allows you to retrieve the config value for #{k} via []" do
127
+ expect(ConfigIt[k]).to eql(v)
128
128
  end
129
- it "should allow you to retrieve the config value for #{k} via method_missing" do
130
- ConfigIt.send(k).should == v
129
+ it "allows you to retrieve the config value for #{k} via method_missing" do
130
+ expect(ConfigIt.send(k)).to eql(v)
131
131
  end
132
132
  end
133
133
  end
134
134
 
135
- it "should not raise an ArgumentError if you access a config option that does not exist" do
136
- lambda { ConfigIt[:snob_hobbery] }.should_not raise_error
135
+ it "doesn't raise an ArgumentError if you access a config option that does not exist" do
136
+ expect(lambda { ConfigIt[:snob_hobbery] }).to_not raise_error
137
137
  end
138
138
 
139
- it "should return true or false with has_key?" do
140
- ConfigIt.has_key?(:monkey).should eql(false)
139
+ it "returns true or false with has_key?" do
140
+ expect(ConfigIt.has_key?(:monkey)).to be false
141
141
  ConfigIt[:monkey] = "gotcha"
142
- ConfigIt.has_key?(:monkey).should eql(true)
142
+ expect(ConfigIt.has_key?(:monkey)).to be true
143
143
  end
144
144
 
145
145
  describe "when a class method override writer exists" do
@@ -153,29 +153,29 @@ describe Mixlib::Config do
153
153
  end
154
154
  end
155
155
 
156
- it "should multiply an integer by 1000" do
156
+ it "multiplies an integer by 1000" do
157
157
  @klass[:test_method] = 53
158
- @klass[:test_method].should == 53000
158
+ expect(@klass[:test_method]).to eql(53000)
159
159
  end
160
160
 
161
- it "should multiply an integer by 1000 with the method_missing form" do
161
+ it "multiplies an integer by 1000 with the method_missing form" do
162
162
  @klass.test_method = 63
163
- @klass.test_method.should == 63000
163
+ expect(@klass.test_method).to eql(63000)
164
164
  end
165
165
 
166
- it "should multiply an integer by 1000 with the instance_eval DSL form" do
166
+ it "multiplies an integer by 1000 with the instance_eval DSL form" do
167
167
  @klass.instance_eval("test_method 73")
168
- @klass.test_method.should == 73000
168
+ expect(@klass.test_method).to eql(73000)
169
169
  end
170
170
 
171
- it "should multiply an integer by 1000 via from-file, too" do
172
- IO.stub(:read).with("config.rb").and_return("test_method 99")
171
+ it "multiplies an integer by 1000 via from-file, too" do
172
+ allow(IO).to receive(:read).with("config.rb").and_return("test_method 99")
173
173
  @klass.from_file("config.rb")
174
- @klass.test_method.should == 99000
174
+ expect(@klass.test_method).to eql(99000)
175
175
  end
176
176
 
177
- it "should receive internal_set with the method name and config value" do
178
- @klass.should_receive(:internal_set).with(:test_method, 53).and_return(true)
177
+ it "receives internal_set with the method name and config value" do
178
+ expect(@klass).to receive(:internal_set).with(:test_method, 53).and_return(true)
179
179
  @klass[:test_method] = 53
180
180
  end
181
181
 
@@ -194,19 +194,19 @@ describe Mixlib::Config do
194
194
  end
195
195
 
196
196
  it "Getter methods are created for the configurable" do
197
- @klass.respond_to?(:daemonizeme).should == true
198
- @klass.respond_to?(:a).should == true
199
- @klass.respond_to?(:b).should == true
200
- @klass.respond_to?(:c).should == true
201
- @klass.respond_to?(:z).should == false
197
+ expect(@klass.respond_to?(:daemonizeme)).to be true
198
+ expect(@klass.respond_to?(:a)).to be true
199
+ expect(@klass.respond_to?(:b)).to be true
200
+ expect(@klass.respond_to?(:c)).to be true
201
+ expect(@klass.respond_to?(:z)).to be false
202
202
  end
203
203
 
204
204
  it "Setter methods are created for the configurable" do
205
- @klass.respond_to?("daemonizeme=".to_sym).should == true
206
- @klass.respond_to?("a=".to_sym).should == true
207
- @klass.respond_to?("b=".to_sym).should == true
208
- @klass.respond_to?("c=".to_sym).should == true
209
- @klass.respond_to?("z=".to_sym).should == false
205
+ expect(@klass.respond_to?("daemonizeme=".to_sym)).to be true
206
+ expect(@klass.respond_to?("a=".to_sym)).to be true
207
+ expect(@klass.respond_to?("b=".to_sym)).to be true
208
+ expect(@klass.respond_to?("c=".to_sym)).to be true
209
+ expect(@klass.respond_to?("z=".to_sym)).to be false
210
210
  end
211
211
 
212
212
  describe "and extra methods have been dumped into Object" do
@@ -229,17 +229,17 @@ describe Mixlib::Config do
229
229
  it "Normal classes call the extra method" do
230
230
  normal_class = Class.new
231
231
  normal_class.extend(::Mixlib::Config)
232
- lambda { normal_class.daemonizeme }.should raise_error(NopeError)
232
+ expect(lambda { normal_class.daemonizeme }).to raise_error(NopeError)
233
233
  end
234
234
 
235
235
  it "Configurables with the same name as the extra method can be set" do
236
236
  @klass.daemonizeme = 10
237
- @klass[:daemonizeme].should == 10
237
+ expect(@klass[:daemonizeme]).to eql(10)
238
238
  end
239
239
 
240
240
  it "Configurables with the same name as the extra method can be retrieved" do
241
241
  @klass[:daemonizeme] = 10
242
- @klass.daemonizeme.should == 10
242
+ expect(@klass.daemonizeme).to eql(10)
243
243
  end
244
244
  end
245
245
  end
@@ -251,55 +251,55 @@ describe Mixlib::Config do
251
251
  @klass.class_eval { default :attr, 4 }
252
252
  end
253
253
 
254
- it "should default to that value" do
255
- @klass.attr.should == 4
254
+ it "defaults to that value" do
255
+ expect(@klass.attr).to eql(4)
256
256
  end
257
257
 
258
- it "should default to that value when retrieved as a hash" do
259
- @klass[:attr].should == 4
258
+ it "defaults to that value when retrieved as a hash" do
259
+ expect(@klass[:attr]).to eql(4)
260
260
  end
261
261
 
262
- it "should be settable to another value" do
262
+ it "is settable to another value" do
263
263
  @klass.attr 5
264
- @klass.attr.should == 5
264
+ expect(@klass.attr).to eql(5)
265
265
  end
266
266
 
267
- it "should still default to that value after delete" do
267
+ it "still defaults to that value after delete" do
268
268
  @klass.attr 5
269
269
  @klass.delete(:attr)
270
- @klass.attr.should == 4
270
+ expect(@klass.attr).to eql(4)
271
271
  end
272
272
 
273
- it "should still default to that value after reset" do
273
+ it "still defaults to that value after reset" do
274
274
  @klass.attr 5
275
275
  @klass.reset
276
- @klass.attr.should == 4
276
+ expect(@klass.attr).to eql(4)
277
277
  end
278
278
 
279
279
  it "save should not save anything for it" do
280
- @klass.save.should == {}
280
+ expect(@klass.save).to eql({})
281
281
  end
282
282
 
283
283
  it "save with include_defaults should save all defaults" do
284
- @klass.save(true).should == { :attr => 4 }
284
+ expect(@klass.save(true)).to eql({ :attr => 4 })
285
285
  end
286
286
 
287
- it "save should save the new value if it gets set" do
287
+ it "saves the new value if it gets set" do
288
288
  @klass.attr 5
289
- (saved = @klass.save).should == { :attr => 5 }
289
+ expect((saved = @klass.save)).to eql({ :attr => 5 })
290
290
  @klass.reset
291
- @klass.attr.should == 4
291
+ expect(@klass.attr).to eql(4)
292
292
  @klass.restore(saved)
293
- @klass.attr.should == 5
293
+ expect(@klass.attr).to eql(5)
294
294
  end
295
295
 
296
- it "save should save the new value even if it is set to its default value" do
296
+ it "saves the new value even if it is set to its default value" do
297
297
  @klass.attr 4
298
- (saved = @klass.save).should == { :attr => 4 }
298
+ expect((saved = @klass.save)).to eql({ :attr => 4 })
299
299
  @klass.reset
300
- @klass.save.should == {}
300
+ expect(@klass.save).to eql({})
301
301
  @klass.restore(saved)
302
- @klass.save.should == { :attr => 4 }
302
+ expect(@klass.save).to eql({ :attr => 4 })
303
303
  end
304
304
  end
305
305
 
@@ -313,61 +313,61 @@ describe Mixlib::Config do
313
313
  end
314
314
  end
315
315
 
316
- it "should default to that value" do
317
- @klass.attr.should == 8
316
+ it "defaults to that value" do
317
+ expect(@klass.attr).to eql(8)
318
318
  end
319
319
 
320
- it "should be recalculated each time it is retrieved" do
321
- @klass.attr.should == 8
320
+ it "is recalculated each time it is retrieved" do
321
+ expect(@klass.attr).to eql(8)
322
322
  @klass.x = 2
323
- @klass.attr.should == 4
323
+ expect(@klass.attr).to eql(4)
324
324
  end
325
325
 
326
- it "should default to that value when retrieved as a hash" do
327
- @klass[:attr].should == 8
326
+ it "defaults to that value when retrieved as a hash" do
327
+ expect(@klass[:attr]).to eql(8)
328
328
  end
329
329
 
330
- it "should be settable to another value" do
330
+ it "is settable to another value" do
331
331
  @klass.attr 5
332
- @klass.attr.should == 5
332
+ expect(@klass.attr).to eql(5)
333
333
  end
334
334
 
335
- it "should still default to that value after delete" do
335
+ it "still defaults to that value after delete" do
336
336
  @klass.attr 5
337
337
  @klass.delete(:attr)
338
- @klass.attr.should == 8
338
+ expect(@klass.attr).to eql(8)
339
339
  end
340
340
 
341
- it "should still default to that value after reset" do
341
+ it "still defaults to that value after reset" do
342
342
  @klass.attr 5
343
343
  @klass.reset
344
- @klass.attr.should == 8
344
+ expect(@klass.attr).to eql(8)
345
345
  end
346
346
 
347
347
  it "save should not save anything for it" do
348
- @klass.save.should == {}
348
+ expect(@klass.save).to eql({})
349
349
  end
350
350
 
351
351
  it "save with include_defaults should save all defaults" do
352
- @klass.save(true).should == { :attr => 8, :x => 4 }
352
+ expect(@klass.save(true)).to eql({ :attr => 8, :x => 4 })
353
353
  end
354
354
 
355
- it "save should save the new value if it gets set" do
355
+ it "saves the new value if it gets set" do
356
356
  @klass.attr 5
357
- (saved = @klass.save).should == { :attr => 5 }
357
+ expect((saved = @klass.save)).to eql({ :attr => 5 })
358
358
  @klass.reset
359
- @klass.attr.should == 8
359
+ expect(@klass.attr).to eql(8)
360
360
  @klass.restore(saved)
361
- @klass.attr.should == 5
361
+ expect(@klass.attr).to eql(5)
362
362
  end
363
363
 
364
- it "save should save the new value even if it is set to its default value" do
364
+ it "saves the new value even if it is set to its default value" do
365
365
  @klass.attr 8
366
- (saved = @klass.save).should == { :attr => 8 }
366
+ expect((saved = @klass.save)).to eql({ :attr => 8 })
367
367
  @klass.reset
368
- @klass.save.should == {}
368
+ expect(@klass.save).to eql({})
369
369
  @klass.restore(saved)
370
- @klass.save.should == { :attr => 8 }
370
+ expect(@klass.save).to eql({ :attr => 8 })
371
371
  end
372
372
  end
373
373
 
@@ -380,35 +380,35 @@ describe Mixlib::Config do
380
380
 
381
381
  it "reset clears it to its default" do
382
382
  @klass.attr << "x"
383
- @klass.attr.should == [ "x" ]
383
+ expect(@klass.attr).to eql([ "x" ])
384
384
  @klass.reset
385
- @klass.attr.should == []
385
+ expect(@klass.attr).to eql([])
386
386
  end
387
387
 
388
388
  it "save should not save anything for it" do
389
- @klass.save.should == {}
389
+ expect(@klass.save).to eql({})
390
390
  end
391
391
 
392
392
  it "save with include_defaults should save all defaults" do
393
- @klass.save(true).should == { :attr => [] }
393
+ expect(@klass.save(true)).to eql({ :attr => [] })
394
394
  end
395
395
 
396
- it "save should save the new value if it gets set" do
396
+ it "saves the new value if it gets set" do
397
397
  @klass.attr << "x"
398
- (saved = @klass.save).should == { :attr => [ "x" ] }
398
+ expect((saved = @klass.save)).to eql({ :attr => [ "x" ] })
399
399
  @klass.reset
400
- @klass.attr.should == []
400
+ expect(@klass.attr).to eql([])
401
401
  @klass.restore(saved)
402
- @klass.attr.should == [ "x" ]
402
+ expect(@klass.attr).to eql([ "x" ])
403
403
  end
404
404
 
405
- it "save should save the new value even if it is set to its default value" do
405
+ it "saves the new value even if it is set to its default value" do
406
406
  @klass.attr = []
407
- (saved = @klass.save).should == { :attr => [] }
407
+ expect((saved = @klass.save)).to eql({ :attr => [] })
408
408
  @klass.reset
409
- @klass.save.should == {}
409
+ expect(@klass.save).to eql({})
410
410
  @klass.restore(saved)
411
- @klass.save.should == { :attr => [] }
411
+ expect(@klass.save).to eql({ :attr => [] })
412
412
  end
413
413
  end
414
414
 
@@ -421,35 +421,35 @@ describe Mixlib::Config do
421
421
 
422
422
  it "reset clears it to its default" do
423
423
  @klass.attr[:x] = 10
424
- @klass.attr[:x].should == 10
424
+ expect(@klass.attr[:x]).to eql(10)
425
425
  @klass.reset
426
- @klass.attr[:x].should == nil
426
+ expect(@klass.attr[:x]).to be_nil
427
427
  end
428
428
 
429
429
  it "save should not save anything for it" do
430
- @klass.save.should == {}
430
+ expect(@klass.save).to eql({})
431
431
  end
432
432
 
433
433
  it "save with include_defaults should save all defaults" do
434
- @klass.save(true).should == { :attr => {} }
434
+ expect(@klass.save(true)).to eql({ :attr => {} })
435
435
  end
436
436
 
437
- it "save should save the new value if it gets set" do
437
+ it "saves the new value if it gets set" do
438
438
  @klass.attr[:hi] = "lo"
439
- (saved = @klass.save).should == { :attr => { :hi => "lo" } }
439
+ expect((saved = @klass.save)).to eql({ :attr => { :hi => "lo" } })
440
440
  @klass.reset
441
- @klass.attr.should == {}
441
+ expect(@klass.attr).to eql({})
442
442
  @klass.restore(saved)
443
- @klass.save.should == { :attr => { :hi => "lo" } }
443
+ expect(@klass.save).to eql({ :attr => { :hi => "lo" } })
444
444
  end
445
445
 
446
- it "save should save the new value even if it is set to its default value" do
446
+ it "saves the new value even if it is set to its default value" do
447
447
  @klass.attr = {}
448
- (saved = @klass.save).should == { :attr => {} }
448
+ expect((saved = @klass.save)).to eql({ :attr => {} })
449
449
  @klass.reset
450
- @klass.save.should == {}
450
+ expect(@klass.save).to eql({})
451
451
  @klass.restore(saved)
452
- @klass.save.should == { :attr => {} }
452
+ expect(@klass.save).to eql({ :attr => {} })
453
453
  end
454
454
  end
455
455
 
@@ -462,35 +462,35 @@ describe Mixlib::Config do
462
462
 
463
463
  it "reset clears it to its default" do
464
464
  @klass.attr << " world"
465
- @klass.attr.should == "hello world"
465
+ expect(@klass.attr).to eql("hello world")
466
466
  @klass.reset
467
- @klass.attr.should == "hello"
467
+ expect(@klass.attr).to eql("hello")
468
468
  end
469
469
 
470
470
  it "save should not save anything for it" do
471
- @klass.save.should == {}
471
+ expect(@klass.save).to eql({})
472
472
  end
473
473
 
474
474
  it "save with include_defaults should save all defaults" do
475
- @klass.save(true).should == { :attr => "hello" }
475
+ expect(@klass.save(true)).to eql({ :attr => "hello" })
476
476
  end
477
477
 
478
- it "save should save the new value if it gets set" do
478
+ it "saves the new value if it gets set" do
479
479
  @klass.attr << " world"
480
- (saved = @klass.save).should == { :attr => "hello world" }
480
+ expect((saved = @klass.save)).to eql({ :attr => "hello world" })
481
481
  @klass.reset
482
- @klass.attr.should == "hello"
482
+ expect(@klass.attr).to eql("hello")
483
483
  @klass.restore(saved)
484
- @klass.attr.should == "hello world"
484
+ expect(@klass.attr).to eql("hello world")
485
485
  end
486
486
 
487
- it "save should save the new value even if it is set to its default value" do
487
+ it "saves the new value even if it is set to its default value" do
488
488
  @klass.attr "hello world"
489
- (saved = @klass.save).should == { :attr => "hello world" }
489
+ expect((saved = @klass.save)).to eql({ :attr => "hello world" })
490
490
  @klass.reset
491
- @klass.save.should == {}
491
+ expect(@klass.save).to eql({})
492
492
  @klass.restore(saved)
493
- @klass.save.should == { :attr => "hello world" }
493
+ expect(@klass.save).to eql({ :attr => "hello world" })
494
494
  end
495
495
  end
496
496
 
@@ -503,56 +503,56 @@ describe Mixlib::Config do
503
503
  end
504
504
  end
505
505
 
506
- it "should default to that value" do
507
- @klass.attr.should == 4
506
+ it "defaults to that value" do
507
+ expect(@klass.attr).to eql(4)
508
508
  end
509
509
 
510
- it "should default to that value when retrieved as a hash" do
511
- @klass[:attr].should == 4
510
+ it "defaults to that value when retrieved as a hash" do
511
+ expect(@klass[:attr]).to eql(4)
512
512
  end
513
513
 
514
- it "should be settable to another value" do
514
+ it "is settable to another value" do
515
515
  @klass.attr 5
516
- @klass.attr.should == 5
517
- @klass[:attr].should == 5
516
+ expect(@klass.attr).to eql(5)
517
+ expect(@klass[:attr]).to eql(5)
518
518
  end
519
519
 
520
- it "should still default to that value after delete" do
520
+ it "still defaults to that value after delete" do
521
521
  @klass.attr 5
522
522
  @klass.delete(:attr)
523
- @klass.attr.should == 4
523
+ expect(@klass.attr).to eql(4)
524
524
  end
525
525
 
526
- it "should still default to that value after reset" do
526
+ it "still defaults to that value after reset" do
527
527
  @klass.attr 5
528
528
  @klass.reset
529
- @klass.attr.should == 4
529
+ expect(@klass.attr).to eql(4)
530
530
  end
531
531
 
532
532
  it "save should not save anything for it" do
533
- @klass.save.should == {}
533
+ expect(@klass.save).to eql({})
534
534
  end
535
535
 
536
536
  it "save with include_defaults should save all defaults" do
537
- @klass.save(true).should == { :attr => 4 }
537
+ expect(@klass.save(true)).to eql({ :attr => 4 })
538
538
  end
539
539
 
540
- it "save should save the new value if it gets set" do
540
+ it "saves the new value if it gets set" do
541
541
  @klass.attr 5
542
- (saved = @klass.save).should == { :attr => 5 }
542
+ expect((saved = @klass.save)).to eql({ :attr => 5 })
543
543
  @klass.reset
544
- @klass.attr.should == 4
544
+ expect(@klass.attr).to eql(4)
545
545
  @klass.restore(saved)
546
- @klass.attr.should == 5
546
+ expect(@klass.attr).to eql(5)
547
547
  end
548
548
 
549
- it "save should save the new value even if it is set to its default value" do
549
+ it "saves the new value even if it is set to its default value" do
550
550
  @klass.attr 4
551
- (saved = @klass.save).should == { :attr => 4 }
551
+ expect((saved = @klass.save)).to eql({ :attr => 4 })
552
552
  @klass.reset
553
- @klass.save.should == {}
553
+ expect(@klass.save).to eql({})
554
554
  @klass.restore(saved)
555
- @klass.save.should == { :attr => 4 }
555
+ expect(@klass.save).to eql({ :attr => 4 })
556
556
  end
557
557
  end
558
558
 
@@ -568,68 +568,68 @@ describe Mixlib::Config do
568
568
  end
569
569
  end
570
570
 
571
- it "should default to that value" do
572
- @klass.attr.should == 4
571
+ it "defaults to that value" do
572
+ expect(@klass.attr).to eql(4)
573
573
  end
574
574
 
575
- it "should default to that value when retrieved as a hash" do
576
- @klass[:attr].should == 4
575
+ it "defaults to that value when retrieved as a hash" do
576
+ expect(@klass[:attr]).to eql(4)
577
577
  end
578
578
 
579
- it "should be settable to another value" do
579
+ it "is settable to another value" do
580
580
  @klass.attr 5
581
- @klass.attr.should == 10
582
- @klass[:attr].should == 10
581
+ expect(@klass.attr).to eql(10)
582
+ expect(@klass[:attr]).to eql(10)
583
583
  end
584
584
 
585
- it "should be settable to another value with attr=" do
585
+ it "is settable to another value with attr=" do
586
586
  @klass.attr = 5
587
- @klass.attr.should == 10
588
- @klass[:attr].should == 10
587
+ expect(@klass.attr).to eql(10)
588
+ expect(@klass[:attr]).to eql(10)
589
589
  end
590
590
 
591
- it "should be settable to another value with [:attr]=" do
591
+ it "is settable to another value with [:attr]=" do
592
592
  @klass[:attr] = 5
593
- @klass.attr.should == 10
594
- @klass[:attr].should == 10
593
+ expect(@klass.attr).to eql(10)
594
+ expect(@klass[:attr]).to eql(10)
595
595
  end
596
596
 
597
- it "should still default to that value after delete" do
597
+ it "still defaults to that value after delete" do
598
598
  @klass.attr 5
599
599
  @klass.delete(:attr)
600
- @klass.attr.should == 4
600
+ expect(@klass.attr).to eql(4)
601
601
  end
602
602
 
603
- it "should still default to that value after reset" do
603
+ it "still defaults to that value after reset" do
604
604
  @klass.attr 5
605
605
  @klass.reset
606
- @klass.attr.should == 4
606
+ expect(@klass.attr).to eql(4)
607
607
  end
608
608
 
609
609
  it "save should not save anything for it" do
610
- @klass.save.should == {}
610
+ expect(@klass.save).to eql({})
611
611
  end
612
612
 
613
613
  it "save with include_defaults should save all defaults" do
614
- @klass.save(true).should == { :attr => 4 }
614
+ expect(@klass.save(true)).to eql({ :attr => 4 })
615
615
  end
616
616
 
617
- it "save should save the new value if it gets set" do
617
+ it "saves the new value if it gets set" do
618
618
  @klass.attr 5
619
- (saved = @klass.save).should == { :attr => 10 }
619
+ expect((saved = @klass.save)).to eql({ :attr => 10 })
620
620
  @klass.reset
621
- @klass.attr.should == 4
621
+ expect(@klass.attr).to eql(4)
622
622
  @klass.restore(saved)
623
- @klass.attr.should == 10
623
+ expect(@klass.attr).to eql(10)
624
624
  end
625
625
 
626
- it "save should save the new value even if it is set to its default value" do
626
+ it "saves the new value even if it is set to its default value" do
627
627
  @klass.attr 4
628
- (saved = @klass.save).should == { :attr => 8 }
628
+ expect((saved = @klass.save)).to eql({ :attr => 8 })
629
629
  @klass.reset
630
- @klass.save.should == {}
630
+ expect(@klass.save).to eql({})
631
631
  @klass.restore(saved)
632
- @klass.save.should == { :attr => 8 }
632
+ expect(@klass.save).to eql({ :attr => 8 })
633
633
  end
634
634
  end
635
635
 
@@ -642,68 +642,68 @@ describe Mixlib::Config do
642
642
  end
643
643
  end
644
644
 
645
- it "should default to that value" do
646
- @klass.attr.should == 4
645
+ it "defaults to that value" do
646
+ expect(@klass.attr).to eql(4)
647
647
  end
648
648
 
649
- it "should default to that value when retrieved as a hash" do
650
- @klass[:attr].should == 4
649
+ it "defaults to that value when retrieved as a hash" do
650
+ expect(@klass[:attr]).to eql(4)
651
651
  end
652
652
 
653
- it "should be settable to another value" do
653
+ it "is settable to another value" do
654
654
  @klass.attr 5
655
- @klass.attr.should == 10
656
- @klass[:attr].should == 10
655
+ expect(@klass.attr).to eql(10)
656
+ expect(@klass[:attr]).to eql(10)
657
657
  end
658
658
 
659
- it "should be settable to another value with attr=" do
659
+ it "is settable to another value with attr=" do
660
660
  @klass.attr = 5
661
- @klass.attr.should == 10
662
- @klass[:attr].should == 10
661
+ expect(@klass.attr).to eql(10)
662
+ expect(@klass[:attr]).to eql(10)
663
663
  end
664
664
 
665
- it "should be settable to another value with [:attr]=" do
665
+ it "is settable to another value with [:attr]=" do
666
666
  @klass[:attr] = 5
667
- @klass.attr.should == 10
668
- @klass[:attr].should == 10
667
+ expect(@klass.attr).to eql(10)
668
+ expect(@klass[:attr]).to eql(10)
669
669
  end
670
670
 
671
- it "should still default to that value after delete" do
671
+ it "still defaults to that value after delete" do
672
672
  @klass.attr 5
673
673
  @klass.delete(:attr)
674
- @klass.attr.should == 4
674
+ expect(@klass.attr).to eql(4)
675
675
  end
676
676
 
677
- it "should still default to that value after reset" do
677
+ it "still defaults to that value after reset" do
678
678
  @klass.attr 5
679
679
  @klass.reset
680
- @klass.attr.should == 4
680
+ expect(@klass.attr).to eql(4)
681
681
  end
682
682
 
683
683
  it "save should not save anything for it" do
684
- @klass.save.should == {}
684
+ expect(@klass.save).to eql({})
685
685
  end
686
686
 
687
687
  it "save with include_defaults should save all defaults" do
688
- @klass.save(true).should == { :attr => 4 }
688
+ expect(@klass.save(true)).to eql({ :attr => 4 })
689
689
  end
690
690
 
691
- it "save should save the new value if it gets set" do
691
+ it "saves the new value if it gets set" do
692
692
  @klass.attr 5
693
- (saved = @klass.save).should == { :attr => 10 }
693
+ expect((saved = @klass.save)).to eql({ :attr => 10 })
694
694
  @klass.reset
695
- @klass.attr.should == 4
695
+ expect(@klass.attr).to eql(4)
696
696
  @klass.restore(saved)
697
- @klass.attr.should == 10
697
+ expect(@klass.attr).to eql(10)
698
698
  end
699
699
 
700
- it "save should save the new value even if it is set to its default value" do
700
+ it "saves the new value even if it is set to its default value" do
701
701
  @klass.attr 2
702
- (saved = @klass.save).should == { :attr => 4 }
702
+ expect((saved = @klass.save)).to eql({ :attr => 4 })
703
703
  @klass.reset
704
- @klass.save.should == {}
704
+ expect(@klass.save).to eql({})
705
705
  @klass.restore(saved)
706
- @klass.save.should == { :attr => 4 }
706
+ expect(@klass.save).to eql({ :attr => 4 })
707
707
  end
708
708
  end
709
709
 
@@ -720,63 +720,63 @@ describe Mixlib::Config do
720
720
  end
721
721
 
722
722
  it "configurable defaults in that context work" do
723
- @klass.blah.x.should == 5
723
+ expect(@klass.blah.x).to eql(5)
724
724
  end
725
725
 
726
726
  it "after setting values in the context, the values remain set" do
727
727
  @klass.blah.x = 10
728
- @klass.blah.x.should == 10
728
+ expect(@klass.blah.x).to eql(10)
729
729
  end
730
730
 
731
731
  it "setting values with the same name in the parent context do not affect the child context" do
732
732
  @klass.x = 10
733
- @klass.x.should == 10
734
- @klass.blah.x.should == 5
733
+ expect(@klass.x).to eql(10)
734
+ expect(@klass.blah.x).to eql(5)
735
735
  end
736
736
 
737
737
  it "setting the entire context to a hash with default value overridden sets the value" do
738
738
  @klass.blah = { :x => 10 }
739
- @klass.blah.x.should == 10
739
+ expect(@klass.blah.x).to eql(10)
740
740
  end
741
741
 
742
742
  it "setting the entire context to a hash sets non-default values" do
743
743
  @klass.blah = { :y => 10 }
744
- @klass.blah.x.should == 5
745
- @klass.blah.y.should == 10
744
+ expect(@klass.blah.x).to eql(5)
745
+ expect(@klass.blah.y).to eql(10)
746
746
  end
747
747
 
748
748
  it "setting the entire context to a hash deletes any non-default values and resets default values" do
749
749
  @klass.blah.x = 10
750
750
  @klass.blah.y = 10
751
751
  @klass.blah = { :z => 10 }
752
- @klass.blah.x.should == 5
753
- @klass.blah.y.should == nil
754
- @klass.blah.z.should == 10
752
+ expect(@klass.blah.x).to eql(5)
753
+ expect(@klass.blah.y).to be_nil
754
+ expect(@klass.blah.z).to eql(10)
755
755
  end
756
756
 
757
757
  it "after reset of the parent class, children are reset" do
758
758
  @klass.blah.x = 10
759
- @klass.blah.x.should == 10
759
+ expect(@klass.blah.x).to eql(10)
760
760
  @klass.reset
761
- @klass.blah.x.should == 5
761
+ expect(@klass.blah.x).to eql(5)
762
762
  end
763
763
 
764
764
  it "save should not save anything for it by default" do
765
- @klass.save.should == {}
765
+ expect(@klass.save).to eql({})
766
766
  end
767
767
 
768
768
  it "save with include_defaults should save all defaults" do
769
- @klass.save(true).should == { :blah => { :x => 5 } }
769
+ expect(@klass.save(true)).to eql({ :blah => { :x => 5 } })
770
770
  end
771
771
 
772
- it "save should save any new values that are set in the context" do
772
+ it "saves any new values that are set in the context" do
773
773
  @klass.blah.x = 10
774
- (saved = @klass.save).should == { :blah => { :x => 10 } }
774
+ expect((saved = @klass.save)).to eql({ :blah => { :x => 10 } })
775
775
  @klass.reset
776
- @klass.blah.x.should == 5
776
+ expect(@klass.blah.x).to eql(5)
777
777
  @klass.restore(saved)
778
- @klass.blah.x.should == 10
779
- @klass.save.should == { :blah => { :x => 10 } }
778
+ expect(@klass.blah.x).to eql(10)
779
+ expect(@klass.save).to eql({ :blah => { :x => 10 } })
780
780
  end
781
781
  end
782
782
 
@@ -788,6 +788,7 @@ describe Mixlib::Config do
788
788
  config_context(:blah) do
789
789
  config_context(:yarr) do
790
790
  default :x, 5
791
+ default :y, 6
791
792
  end
792
793
  end
793
794
  configurable :x
@@ -795,43 +796,65 @@ describe Mixlib::Config do
795
796
  end
796
797
 
797
798
  it "configurable defaults in that context work" do
798
- @klass.blah.yarr.x.should == 5
799
+ expect(@klass.blah.yarr.x).to eql(5)
800
+ expect(@klass.blah.yarr.y).to eql(6)
799
801
  end
800
802
 
801
803
  it "after setting values in the context, the values remain set" do
802
804
  @klass.blah.yarr.x = 10
803
- @klass.blah.yarr.x.should == 10
805
+ @klass.blah.yarr.y = 11
806
+ expect(@klass.blah.yarr.x).to eql(10)
807
+ expect(@klass.blah.yarr.y).to eql(11)
804
808
  end
805
809
 
806
810
  it "setting values with the same name in the parent context do not affect the child context" do
807
811
  @klass.x = 10
808
- @klass.x.should == 10
809
- @klass.blah.yarr.x.should == 5
812
+ expect(@klass.x).to eql(10)
813
+ expect(@klass.blah.yarr.x).to eql(5)
810
814
  end
811
815
 
812
816
  it "after reset of the parent class, children are reset" do
813
817
  @klass.blah.yarr.x = 10
814
- @klass.blah.yarr.x.should == 10
818
+ @klass.blah.yarr.y = 11
819
+ expect(@klass.blah.yarr.x).to eql(10)
820
+ expect(@klass.blah.yarr.y).to eql(11)
815
821
  @klass.reset
816
- @klass.blah.yarr.x.should == 5
822
+ expect(@klass.blah.yarr.x).to eql(5)
823
+ expect(@klass.blah.yarr.y).to eql(6)
817
824
  end
818
825
 
819
826
  it "save should not save anything for it by default" do
820
- @klass.save.should == {}
827
+ expect(@klass.save).to eql({})
821
828
  end
822
829
 
823
830
  it "save with include_defaults should save all defaults" do
824
- @klass.save(true).should == { :blah => { :yarr => { :x => 5 } } }
831
+ expect(@klass.save(true)).to eql({ :blah => { :yarr => { :x => 5, :y => 6 } } })
825
832
  end
826
833
 
827
- it "save should save any new values that are set in the context" do
834
+ it "saves any new values that are set in the context" do
828
835
  @klass.blah.yarr.x = 10
829
- (saved = @klass.save).should == { :blah => { :yarr => { :x => 10 } } }
836
+ @klass.blah.yarr.y = 11
837
+ expect((saved = @klass.save)).to eql({ :blah => { :yarr => { :x => 10, :y => 11 } } })
830
838
  @klass.reset
831
- @klass.blah.yarr.x.should == 5
839
+ expect(@klass.blah.yarr.x).to eql(5)
840
+ expect(@klass.blah.yarr.y).to eql(6)
832
841
  @klass.restore(saved)
833
- @klass.blah.yarr.x.should == 10
834
- @klass.save.should == { :blah => { :yarr => { :x => 10 } } }
842
+ expect(@klass.blah.yarr.x).to eql(10)
843
+ expect(@klass.blah.yarr.y).to eql(11)
844
+ expect(@klass.save).to eql({ :blah => { :yarr => { :x => 10, :y => 11 } } })
845
+ end
846
+
847
+ it "restores defaults not included in saved data" do
848
+ @klass.restore( :blah => { :yarr => { :x => 10 } } )
849
+ expect(@klass.blah.yarr.x).to eql(10)
850
+ expect(@klass.blah.yarr.y).to eql(6)
851
+ end
852
+
853
+ it "resmoves added properties not included in saved state" do
854
+ @klass.blah.yarr.z = 12
855
+ @klass.restore( :blah => { :yarr => { :x => 10 } } )
856
+ expect(@klass.blah.yarr.x).to eql(10)
857
+ expect(@klass.blah.yarr.z).to eql(nil)
835
858
  end
836
859
  end
837
860
 
@@ -847,11 +870,11 @@ describe Mixlib::Config do
847
870
  end
848
871
 
849
872
  it "save does not save the hash for the config_context" do
850
- @klass.save.should == {}
873
+ expect(@klass.save).to eql({})
851
874
  end
852
875
 
853
876
  it "save with defaults saves the hash for the config_context" do
854
- @klass.save(true).should == { :blah => {} }
877
+ expect(@klass.save(true)).to eql({ :blah => {} })
855
878
  end
856
879
  end
857
880
 
@@ -865,11 +888,11 @@ describe Mixlib::Config do
865
888
  end
866
889
 
867
890
  it "save does not save the hash for the config_context" do
868
- @klass.save.should == {}
891
+ expect(@klass.save).to eql({})
869
892
  end
870
893
 
871
894
  it "save with defaults saves the hash for the config_context" do
872
- @klass.save(true).should == { :blah => {} }
895
+ expect(@klass.save(true)).to eql({ :blah => {} })
873
896
  end
874
897
  end
875
898
 
@@ -887,7 +910,7 @@ describe Mixlib::Config do
887
910
  end
888
911
 
889
912
  it "The nested class does not allow you to set arbitrary config options" do
890
- lambda { StrictClass2.c.y = 10 }.should raise_error(Mixlib::Config::UnknownConfigOptionError, "Cannot set unsupported config value y.")
913
+ expect(lambda { StrictClass2.c.y = 10 }).to raise_error(Mixlib::Config::UnknownConfigOptionError, "Cannot set unsupported config value y.")
891
914
  end
892
915
  end
893
916
 
@@ -900,11 +923,11 @@ describe Mixlib::Config do
900
923
  end
901
924
 
902
925
  it "The parent class does not allow you to set arbitrary config options" do
903
- lambda { StrictClass3.y = 10 }.should raise_error(Mixlib::Config::UnknownConfigOptionError, "Cannot set unsupported config value y.")
926
+ expect(lambda { StrictClass3.y = 10 }).to raise_error(Mixlib::Config::UnknownConfigOptionError, "Cannot set unsupported config value y.")
904
927
  end
905
928
 
906
929
  it "The nested class does not allow you to set arbitrary config options" do
907
- lambda { StrictClass3.y = 10 }.should raise_error(Mixlib::Config::UnknownConfigOptionError, "Cannot set unsupported config value y.")
930
+ expect(lambda { StrictClass3.y = 10 }).to raise_error(Mixlib::Config::UnknownConfigOptionError, "Cannot set unsupported config value y.")
908
931
  end
909
932
  end
910
933
 
@@ -931,27 +954,27 @@ describe Mixlib::Config do
931
954
  it "When a config_context is opened in place of a regular configurable, an error is raised" do
932
955
  klass = Class.new
933
956
  klass.extend(::Mixlib::Config)
934
- lambda do
957
+ expect(lambda do
935
958
  klass.class_eval do
936
959
  default :blah, 10
937
960
  config_context(:blah) do
938
961
  default :y, 20
939
962
  end
940
963
  end
941
- end.should raise_error(Mixlib::Config::ReopenedConfigurableWithConfigContextError)
964
+ end).to raise_error(Mixlib::Config::ReopenedConfigurableWithConfigContextError)
942
965
  end
943
966
 
944
967
  it "When a config_context is opened in place of a regular configurable, an error is raised" do
945
968
  klass = Class.new
946
969
  klass.extend(::Mixlib::Config)
947
- lambda do
970
+ expect(lambda do
948
971
  klass.class_eval do
949
972
  config_context(:blah) do
950
973
  default :y, 20
951
974
  end
952
975
  default :blah, 10
953
976
  end
954
- end.should raise_error(Mixlib::Config::ReopenedConfigContextWithConfigurableError)
977
+ end).to raise_error(Mixlib::Config::ReopenedConfigContextWithConfigurableError)
955
978
  end
956
979
 
957
980
  end