0
@@ -14,65 +14,63 @@ describe Puppet::FileServing::TerminusHelper do
0
@helper.stubs(:model).returns(@model)
0
+ @request = stub 'request', :key => "url", :options => {}
0
it "should use a fileset to find paths" do
0
fileset = mock 'fileset', :files => []
0
Puppet::FileServing::Fileset.expects(:new).with("/my/file", {}).returns(fileset)
0
- @helper.path2instances(
"url", "/my/file")
0
+ @helper.path2instances(
@request, "/my/file")
0
it "should pass :recurse, :ignore, and :links settings on to the fileset if present" do
0
fileset = mock 'fileset', :files => []
0
Puppet::FileServing::Fileset.expects(:new).with("/my/file", :links => :a, :ignore => :b, :recurse => :c).returns(fileset)
0
- @helper.path2instances("url", "/my/file", :links => :a, :ignore => :b, :recurse => :c)
0
-describe Puppet::FileServing::TerminusHelper, " when creating instances" do
0
- @helper.extend(Puppet::FileServing::TerminusHelper)
0
- @helper.stubs(:model).returns(@model)
0
- @key = "puppet://host/mount/dir"
0
- @fileset = mock 'fileset', :files => %w{one two}
0
- Puppet::FileServing::Fileset.expects(:new).returns(@fileset)
0
- it "should create an instance of the model for each path returned by the fileset" do
0
- @model.expects(:new).returns(:one)
0
- @model.expects(:new).returns(:two)
0
- @helper.path2instances(@key, "/my/file").length.should == 2
0
- it "should set each instance's key to be the original key plus the file-specific path" do
0
- @model.expects(:new).with { |key, options| key == @key + "/one" }.returns(:one)
0
- @model.expects(:new).with { |key, options| key == @key + "/two" }.returns(:two)
0
- @helper.path2instances(@key, "/my/file")
0
- it "should set each returned instance's path to the original path" do
0
- @model.expects(:new).with { |key, options| options[:path] == "/my/file" }.returns(:one)
0
- @model.expects(:new).with { |key, options| options[:path] == "/my/file" }.returns(:two)
0
- @helper.path2instances(@key, "/my/file")
0
- it "should set each returned instance's relative path to the file-specific path" do
0
- @model.expects(:new).with { |key, options| options[:relative_path] == "one" }.returns(:one)
0
- @model.expects(:new).with { |key, options| options[:relative_path] == "two" }.returns(:two)
0
- @helper.path2instances(@key, "/my/file")
0
+ @request.stubs(:options).returns(:links => :a, :ignore => :b, :recurse => :c)
0
+ @helper.path2instances(@request, "/my/file")
0
- it "should set the links value on each instance if one is provided" do
0
- one = mock 'one', :links= => :manage
0
- two = mock 'two', :links= => :manage
0
- @model.expects(:new).returns(one)
0
- @model.expects(:new).returns(two)
0
- @helper.path2instances(@key, "/my/file", :links => :manage)
0
+ describe "when creating instances" do
0
+ @request.stubs(:key).returns "puppet://host/mount/dir"
0
+ @fileset = mock 'fileset', :files => %w{one two}
0
+ Puppet::FileServing::Fileset.expects(:new).returns(@fileset)
0
+ it "should create an instance of the model for each path returned by the fileset" do
0
+ @model.expects(:new).returns(:one)
0
+ @model.expects(:new).returns(:two)
0
+ @helper.path2instances(@request, "/my/file").length.should == 2
0
+ it "should set each instance's key to be the original key plus the file-specific path" do
0
+ @model.expects(:new).with { |key, options| key == @request.key + "/one" }.returns(:one)
0
+ @model.expects(:new).with { |key, options| key == @request.key + "/two" }.returns(:two)
0
+ @helper.path2instances(@request, "/my/file")
0
+ it "should set each returned instance's path to the original path" do
0
+ @model.expects(:new).with { |key, options| options[:path] == "/my/file" }.returns(:one)
0
+ @model.expects(:new).with { |key, options| options[:path] == "/my/file" }.returns(:two)
0
+ @helper.path2instances(@request, "/my/file")
0
+ it "should set each returned instance's relative path to the file-specific path" do
0
+ @model.expects(:new).with { |key, options| options[:relative_path] == "one" }.returns(:one)
0
+ @model.expects(:new).with { |key, options| options[:relative_path] == "two" }.returns(:two)
0
+ @helper.path2instances(@request, "/my/file")
0
+ it "should set the links value on each instance if one is provided" do
0
+ one = mock 'one', :links= => :manage
0
+ two = mock 'two', :links= => :manage
0
+ @model.expects(:new).returns(one)
0
+ @model.expects(:new).returns(two)
0
+ @request.options[:links] = :manage
0
+ @helper.path2instances(@request, "/my/file")