summaryrefslogtreecommitdiffstats
path: root/spec/unit/util/storage_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/util/storage_spec.rb')
-rwxr-xr-xspec/unit/util/storage_spec.rb90
1 files changed, 45 insertions, 45 deletions
diff --git a/spec/unit/util/storage_spec.rb b/spec/unit/util/storage_spec.rb
index ce5bd202a..c91702dfb 100755
--- a/spec/unit/util/storage_spec.rb
+++ b/spec/unit/util/storage_spec.rb
@@ -11,7 +11,7 @@ describe Puppet::Util::Storage do
before(:all) do
@basepath = Puppet.features.posix? ? "/somepath" : "C:/somepath"
- Puppet[:statedir] = Dir.tmpdir()
+ Puppet[:statedir] = Dir.tmpdir
end
after(:all) do
@@ -19,7 +19,7 @@ describe Puppet::Util::Storage do
end
before(:each) do
- Puppet::Util::Storage.clear()
+ Puppet::Util::Storage.clear
end
describe "when caching a symbol" do
@@ -30,14 +30,14 @@ describe Puppet::Util::Storage do
it "should add the symbol to its internal state" do
Puppet::Util::Storage.cache(:yayness)
- Puppet::Util::Storage.state().should == {:yayness=>{}}
+ Puppet::Util::Storage.state.should == {:yayness=>{}}
end
it "should not clobber existing state when caching additional objects" do
Puppet::Util::Storage.cache(:yayness)
- Puppet::Util::Storage.state().should == {:yayness=>{}}
+ Puppet::Util::Storage.state.should == {:yayness=>{}}
Puppet::Util::Storage.cache(:bubblyness)
- Puppet::Util::Storage.state().should == {:yayness=>{},:bubblyness=>{}}
+ Puppet::Util::Storage.state.should == {:yayness=>{},:bubblyness=>{}}
end
end
@@ -53,11 +53,11 @@ describe Puppet::Util::Storage do
end
it "should add the resource ref to its internal state" do
- Puppet::Util::Storage.state().should == {}
+ Puppet::Util::Storage.state.should == {}
Puppet::Util::Storage.cache(@file_test)
- Puppet::Util::Storage.state().should == {"File[#{@basepath}/yayness]"=>{}}
+ Puppet::Util::Storage.state.should == {"File[#{@basepath}/yayness]"=>{}}
Puppet::Util::Storage.cache(@exec_test)
- Puppet::Util::Storage.state().should == {"File[#{@basepath}/yayness]"=>{}, "Exec[#{@basepath}/bin/ls /yayness]"=>{}}
+ Puppet::Util::Storage.state.should == {"File[#{@basepath}/yayness]"=>{}, "Exec[#{@basepath}/bin/ls /yayness]"=>{}}
end
end
@@ -71,9 +71,9 @@ describe Puppet::Util::Storage do
it "should clear its internal state when clear() is called" do
Puppet::Util::Storage.cache(:yayness)
- Puppet::Util::Storage.state().should == {:yayness=>{}}
- Puppet::Util::Storage.clear()
- Puppet::Util::Storage.state().should == {}
+ Puppet::Util::Storage.state.should == {:yayness=>{}}
+ Puppet::Util::Storage.clear
+ Puppet::Util::Storage.state.should == {}
end
describe "when loading from the state file" do
@@ -89,23 +89,23 @@ describe Puppet::Util::Storage do
end
it "should not fail to load()" do
- FileTest.exists?(@path).should be_false()
+ FileTest.exists?(@path).should be_false
Puppet[:statedir] = @path
- proc { Puppet::Util::Storage.load() }.should_not raise_error()
+ proc { Puppet::Util::Storage.load }.should_not raise_error
Puppet[:statefile] = @path
- proc { Puppet::Util::Storage.load() }.should_not raise_error()
+ proc { Puppet::Util::Storage.load }.should_not raise_error
end
it "should not lose its internal state when load() is called" do
- FileTest.exists?(@path).should be_false()
+ FileTest.exists?(@path).should be_false
Puppet::Util::Storage.cache(:yayness)
- Puppet::Util::Storage.state().should == {:yayness=>{}}
+ Puppet::Util::Storage.state.should == {:yayness=>{}}
Puppet[:statefile] = @path
- proc { Puppet::Util::Storage.load() }.should_not raise_error()
+ proc { Puppet::Util::Storage.load }.should_not raise_error
- Puppet::Util::Storage.state().should == {:yayness=>{}}
+ Puppet::Util::Storage.state.should == {:yayness=>{}}
end
end
@@ -113,41 +113,41 @@ describe Puppet::Util::Storage do
before(:each) do
@state_file = Tempfile.new('storage_test')
@saved_statefile = Puppet[:statefile]
- Puppet[:statefile] = @state_file.path()
+ Puppet[:statefile] = @state_file.path
end
it "should overwrite its internal state if load() is called" do
# Should the state be overwritten even if Puppet[:statefile] is not valid YAML?
Puppet::Util::Storage.cache(:yayness)
- Puppet::Util::Storage.state().should == {:yayness=>{}}
+ Puppet::Util::Storage.state.should == {:yayness=>{}}
- proc { Puppet::Util::Storage.load() }.should_not raise_error()
- Puppet::Util::Storage.state().should == {}
+ proc { Puppet::Util::Storage.load }.should_not raise_error
+ Puppet::Util::Storage.state.should == {}
end
it "should restore its internal state if the state file contains valid YAML" do
test_yaml = {'File["/yayness"]'=>{"name"=>{:a=>:b,:c=>:d}}}
YAML.expects(:load).returns(test_yaml)
- proc { Puppet::Util::Storage.load() }.should_not raise_error()
- Puppet::Util::Storage.state().should == 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()
+ @state_file.flush
- proc { Puppet::Util::Storage.load() }.should_not raise_error()
- Puppet::Util::Storage.state().should == {}
+ proc { Puppet::Util::Storage.load }.should_not raise_error
+ Puppet::Util::Storage.state.should == {}
end
it "should raise an error if the state file does not contain valid YAML and cannot be renamed" do
@state_file.write(:booness)
- @state_file.flush()
+ @state_file.flush
YAML.expects(:load).raises(Puppet::Error)
File.expects(:rename).raises(SystemCallError)
- proc { Puppet::Util::Storage.load() }.should raise_error()
+ proc { Puppet::Util::Storage.load }.should raise_error
end
it "should attempt to rename the state file if the file is corrupted" do
@@ -155,14 +155,14 @@ describe Puppet::Util::Storage do
YAML.expects(:load).raises(Puppet::Error)
File.expects(:rename).at_least_once
- proc { Puppet::Util::Storage.load() }.should_not raise_error()
+ proc { Puppet::Util::Storage.load }.should_not raise_error
end
it "should fail gracefully on load() if the state file is not a regular file" do
@state_file.close!()
Dir.mkdir(Puppet[:statefile])
- proc { Puppet::Util::Storage.load() }.should_not raise_error()
+ proc { Puppet::Util::Storage.load }.should_not raise_error
Dir.rmdir(Puppet[:statefile])
end
@@ -172,8 +172,8 @@ describe Puppet::Util::Storage do
test_yaml = {'File["/yayness"]'=>{"name"=>{:a=>:b,:c=>:d}}}
YAML.expects(:load).returns(test_yaml)
- proc { Puppet::Util::Storage.load() }.should_not raise_error()
- Puppet::Util::Storage.state().should == test_yaml
+ proc { Puppet::Util::Storage.load }.should_not raise_error
+ Puppet::Util::Storage.state.should == test_yaml
end
after(:each) do
@@ -187,16 +187,16 @@ describe Puppet::Util::Storage do
before(:each) do
@state_file = Tempfile.new('storage_test')
@saved_statefile = Puppet[:statefile]
- Puppet[:statefile] = @state_file.path()
+ Puppet[:statefile] = @state_file.path
end
it "should create the state file if it does not exist" do
@state_file.close!()
- FileTest.exists?(Puppet[:statefile]).should be_false()
+ FileTest.exists?(Puppet[:statefile]).should be_false
Puppet::Util::Storage.cache(:yayness)
- proc { Puppet::Util::Storage.store() }.should_not raise_error()
- FileTest.exists?(Puppet[:statefile]).should be_true()
+ proc { Puppet::Util::Storage.store }.should_not raise_error
+ FileTest.exists?(Puppet[:statefile]).should be_true
end
it "should raise an exception if the state file is not a regular file" do
@@ -204,7 +204,7 @@ describe Puppet::Util::Storage do
Dir.mkdir(Puppet[:statefile])
Puppet::Util::Storage.cache(:yayness)
- proc { Puppet::Util::Storage.store() }.should raise_error()
+ proc { Puppet::Util::Storage.store }.should raise_error
Dir.rmdir(Puppet[:statefile])
end
@@ -213,18 +213,18 @@ describe Puppet::Util::Storage do
Puppet::Util::FileLocking.expects(:writelock).yields(false)
Puppet::Util::Storage.cache(:yayness)
- proc { Puppet::Util::Storage.store() }.should raise_error()
+ proc { Puppet::Util::Storage.store }.should raise_error
end
it "should load() the same information that it store()s" do
Puppet::Util::Storage.cache(:yayness)
- Puppet::Util::Storage.state().should == {:yayness=>{}}
- proc { Puppet::Util::Storage.store() }.should_not raise_error()
- Puppet::Util::Storage.clear()
- Puppet::Util::Storage.state().should == {}
- proc { Puppet::Util::Storage.load() }.should_not raise_error()
- Puppet::Util::Storage.state().should == {:yayness=>{}}
+ Puppet::Util::Storage.state.should == {:yayness=>{}}
+ proc { Puppet::Util::Storage.store }.should_not raise_error
+ Puppet::Util::Storage.clear
+ Puppet::Util::Storage.state.should == {}
+ proc { Puppet::Util::Storage.load }.should_not raise_error
+ Puppet::Util::Storage.state.should == {:yayness=>{}}
end
after(:each) do