summaryrefslogtreecommitdiffstats
path: root/spec/shared_behaviours
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-04-08 18:21:18 -0500
committerLuke Kanies <luke@madstop.com>2008-04-08 18:21:18 -0500
commitbf728d23caca4f58ae4ede1a2d477c9fc15e0bdc (patch)
treed79ae6e23667f0a1b201537914a025c9f677aa74 /spec/shared_behaviours
parent644d6baae132a097170631f90521e878e31a5a0a (diff)
Intermediate commit.
This commit adds a Request instance into the indirection, pushing it all the way to the terminus instances. It's a big commit because it requires modifying every terminus class. There are still some thorny design issues. In particular, who should be responsible for making the request object? I've tried having both the indirection class and the Indirector module creating it, and both have their issues. Also, the Catalog class previously allowed passing Node instances directly to the find method, which is now no longer possible because the Request class would treat the node as the instance being found. We need the request class to have two modes, one when it's passed an instance and one when it's passed a key.
Diffstat (limited to 'spec/shared_behaviours')
-rw-r--r--spec/shared_behaviours/file_serving.rb12
-rw-r--r--spec/shared_behaviours/memory_terminus.rb32
2 files changed, 38 insertions, 6 deletions
diff --git a/spec/shared_behaviours/file_serving.rb b/spec/shared_behaviours/file_serving.rb
index b5ab6b0fd..82f207243 100644
--- a/spec/shared_behaviours/file_serving.rb
+++ b/spec/shared_behaviours/file_serving.rb
@@ -6,7 +6,7 @@
describe "Puppet::FileServing::Files", :shared => true do
it "should use the rest terminus when the 'puppet' URI scheme is used and a host name is present" do
uri = "puppet://myhost/mymod/my/file"
- @indirection.terminus(:rest).expects(:find).with(uri)
+ @indirection.terminus(:rest).expects(:find)
@test_class.find(uri)
end
@@ -14,7 +14,7 @@ describe "Puppet::FileServing::Files", :shared => true do
uri = "puppet:///mymod/my/file"
Puppet.settings.stubs(:value).with(:name).returns("puppetd")
Puppet.settings.stubs(:value).with(:modulepath).returns("")
- @indirection.terminus(:rest).expects(:find).with(uri)
+ @indirection.terminus(:rest).expects(:find)
@test_class.find(uri)
end
@@ -27,27 +27,27 @@ describe "Puppet::FileServing::Files", :shared => true do
Puppet.settings.stubs(:value).with(:libdir).returns("")
Puppet.settings.stubs(:value).with(:fileserverconfig).returns("/whatever")
Puppet.settings.stubs(:value).with(:environment).returns("")
- @indirection.terminus(:file_server).expects(:find).with(uri)
+ @indirection.terminus(:file_server).expects(:find)
@indirection.terminus(:file_server).stubs(:authorized?).returns(true)
@test_class.find(uri)
end
it "should use the file_server terminus when the 'puppetmounts' URI scheme is used" do
uri = "puppetmounts:///mymod/my/file"
- @indirection.terminus(:file_server).expects(:find).with(uri)
+ @indirection.terminus(:file_server).expects(:find)
@indirection.terminus(:file_server).stubs(:authorized?).returns(true)
@test_class.find(uri)
end
it "should use the file terminus when the 'file' URI scheme is used" do
uri = "file:///mymod/my/file"
- @indirection.terminus(:file).expects(:find).with(uri)
+ @indirection.terminus(:file).expects(:find)
@test_class.find(uri)
end
it "should use the file terminus when a fully qualified path is provided" do
uri = "/mymod/my/file"
- @indirection.terminus(:file).expects(:find).with(uri)
+ @indirection.terminus(:file).expects(:find)
@test_class.find(uri)
end
end
diff --git a/spec/shared_behaviours/memory_terminus.rb b/spec/shared_behaviours/memory_terminus.rb
new file mode 100644
index 000000000..a00dc9f74
--- /dev/null
+++ b/spec/shared_behaviours/memory_terminus.rb
@@ -0,0 +1,32 @@
+#
+# Created by Luke Kanies on 2008-4-8.
+# Copyright (c) 2008. All rights reserved.
+
+describe "A Memory Terminus", :shared => true do
+ it "should find no instances by default" do
+ @searcher.find(@request).should be_nil
+ end
+
+ it "should be able to find instances that were previously saved" do
+ @searcher.save(@request)
+ @searcher.find(@request).should equal(@instance)
+ end
+
+ it "should replace existing saved instances when a new instance with the same name is saved" do
+ @searcher.save(@request)
+ two = stub 'second', :name => @name
+ trequest = stub 'request', :key => @name, :instance => two
+ @searcher.save(trequest)
+ @searcher.find(@request).should equal(two)
+ end
+
+ it "should be able to remove previously saved instances" do
+ @searcher.save(@request)
+ @searcher.destroy(@request)
+ @searcher.find(@request).should be_nil
+ end
+
+ it "should fail when asked to destroy an instance that does not exist" do
+ proc { @searcher.destroy(@request) }.should raise_error(ArgumentError)
+ end
+end