summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Keiser <jkeiser@opscode.com>2014-05-26 21:58:40 -0700
committerJohn Keiser <jkeiser@opscode.com>2014-09-09 21:03:00 -0700
commit9fa62a5c01b5cf3d5f29818b3c808b5c02ddbdeb (patch)
tree66ddc980618e30056ca6d9c9adceeac963f7a842
parentda2f0ae30bf6d19f236ad7b0742a2b75e586fb8b (diff)
downloadmixlib-config-jk/strict-error.tar.gz
Fix strict mode errors to actually print symboljk/strict-error
-rw-r--r--lib/mixlib/config.rb8
-rw-r--r--spec/mixlib/config_spec.rb22
2 files changed, 15 insertions, 15 deletions
diff --git a/lib/mixlib/config.rb b/lib/mixlib/config.rb
index 442c40f..b70c11d 100644
--- a/lib/mixlib/config.rb
+++ b/lib/mixlib/config.rb
@@ -50,7 +50,7 @@ module Mixlib
# Pass Mixlib::Config.configure() a block, and it will yield itself
#
# === Parameters
- # block<Block>:: A block that is called with self.configuration as the arugment.
+ # block<Block>:: A block that is called with self.configuration as the argument.
def configure(&block)
block.call(self.configuration)
end
@@ -403,7 +403,7 @@ module Mixlib
# === Parameters
# symbol<Symbol>:: Name of the method (variable setter)
# value<Object>:: Value to be set in config hash
- #
+ #
def internal_set(symbol,value)
if configurables.has_key?(symbol)
configurables[symbol].set(self.configuration, value)
@@ -411,9 +411,9 @@ module Mixlib
config_contexts[symbol].restore(value)
else
if config_strict_mode == :warn
- Chef::Log.warn("Setting unsupported config value #{method_name}..")
+ Chef::Log.warn("Setting unsupported config value #{symbol}.")
elsif config_strict_mode
- raise UnknownConfigOptionError, "Cannot set unsupported config value #{method_name}."
+ raise UnknownConfigOptionError, "Cannot set unsupported config value #{symbol}."
end
configuration[symbol] = value
end
diff --git a/spec/mixlib/config_spec.rb b/spec/mixlib/config_spec.rb
index b5c753b..4610779 100644
--- a/spec/mixlib/config_spec.rb
+++ b/spec/mixlib/config_spec.rb
@@ -102,23 +102,23 @@ describe Mixlib::Config do
end
it "raises an error when you get an arbitrary config option with .y" do
- lambda { StrictClass.y }.should raise_error(Mixlib::Config::UnknownConfigOptionError)
+ lambda { StrictClass.y }.should raise_error(Mixlib::Config::UnknownConfigOptionError, "Reading unsupported config value y.")
end
it "raises an error when you get an arbitrary config option with [:y]" do
- lambda { StrictClass[:y] }.should raise_error(Mixlib::Config::UnknownConfigOptionError)
+ lambda { StrictClass[:y] }.should raise_error(Mixlib::Config::UnknownConfigOptionError, "Reading unsupported config value y.")
end
it "raises an error when you set an arbitrary config option with .y = 10" do
- lambda { StrictClass.y = 10 }.should raise_error(Mixlib::Config::UnknownConfigOptionError)
+ lambda { StrictClass.y = 10 }.should raise_error(Mixlib::Config::UnknownConfigOptionError, "Cannot set unsupported config value y.")
end
- it "raises an error when you get an arbitrary config option with .y 10" do
- lambda { StrictClass.y 10 }.should raise_error(Mixlib::Config::UnknownConfigOptionError)
+ it "raises an error when you set an arbitrary config option with .y 10" do
+ lambda { StrictClass.y 10 }.should raise_error(Mixlib::Config::UnknownConfigOptionError, "Cannot set unsupported config value y.")
end
- it "raises an error when you get an arbitrary config option with [:y] = 10" do
- lambda { StrictClass[:y] = 10 }.should raise_error(Mixlib::Config::UnknownConfigOptionError)
+ it "raises an error when you set an arbitrary config option with [:y] = 10" do
+ lambda { StrictClass[:y] = 10 }.should raise_error(Mixlib::Config::UnknownConfigOptionError, "Cannot set unsupported config value y.")
end
end
@@ -225,7 +225,7 @@ describe Mixlib::Config do
raise NopeError, "NOPE"
end
end
-
+
it 'Normal classes call the extra method' do
normal_class = Class.new
normal_class.extend(::Mixlib::Config)
@@ -887,7 +887,7 @@ describe Mixlib::Config do
end
it "The nested class does not allow you to set arbitrary config options" do
- lambda { StrictClass2.c.y = 10 }.should raise_error(Mixlib::Config::UnknownConfigOptionError)
+ lambda { StrictClass2.c.y = 10 }.should raise_error(Mixlib::Config::UnknownConfigOptionError, "Cannot set unsupported config value y.")
end
end
@@ -900,11 +900,11 @@ describe Mixlib::Config do
end
it "The parent class does not allow you to set arbitrary config options" do
- lambda { StrictClass3.y = 10 }.should raise_error(Mixlib::Config::UnknownConfigOptionError)
+ lambda { StrictClass3.y = 10 }.should raise_error(Mixlib::Config::UnknownConfigOptionError, "Cannot set unsupported config value y.")
end
it "The nested class does not allow you to set arbitrary config options" do
- lambda { StrictClass3.y = 10 }.should raise_error(Mixlib::Config::UnknownConfigOptionError)
+ lambda { StrictClass3.y = 10 }.should raise_error(Mixlib::Config::UnknownConfigOptionError, "Cannot set unsupported config value y.")
end
end