summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-10-04 17:07:47 -0500
committerLuke Kanies <luke@madstop.com>2007-10-04 17:07:47 -0500
commit1fa591287a4ab921cec628aa0c5bf58d61fbdef2 (patch)
treef6321fde5b3256b6d0752b91af971d08bdc0ed7f
parent95b2b93290f619c20a1c2dca11dd9909477857f8 (diff)
downloadpuppet-1fa591287a4ab921cec628aa0c5bf58d61fbdef2.tar.gz
puppet-1fa591287a4ab921cec628aa0c5bf58d61fbdef2.tar.xz
puppet-1fa591287a4ab921cec628aa0c5bf58d61fbdef2.zip
Adding the integration tests to the Rakefile for spec,
fixing the integration tests, and extending the Classmethods for the indirector so that indirected classes can set the terminus class and cache class.
-rw-r--r--lib/puppet/indirector.rb8
-rw-r--r--spec/Rakefile2
-rwxr-xr-xspec/integration/checksum.rb3
-rwxr-xr-xspec/integration/node.rb2
-rwxr-xr-xspec/unit/indirector/indirector.rb74
5 files changed, 52 insertions, 37 deletions
diff --git a/lib/puppet/indirector.rb b/lib/puppet/indirector.rb
index 6ff2de1b4..7821e809c 100644
--- a/lib/puppet/indirector.rb
+++ b/lib/puppet/indirector.rb
@@ -28,6 +28,14 @@ module Puppet::Indirector
module ClassMethods
attr_reader :indirection
+
+ def cache_class=(klass)
+ indirection.cache_class = klass
+ end
+
+ def terminus_class=(klass)
+ indirection.terminus_class = klass
+ end
def find(*args)
indirection.find(*args)
diff --git a/spec/Rakefile b/spec/Rakefile
index bb2a75de5..8b45eff89 100644
--- a/spec/Rakefile
+++ b/spec/Rakefile
@@ -9,7 +9,7 @@ speclibdir = File.join(basedir, "lib")
desc "Run all spec unit tests"
Spec::Rake::SpecTask.new('unit') do |t|
- t.spec_files = FileList['unit/**/*.rb']
+ t.spec_files = FileList['unit/**/*.rb', 'integration/**/*.rb']
t.libs = [puppetlibdir, puppettestlibdir, speclibdir]
end
diff --git a/spec/integration/checksum.rb b/spec/integration/checksum.rb
index f112f7502..cb187c656 100755
--- a/spec/integration/checksum.rb
+++ b/spec/integration/checksum.rb
@@ -9,8 +9,7 @@ require 'puppet/checksum'
describe Puppet::Checksum, " when using the file terminus" do
before do
- Puppet[:checksum_terminus] = "file"
-
+ Puppet::Checksum.terminus_class = :file
@content = "this is some content"
@sum = Puppet::Checksum.new(@content)
diff --git a/spec/integration/node.rb b/spec/integration/node.rb
index 8bc641bae..e4a311998 100755
--- a/spec/integration/node.rb
+++ b/spec/integration/node.rb
@@ -10,8 +10,8 @@ require 'puppet/node'
describe Puppet::Node, " when using the memory terminus" do
before do
@name = "me"
+ Puppet::Node.terminus_class = :memory
@node = Puppet::Node.new(@name)
- Puppet[:node_terminus] = "memory"
end
it "should find no nodes by default" do
diff --git a/spec/unit/indirector/indirector.rb b/spec/unit/indirector/indirector.rb
index 1702bf51f..5c3ddf9d3 100755
--- a/spec/unit/indirector/indirector.rb
+++ b/spec/unit/indirector/indirector.rb
@@ -50,37 +50,45 @@ describe Puppet::Indirector, "when registering an indirection" do
end
describe Puppet::Indirector, " when redirecting a model" do
- before do
- @thingie = Class.new do
- extend Puppet::Indirector
- end
- @mock_terminus = mock('Terminus')
- @indirection = @thingie.send(:indirects, :test)
- @thingie.expects(:indirection).returns(@mock_terminus)
- end
-
- it "should give the model the ability to lookup a model instance by letting the indirection perform the lookup" do
- @mock_terminus.expects(:find)
- @thingie.find
- end
-
- it "should give the model the ability to remove model instances from a terminus by letting the indirection remove the instance" do
- @mock_terminus.expects(:destroy)
- @thingie.destroy
- end
-
- it "should give the model the ability to search for model instances by letting the indirection find the matching instances" do
- @mock_terminus.expects(:search)
- @thingie.search
- end
-
- it "should give the model the ability to store a model instance by letting the indirection store the instance" do
- thing = @thingie.new
- @mock_terminus.expects(:save).with(thing)
- thing.save
- end
-
- after do
- @indirection.delete
- end
+ before do
+ @thingie = Class.new do
+ extend Puppet::Indirector
+ end
+ @indirection = @thingie.send(:indirects, :test)
+ end
+
+ it "should give the model the ability to lookup a model instance by letting the indirection perform the lookup" do
+ @indirection.expects(:find)
+ @thingie.find
+ end
+
+ it "should give the model the ability to remove model instances from a terminus by letting the indirection remove the instance" do
+ @indirection.expects(:destroy)
+ @thingie.destroy
+ end
+
+ it "should give the model the ability to search for model instances by letting the indirection find the matching instances" do
+ @indirection.expects(:search)
+ @thingie.search
+ end
+
+ it "should give the model the ability to store a model instance by letting the indirection store the instance" do
+ thing = @thingie.new
+ @indirection.expects(:save).with(thing)
+ thing.save
+ end
+
+ it "should give the model the ability to set the indirection terminus class" do
+ @indirection.expects(:terminus_class=).with(:myterm)
+ @thingie.terminus_class = :myterm
+ end
+
+ it "should give the model the ability to set the indirection cache class" do
+ @indirection.expects(:cache_class=).with(:mycache)
+ @thingie.cache_class = :mycache
+ end
+
+ after do
+ @indirection.delete
+ end
end