summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRick Bradley <rick@rickbradley.com>2007-09-19 23:13:30 -0500
committerRick Bradley <rick@rickbradley.com>2007-09-19 23:13:30 -0500
commit129cce8b63c827d16a49c5ff1f6f25daf2906f47 (patch)
treeda0ce09830ca1d7a5bf826a4e64a64035f929080
parenta6c4041a201dd8984cec89a96a194e96479f6657 (diff)
downloadpuppet-129cce8b63c827d16a49c5ff1f6f25daf2906f47.tar.gz
puppet-129cce8b63c827d16a49c5ff1f6f25daf2906f47.tar.xz
puppet-129cce8b63c827d16a49c5ff1f6f25daf2906f47.zip
Finally, some progress. Closing the loops and delegating registered class calls out to the actual Terminus.
-rwxr-xr-xspec/unit/indirector/indirector.rb47
1 files changed, 38 insertions, 9 deletions
diff --git a/spec/unit/indirector/indirector.rb b/spec/unit/indirector/indirector.rb
index 3a51fedf2..a44ef8814 100755
--- a/spec/unit/indirector/indirector.rb
+++ b/spec/unit/indirector/indirector.rb
@@ -73,9 +73,11 @@ describe Puppet::Indirector, "when registering an indirection" do
end
it "should make available the indirection used for a registered class" do
+ mock_terminus = mock('Terminus')
+ Puppet::Indirector.expects(:terminus_for_indirection).with(:node).returns(:ldap)
+ Puppet::Indirector.expects(:terminus).returns(mock_terminus)
@thingie.send(:indirects, :node)
- @thingie.indirection.indirection.should == :node
- @thingie.indirection.name.should == :ldap
+ @thingie.indirection.should == mock_terminus
end
it "should make a save method available on instances of the registered class" do
@@ -98,16 +100,43 @@ describe Puppet::Indirector, "when registering an indirection" do
end
it "should use the Terminus described in the class configuration" do
- Puppet::Indirector.expects(:terminus_for_indirection).with(:node).returns(:ldap)
+ mock_terminus = mock('Terminus')
+ Puppet::Indirector.expects(:terminus_for_indirection).with(:foo).returns(:bar)
+ Puppet::Indirector.expects(:terminus).with(:foo, :bar).returns(mock_terminus)
+ @thingie.send(:indirects, :foo)
+ end
+
+ it "should delegate to the Terminus find method when calling find on the registered class" do
+ @thingie.send(:indirects, :node)
+ mock_terminus = mock('Terminus')
+ mock_terminus.expects(:find)
+ @thingie.expects(:indirection).returns(mock_terminus)
+ @thingie.find
+ end
+
+ it "should delegate to the Terminus destroy method when calling destroy on the registered class" do
+ @thingie.send(:indirects, :node)
+ mock_terminus = mock('Terminus')
+ mock_terminus.expects(:destroy)
+ @thingie.expects(:indirection).returns(mock_terminus)
+ @thingie.destroy
+ end
+
+ it "should delegate to the Terminus search method when calling search on the registered class" do
@thingie.send(:indirects, :node)
- @thingie.indirection.indirection.should == :node
- @thingie.indirection.name.should == :ldap
+ mock_terminus = mock('Terminus')
+ mock_terminus.expects(:search)
+ @thingie.expects(:indirection).returns(mock_terminus)
+ @thingie.search
end
- it "should use the Terminus find method when calling find on the registered class"
- it "should use the Terminus save method when calling save on the registered class"
- it "should use the Terminus destroy method when calling destroy on the registered class"
- it "should use the Terminus search method when calling search on the registered class"
+ it "should delegate to the Terminus save method when calling save on the registered class" do
+ @thingie.send(:indirects, :node)
+ mock_terminus = mock('Terminus')
+ mock_terminus.expects(:save)
+ @thingie.expects(:indirection).returns(mock_terminus)
+ @thingie.new.save
+ end
it "should allow a registered class to specify variations in behavior for a given Terminus"
end