spec/mixlib/config_spec.rb in mixlib-config-1.1.0.rc01 vs spec/mixlib/config_spec.rb in mixlib-config-1.1.0

- old
+ new

@@ -16,15 +16,10 @@ # limitations under the License. # require File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_helper")) -class ConfigIt - extend ::Mixlib::Config -end - - describe Mixlib::Config do before(:each) do ConfigIt.configure do |c| c[:alpha] = 'omega' c[:foo] = nil @@ -99,43 +94,49 @@ ConfigIt.has_key?(:monkey).should eql(true) end describe "when a class method override accessor exists" do before do - @klass = Class.new - @klass.extend(::Mixlib::Config) - @klass.class_eval(<<-EVAL) + class ConfigIt + config_attr_writer :test_method do |blah| blah.is_a?(Integer) ? blah * 1000 : blah end - pp self.methods - EVAL + + end end it "should multiply an integer by 1000" do - @klass[:test_method] = 53 - @klass[:test_method].should == 53000 + ConfigIt[:test_method] = 53 + ConfigIt[:test_method].should == 53000 end it "should multiply an integer by 1000 with the method_missing form" do - @klass.test_method = 63 - @klass.test_method.should == 63000 + ConfigIt.test_method = 63 + ConfigIt.test_method.should == 63000 end it "should multiply an integer by 1000 with the instance_eval DSL form" do - @klass.instance_eval("test_method 73") - @klass.test_method.should == 73000 + ConfigIt.instance_eval("test_method 73") + ConfigIt.test_method.should == 73000 end it "should multiply an integer by 1000 via from-file, too" do IO.stub!(:read).with('config.rb').and_return("test_method 99") - @klass.from_file('config.rb') - @klass.test_method.should == 99000 + ConfigIt.from_file('config.rb') + ConfigIt.test_method.should == 99000 end it "should receive internal_set with the method name and config value" do - @klass.should_receive(:internal_set).with(:test_method, 53).and_return(true) - @klass[:test_method] = 53 + ConfigIt.should_receive(:internal_set).with(:test_method, 53).and_return(true) + ConfigIt[:test_method] = 53 end + after do + class ConfigIt + class << self + undef test_method= + end + end + end end end