From 14f8160674628340ccfd79baeb84f66cf1e0398a Mon Sep 17 00:00:00 2001 From: Paul Berry Date: Mon, 29 Nov 2010 11:55:00 -0800 Subject: Maint: Refactor tests to use .indirection. Replaced uses of the find, search, destroy, and expire methods on model classes with direct calls to the indirection objects. This change affects tests only. --- spec/unit/application/queue_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'spec/unit/application/queue_spec.rb') diff --git a/spec/unit/application/queue_spec.rb b/spec/unit/application/queue_spec.rb index bd0d53ab1..18fd8cea2 100755 --- a/spec/unit/application/queue_spec.rb +++ b/spec/unit/application/queue_spec.rb @@ -13,7 +13,7 @@ describe Puppet::Application::Queue do Puppet::Util::Log.stubs(:newdestination) Puppet::Util::Log.stubs(:level=) - Puppet::Resource::Catalog.stubs(:terminus_class=) + Puppet::Resource::Catalog.indirection.stubs(:terminus_class=) end it "should ask Puppet::Application to parse Puppet configuration file" do @@ -80,7 +80,7 @@ describe Puppet::Application::Queue do @queue.daemon.stubs(:daemonize) Puppet.stubs(:info) Puppet.features.stubs(:stomp?).returns true - Puppet::Resource::Catalog.stubs(:terminus_class=) + Puppet::Resource::Catalog.indirection.stubs(:terminus_class=) Puppet.stubs(:settraps) Puppet.settings.stubs(:print_config?) Puppet.settings.stubs(:print_config) @@ -144,7 +144,7 @@ describe Puppet::Application::Queue do end it "should configure the Catalog class to use ActiveRecord" do - Puppet::Resource::Catalog.expects(:terminus_class=).with(:active_record) + Puppet::Resource::Catalog.indirection.expects(:terminus_class=).with(:active_record) @queue.setup end -- cgit From f77764de3ace7cc880a77466618a5affe1b61a8e Mon Sep 17 00:00:00 2001 From: Paul Berry Date: Tue, 30 Nov 2010 12:06:33 -0800 Subject: Maint: Modified tests of indirector.save to call the indirection directly. This change replaces calls to .save with calls to .indirection.save(). This makes the use of the indirector explicit rather than implicit so that it will be easier to search for all indirector call sites using grep. This is an intermediate refactor on the way towards allowing indirector calls to be explicitly routed to multiple termini. This patch affects tests only; the next patch will make the corresponding change to the code. --- spec/unit/application/queue_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'spec/unit/application/queue_spec.rb') diff --git a/spec/unit/application/queue_spec.rb b/spec/unit/application/queue_spec.rb index 18fd8cea2..619f94e45 100755 --- a/spec/unit/application/queue_spec.rb +++ b/spec/unit/application/queue_spec.rb @@ -171,8 +171,8 @@ describe Puppet::Application::Queue do end it "should log and save each catalog passed by the queue" do - catalog = mock 'catalog', :name => 'eh' - catalog.expects(:save) + catalog = Puppet::Resource::Catalog.new('eh') + Puppet::Resource::Catalog.indirection.expects(:save).with(catalog, nil) Puppet::Resource::Catalog::Queue.expects(:subscribe).yields(catalog) Puppet.expects(:notice).times(2) -- cgit From 0747b58bfef9c6bb5f1f9ac1eb6a7b3955dac2af Mon Sep 17 00:00:00 2001 From: Paul Berry Date: Tue, 30 Nov 2010 12:06:52 -0800 Subject: Maint: Modified uses of indirector.save to call the indirection directly. This change replaces calls to .save with calls to .indirection.save(). This makes the use of the indirector explicit rather than implicit so that it will be easier to search for all indirector call sites using grep. This is an intermediate refactor on the way towards allowing indirector calls to be explicitly routed to multiple termini. This patch affects production code. --- spec/unit/application/queue_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/unit/application/queue_spec.rb') diff --git a/spec/unit/application/queue_spec.rb b/spec/unit/application/queue_spec.rb index 619f94e45..1c65b558c 100755 --- a/spec/unit/application/queue_spec.rb +++ b/spec/unit/application/queue_spec.rb @@ -172,7 +172,7 @@ describe Puppet::Application::Queue do it "should log and save each catalog passed by the queue" do catalog = Puppet::Resource::Catalog.new('eh') - Puppet::Resource::Catalog.indirection.expects(:save).with(catalog, nil) + Puppet::Resource::Catalog.indirection.expects(:save).with(catalog) Puppet::Resource::Catalog::Queue.expects(:subscribe).yields(catalog) Puppet.expects(:notice).times(2) -- cgit From 626d7564467bdc0e9d2d385e9aa10c539d9ed175 Mon Sep 17 00:00:00 2001 From: Matt Robinson Date: Mon, 6 Dec 2010 12:01:18 -0800 Subject: maint: Use expand_path when requiring spec_helper or puppettest Doing a require to a relative path can cause files to be required more than once when they're required from different relative paths. If you expand the path fully, this won't happen. Ruby 1.9 also requires that you use expand_path when doing these requires. Paired-with: Jesse Wolfe --- spec/unit/application/queue_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/unit/application/queue_spec.rb') diff --git a/spec/unit/application/queue_spec.rb b/spec/unit/application/queue_spec.rb index 1c65b558c..2ff9001af 100755 --- a/spec/unit/application/queue_spec.rb +++ b/spec/unit/application/queue_spec.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require 'puppet/application/queue' require 'puppet/indirector/catalog/queue' -- cgit