From d4012dbf2e7e041e8e24eda6cd896b6f6e4fac4d Mon Sep 17 00:00:00 2001 From: Daniel Pittman Date: Wed, 6 Apr 2011 16:28:56 -0700 Subject: (#6995) Fix indexing of :current on string load. We do this by implementing a standard mechanism for finding the current version out of the default file, and only supporting that one file. This implements our decision to lazy-evaluate the extra version support stuff as much as possible. Reviewed-By: Dan Bode --- spec/unit/string/string_collection_spec.rb | 54 +++++++++++++----------------- 1 file changed, 23 insertions(+), 31 deletions(-) (limited to 'spec/unit/string') diff --git a/spec/unit/string/string_collection_spec.rb b/spec/unit/string/string_collection_spec.rb index fa63f18e3..fab647da0 100755 --- a/spec/unit/string/string_collection_spec.rb +++ b/spec/unit/string/string_collection_spec.rb @@ -70,7 +70,6 @@ describe Puppet::String::StringCollection do it "should attempt to load the string if it isn't found" do subject.expects(:require).with('puppet/string/bar') - subject.expects(:require).with('bar@0.0.1/puppet/string/bar') subject["bar", '0.0.1'] end @@ -104,26 +103,15 @@ describe Puppet::String::StringCollection do end end - it "should require the string by version if the 'current' version isn't it" do - subject.expects(:require).with('puppet/string/bar'). - raises(LoadError, 'no such file to load -- puppet/string/bar') - subject.expects(:require).with do |file| - subject.instance_variable_get("@strings")[:bar]['0.0.1'] = true - file == 'bar@0.0.1/puppet/string/bar' - end - subject.string?("bar", '0.0.1').should == true - end - it "should return false if the string is not registered" do subject.stubs(:require).returns(true) - subject.string?("bar", '0.0.1').should == false + subject.string?("bar", '0.0.1').should be_false end - it "should return false if there is a LoadError requiring the string" do + it "should return false if the string file itself is missing" do subject.stubs(:require). - raises(LoadError, 'no such file to load -- puppet/string/bar').then. - raises(LoadError, 'no such file to load -- bar@0.0.1/puppet/string/bar') - subject.string?("bar", '0.0.1').should == false + raises(LoadError, 'no such file to load -- puppet/string/bar') + subject.string?("bar", '0.0.1').should be_false end it "should register the version loaded by `:current` as `:current`" do @@ -135,24 +123,28 @@ describe Puppet::String::StringCollection do subject.instance_variable_get("@strings")[:huzzah][:current].should == :huzzah_string end - it "should register the version loaded from `puppet/string/{name}` as `:current`" do - subject.expects(:require).with do |file| - subject.instance_variable_get("@strings")[:huzzah]['2.0.1'] = :huzzah_string - file == 'puppet/string/huzzah' + context "with something on disk" do + before :each do + write_scratch_string :huzzah do |fh| + fh.puts <