summaryrefslogtreecommitdiffstats
path: root/spec/unit
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-02-17 17:16:20 -0600
committerLuke Kanies <luke@madstop.com>2009-02-18 22:38:44 -0600
commit458642b8660c8f0507b1f66b67bade5c60efe64a (patch)
treebd85a12540ad0711f31767406d7b8ff710f152e6 /spec/unit
parenteec1caddf0dc431229ceb1741b357a9fefce5c38 (diff)
downloadpuppet-458642b8660c8f0507b1f66b67bade5c60efe64a.tar.gz
puppet-458642b8660c8f0507b1f66b67bade5c60efe64a.tar.xz
puppet-458642b8660c8f0507b1f66b67bade5c60efe64a.zip
Supporting multiple paths for searching for files.
This is, once again, used for plugins, which needs to search across multiple modules' plugin directories. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec/unit')
-rwxr-xr-xspec/unit/file_serving/terminus_helper.rb40
1 files changed, 22 insertions, 18 deletions
diff --git a/spec/unit/file_serving/terminus_helper.rb b/spec/unit/file_serving/terminus_helper.rb
index 7f08aeb7e..c79261eca 100755
--- a/spec/unit/file_serving/terminus_helper.rb
+++ b/spec/unit/file_serving/terminus_helper.rb
@@ -16,38 +16,48 @@ describe Puppet::FileServing::TerminusHelper do
@helper.stubs(:model).returns(@model)
@request = stub 'request', :key => "url", :options => {}
+
+ @fileset = stub 'fileset', :files => [], :path => "/my/file"
+ Puppet::FileServing::Fileset.stubs(:new).with("/my/file", {}).returns(@fileset)
end
it "should use a fileset to find paths" do
- fileset = mock 'fileset', :files => []
- Puppet::FileServing::Fileset.expects(:new).with("/my/file", {}).returns(fileset)
+ @fileset = stub 'fileset', :files => [], :path => "/my/files"
+ Puppet::FileServing::Fileset.expects(:new).with("/my/file", {}).returns(@fileset)
@helper.path2instances(@request, "/my/file")
end
+ it "should support finding across multiple paths by merging the filesets" do
+ first = stub 'fileset', :files => [], :path => "/first/file"
+ Puppet::FileServing::Fileset.expects(:new).with { |path, options| path == "/first/file" }.returns(first)
+ second = stub 'fileset', :files => [], :path => "/second/file"
+ Puppet::FileServing::Fileset.expects(:new).with { |path, options| path == "/second/file" }.returns(second)
+
+ Puppet::FileServing::Fileset.expects(:merge).with(first, second).returns({})
+
+ @helper.path2instances(@request, "/first/file", "/second/file")
+ end
+
it "should pass :recurse, :ignore, and :links settings on to the fileset if present" do
- fileset = mock 'fileset', :files => []
- Puppet::FileServing::Fileset.expects(:new).with("/my/file", :links => :a, :ignore => :b, :recurse => :c).returns(fileset)
+ 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
- fileset = mock 'fileset', :files => []
- Puppet::FileServing::Fileset.expects(:new).with("/my/file", :links => :a, :ignore => :b, :recurse => :c).returns(fileset)
+ 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
- fileset = mock 'fileset', :files => []
- Puppet::FileServing::Fileset.expects(:new).with("/my/file", :recurse => true).returns(fileset)
+ 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
- fileset = mock 'fileset', :files => []
- Puppet::FileServing::Fileset.expects(:new).with("/my/file", :recurse => false).returns(fileset)
+ Puppet::FileServing::Fileset.expects(:new).with { |path, options| options[:recurse] == false }.returns(@fileset)
@request.stubs(:options).returns(:recurse => "false")
@helper.path2instances(@request, "/my/file")
end
@@ -59,14 +69,8 @@ describe Puppet::FileServing::TerminusHelper do
@one = stub 'one', :links= => nil, :collect => nil
@two = stub 'two', :links= => nil, :collect => nil
- @fileset = mock 'fileset', :files => %w{one two}
- Puppet::FileServing::Fileset.expects(:new).returns(@fileset)
- end
-
- it "should create an instance of the model for each path returned by the fileset" do
- @model.expects(:new).returns(@one)
- @model.expects(:new).returns(@two)
- @helper.path2instances(@request, "/my/file").length.should == 2
+ @fileset = stub 'fileset', :files => %w{one two}, :path => "/my/file"
+ Puppet::FileServing::Fileset.stubs(:new).returns(@fileset)
end
it "should set each returned instance's path to the original path" do