summaryrefslogtreecommitdiffstats
path: root/spec/unit
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-02-18 15:27:32 -0600
committerLuke Kanies <luke@madstop.com>2009-02-19 16:22:50 -0600
commit00726bac02211be3c269c23a564bdcc8fdd28c2b (patch)
treee7f9692caebdc12c8661233a17cca2d3a0370e1b /spec/unit
parent058266feebb3be90f6af29d0ff70b22ceeb9b3e7 (diff)
downloadpuppet-00726bac02211be3c269c23a564bdcc8fdd28c2b.tar.gz
puppet-00726bac02211be3c269c23a564bdcc8fdd28c2b.tar.xz
puppet-00726bac02211be3c269c23a564bdcc8fdd28c2b.zip
Moving Request and Fileset integration into Fileset.
It was previously in a helper module, TerminusHelper. I hope to actually remove that module entirely. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec/unit')
-rwxr-xr-xspec/unit/file_serving/fileset.rb36
-rwxr-xr-xspec/unit/file_serving/terminus_helper.rb25
2 files changed, 39 insertions, 22 deletions
diff --git a/spec/unit/file_serving/fileset.rb b/spec/unit/file_serving/fileset.rb
index 505875be5..dfba9c1a1 100755
--- a/spec/unit/file_serving/fileset.rb
+++ b/spec/unit/file_serving/fileset.rb
@@ -54,6 +54,42 @@ describe Puppet::FileServing::Fileset, " when initializing" do
File.expects(:lstat).with("/some/file").returns stub("stat")
Puppet::FileServing::Fileset.new("/some/file").links.should == :manage
end
+
+ it "should support using an Indirector Request for its options" do
+ File.expects(:lstat).with("/some/file").returns stub("stat")
+ request = Puppet::Indirector::Request.new(:file_serving, :find, "foo")
+ lambda { Puppet::FileServing::Fileset.new("/some/file", request) }.should_not raise_error
+ end
+
+ describe "using an indirector request" do
+ before do
+ File.stubs(:lstat).returns stub("stat")
+ @values = {:links => :manage, :ignore => %w{a b}, :recurse => true}
+ @request = Puppet::Indirector::Request.new(:file_serving, :find, "foo")
+ end
+
+ [:recurse, :ignore, :links].each do |option|
+ it "should pass :recurse, :ignore, and :links settings on to the fileset if present" do
+ @request.stubs(:options).returns(option => @values[option])
+ Puppet::FileServing::Fileset.new("/my/file", @request).send(option).should == @values[option]
+ end
+
+ it "should pass :recurse, :ignore, and :links settings on to the fileset if present with the keys stored as strings" do
+ @request.stubs(:options).returns(option.to_s => @values[option])
+ Puppet::FileServing::Fileset.new("/my/file", @request).send(option).should == @values[option]
+ end
+ end
+
+ it "should convert the string 'true' to the boolean true when setting options" do
+ @request.stubs(:options).returns(:recurse => "true")
+ Puppet::FileServing::Fileset.new("/my/file", @request).recurse.should == true
+ end
+
+ it "should convert the string 'false' to the boolean false when setting options" do
+ @request.stubs(:options).returns(:recurse => "false")
+ Puppet::FileServing::Fileset.new("/my/file", @request).recurse.should == false
+ end
+ end
end
describe Puppet::FileServing::Fileset, " when determining whether to recurse" do
diff --git a/spec/unit/file_serving/terminus_helper.rb b/spec/unit/file_serving/terminus_helper.rb
index c79261eca..d0c06f126 100755
--- a/spec/unit/file_serving/terminus_helper.rb
+++ b/spec/unit/file_serving/terminus_helper.rb
@@ -23,7 +23,7 @@ describe Puppet::FileServing::TerminusHelper do
it "should use a fileset to find paths" do
@fileset = stub 'fileset', :files => [], :path => "/my/files"
- Puppet::FileServing::Fileset.expects(:new).with("/my/file", {}).returns(@fileset)
+ Puppet::FileServing::Fileset.expects(:new).with { |key, options| key == "/my/file" }.returns(@fileset)
@helper.path2instances(@request, "/my/file")
end
@@ -38,27 +38,8 @@ describe Puppet::FileServing::TerminusHelper do
@helper.path2instances(@request, "/first/file", "/second/file")
end
- it "should pass :recurse, :ignore, and :links settings on to the fileset if present" do
- Puppet::FileServing::Fileset.expects(:new).with { |path, options| options == {:links => :a, :ignore => :b, :recurse => :c } }.returns(@fileset)
- @request.stubs(:options).returns(:links => :a, :ignore => :b, :recurse => :c)
- @helper.path2instances(@request, "/my/file")
- end
-
- it "should pass :recurse, :ignore, and :links settings on to the fileset if present with the keys stored as strings" do
- Puppet::FileServing::Fileset.expects(:new).with { |path, options| options == {:links => :a, :ignore => :b, :recurse => :c} }.returns(@fileset)
- @request.stubs(:options).returns("links" => :a, "ignore" => :b, "recurse" => :c)
- @helper.path2instances(@request, "/my/file")
- end
-
- it "should convert the string 'true' to the boolean true when setting options" do
- Puppet::FileServing::Fileset.expects(:new).with { |path, options| options[:recurse] == true }.returns(@fileset)
- @request.stubs(:options).returns(:recurse => "true")
- @helper.path2instances(@request, "/my/file")
- end
-
- it "should convert the string 'false' to the boolean false when setting options" do
- Puppet::FileServing::Fileset.expects(:new).with { |path, options| options[:recurse] == false }.returns(@fileset)
- @request.stubs(:options).returns(:recurse => "false")
+ it "should pass the indirection request to the Fileset at initialization" do
+ Puppet::FileServing::Fileset.expects(:new).with { |path, options| options == @request }.returns @fileset
@helper.path2instances(@request, "/my/file")
end