spec/unit/util/storage.rb in puppet-0.24.9 vs spec/unit/util/storage.rb in puppet-0.25.0

- old
+ new

@@ -10,17 +10,17 @@ describe Puppet::Util::Storage do before(:all) do Puppet[:statedir] = Dir.tmpdir() end + after(:all) do + Puppet.settings.clear + end + before(:each) do Puppet::Util::Storage.clear() end - - after do - Puppet::Type.type(:file).clear - end describe "when caching a symbol" do it "should return an empty hash" do Puppet::Util::Storage.cache(:yayness).should == {} Puppet::Util::Storage.cache(:more_yayness).should == {} @@ -39,12 +39,12 @@ end end describe "when caching a Puppet::Type" do before(:all) do - @file_test = Puppet.type(:file).create(:name => "/yayness", :check => %w{checksum type}) - @exec_test = Puppet.type(:exec).create(:name => "/bin/ls /yayness") + @file_test = Puppet::Type.type(:file).new(:name => "/yayness", :check => %w{checksum type}) + @exec_test = Puppet::Type.type(:exec).new(:name => "/bin/ls /yayness") end it "should return an empty hash" do Puppet::Util::Storage.cache(@file_test).should == {} Puppet::Util::Storage.cache(@exec_test).should == {} @@ -97,11 +97,11 @@ before(:each) do transient = Tempfile.new('storage_test') @path = transient.path() transient.close!() end - + it "should not fail to load()" do FileTest.exists?(@path).should be_false() Puppet[:statedir] = @path proc { Puppet::Util::Storage.load() }.should_not raise_error() Puppet[:statefile] = @path @@ -111,14 +111,14 @@ it "should not lose its internal state when load() is called" do FileTest.exists?(@path).should be_false() Puppet::Util::Storage.cache(:yayness) Puppet::Util::Storage.state().should == {:yayness=>{}} - + Puppet[:statefile] = @path proc { Puppet::Util::Storage.load() }.should_not raise_error() - + Puppet::Util::Storage.state().should == {:yayness=>{}} end end describe "when the state file/directory exists" do @@ -142,11 +142,11 @@ YAML.expects(:load).returns(test_yaml) proc { Puppet::Util::Storage.load() }.should_not raise_error() Puppet::Util::Storage.state().should == test_yaml end - + it "should initialize with a clear internal state if the state file does not contain valid YAML" do @state_file.write(:booness) @state_file.flush() proc { Puppet::Util::Storage.load() }.should_not raise_error() @@ -186,10 +186,10 @@ YAML.expects(:load).returns(test_yaml) proc { Puppet::Util::Storage.load() }.should_not raise_error() Puppet::Util::Storage.state().should == test_yaml end - + after(:each) do @state_file.close!() Puppet[:statefile] = @saved_statefile end end