diff options
author | Rick Bradley <rick@rickbradley.com> | 2008-02-18 14:18:17 -0600 |
---|---|---|
committer | Rick Bradley <rick@rickbradley.com> | 2008-02-18 14:18:17 -0600 |
commit | c86c1da76d22e96b792b35e8c46afa2656226918 (patch) | |
tree | 53ab73fffcf66ce70e335ccff119227c6e11b21c | |
parent | 61cdc2bcd82121319821e236cec1632779b19c26 (diff) | |
download | puppet-c86c1da76d22e96b792b35e8c46afa2656226918.tar.gz puppet-c86c1da76d22e96b792b35e8c46afa2656226918.tar.xz puppet-c86c1da76d22e96b792b35e8c46afa2656226918.zip |
converting node catalog specs from setup/teardown to before/after
-rwxr-xr-x | spec/unit/node/catalog.rb | 167 |
1 files changed, 82 insertions, 85 deletions
diff --git a/spec/unit/node/catalog.rb b/spec/unit/node/catalog.rb index aa49909e2..c3c5b328b 100755 --- a/spec/unit/node/catalog.rb +++ b/spec/unit/node/catalog.rb @@ -468,8 +468,8 @@ describe Puppet::Node::Catalog, " when functioning as a resource container" do end end -module ApplyingCatalogs - def setup +describe Puppet::Node::Catalog do + before :each do @catalog = Puppet::Node::Catalog.new("host") @catalog.retrieval_duration = Time.now @@ -479,114 +479,111 @@ module ApplyingCatalogs @transaction.stubs(:cleanup) @transaction.stubs(:addtimes) end -end -describe Puppet::Node::Catalog, " when applying" do - include ApplyingCatalogs + describe Puppet::Node::Catalog, " when applying" do - it "should create and evaluate a transaction" do - @transaction.expects(:evaluate) - @catalog.apply - end + it "should create and evaluate a transaction" do + @transaction.expects(:evaluate) + @catalog.apply + end - it "should provide the catalog time to the transaction" do - @transaction.expects(:addtimes).with do |arg| - arg[:config_retrieval].should be_instance_of(Time) - true + it "should provide the catalog time to the transaction" do + @transaction.expects(:addtimes).with do |arg| + arg[:config_retrieval].should be_instance_of(Time) + true + end + @catalog.apply end - @catalog.apply - end - it "should clean up the transaction" do - @transaction.expects :cleanup - @catalog.apply - end + it "should clean up the transaction" do + @transaction.expects :cleanup + @catalog.apply + end - it "should return the transaction" do - @catalog.apply.should equal(@transaction) - end + it "should return the transaction" do + @catalog.apply.should equal(@transaction) + end - it "should yield the transaction if a block is provided" do - @catalog.apply do |trans| - trans.should equal(@transaction) + it "should yield the transaction if a block is provided" do + @catalog.apply do |trans| + trans.should equal(@transaction) + end end - end - it "should default to not being a host catalog" do - @catalog.host_config.should be_nil - end + it "should default to not being a host catalog" do + @catalog.host_config.should be_nil + end - it "should pass supplied tags on to the transaction" do - @transaction.expects(:tags=).with(%w{one two}) - @catalog.apply(:tags => %w{one two}) - end + it "should pass supplied tags on to the transaction" do + @transaction.expects(:tags=).with(%w{one two}) + @catalog.apply(:tags => %w{one two}) + end - it "should set ignoreschedules on the transaction if specified in apply()" do - @transaction.expects(:ignoreschedules=).with(true) - @catalog.apply(:ignoreschedules => true) + it "should set ignoreschedules on the transaction if specified in apply()" do + @transaction.expects(:ignoreschedules=).with(true) + @catalog.apply(:ignoreschedules => true) + end end -end -describe Puppet::Node::Catalog, " when applying host catalogs" do - include ApplyingCatalogs + describe Puppet::Node::Catalog, " when applying host catalogs" do - # super() doesn't work in the setup method for some reason - before do - @catalog.host_config = true - end + # super() doesn't work in the setup method for some reason + before do + @catalog.host_config = true + end - it "should send a report if reporting is enabled" do - Puppet[:report] = true - @transaction.expects :send_report - @transaction.stubs :any_failed? => false - @catalog.apply - end + it "should send a report if reporting is enabled" do + Puppet[:report] = true + @transaction.expects :send_report + @transaction.stubs :any_failed? => false + @catalog.apply + end - it "should send a report if report summaries are enabled" do - Puppet[:summarize] = true - @transaction.expects :send_report - @transaction.stubs :any_failed? => false - @catalog.apply - end + it "should send a report if report summaries are enabled" do + Puppet[:summarize] = true + @transaction.expects :send_report + @transaction.stubs :any_failed? => false + @catalog.apply + end - it "should initialize the state database before applying a catalog" do - Puppet::Util::Storage.expects(:load) + it "should initialize the state database before applying a catalog" do + Puppet::Util::Storage.expects(:load) - # Short-circuit the apply, so we know we're loading before the transaction - Puppet::Transaction.expects(:new).raises ArgumentError - proc { @catalog.apply }.should raise_error(ArgumentError) - end + # Short-circuit the apply, so we know we're loading before the transaction + Puppet::Transaction.expects(:new).raises ArgumentError + proc { @catalog.apply }.should raise_error(ArgumentError) + end - it "should sync the state database after applying" do - Puppet::Util::Storage.expects(:store) - @transaction.stubs :any_failed? => false - @catalog.apply - end + it "should sync the state database after applying" do + Puppet::Util::Storage.expects(:store) + @transaction.stubs :any_failed? => false + @catalog.apply + end - after { Puppet.settings.clear } -end + after { Puppet.settings.clear } + end -describe Puppet::Node::Catalog, " when applying non-host catalogs" do - include ApplyingCatalogs + describe Puppet::Node::Catalog, " when applying non-host catalogs" do - before do - @catalog.host_config = false - end + before do + @catalog.host_config = false + end - it "should never send reports" do - Puppet[:report] = true - Puppet[:summarize] = true - @transaction.expects(:send_report).never - @catalog.apply - end + it "should never send reports" do + Puppet[:report] = true + Puppet[:summarize] = true + @transaction.expects(:send_report).never + @catalog.apply + end - it "should never modify the state database" do - Puppet::Util::Storage.expects(:load).never - Puppet::Util::Storage.expects(:store).never - @catalog.apply - end + it "should never modify the state database" do + Puppet::Util::Storage.expects(:load).never + Puppet::Util::Storage.expects(:store).never + @catalog.apply + end - after { Puppet.settings.clear } + after { Puppet.settings.clear } + end end describe Puppet::Node::Catalog, " when creating a relationship graph" do |