summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/puppet/file_serving/content.rb4
-rwxr-xr-xspec/unit/file_serving/content.rb28
2 files changed, 31 insertions, 1 deletions
diff --git a/lib/puppet/file_serving/content.rb b/lib/puppet/file_serving/content.rb
index b30070dd6..0f169c28b 100644
--- a/lib/puppet/file_serving/content.rb
+++ b/lib/puppet/file_serving/content.rb
@@ -14,12 +14,14 @@ class Puppet::FileServing::Content < Puppet::FileServing::Base
extend Puppet::Indirector
indirects :file_content, :extend => Puppet::FileServing::IndirectionHooks
+ attr_writer :content
+
def self.supported_formats
[:raw]
end
def self.from_raw(content)
- instance = new("eh")
+ instance = new("/this/is/a/fake/path")
instance.content = content
instance
end
diff --git a/spec/unit/file_serving/content.rb b/spec/unit/file_serving/content.rb
index 5441dff53..e471c3b29 100755
--- a/spec/unit/file_serving/content.rb
+++ b/spec/unit/file_serving/content.rb
@@ -17,6 +17,10 @@ describe Puppet::FileServing::Content do
Puppet::FileServing::Content.indirection.metaclass.included_modules.should include(Puppet::FileServing::IndirectionHooks)
end
+ it "should only support the raw format" do
+ Puppet::FileServing::Content.supported_formats.should == [:raw]
+ end
+
it "should have a method for collecting its attributes" do
Puppet::FileServing::Content.new("/path").should respond_to(:collect)
end
@@ -31,6 +35,30 @@ describe Puppet::FileServing::Content do
content.instance_variable_get("@content").should_not be_nil
end
+
+ it "should have a method for setting its content" do
+ content = Puppet::FileServing::Content.new("/path")
+ content.should respond_to(:content=)
+ end
+
+ it "should make content available when set externally" do
+ content = Puppet::FileServing::Content.new("/path")
+ content.content = "foo/bar"
+ content.content.should == "foo/bar"
+ end
+
+ it "should be able to create a content instance from raw file contents" do
+ Puppet::FileServing::Content.should respond_to(:from_raw)
+ end
+
+ it "should create an instance with a fake file name and correct content when converting from raw" do
+ instance = mock 'instance'
+ Puppet::FileServing::Content.expects(:new).with("/this/is/a/fake/path").returns instance
+
+ instance.expects(:content=).with "foo/bar"
+
+ Puppet::FileServing::Content.from_raw("foo/bar").should equal(instance)
+ end
end
describe Puppet::FileServing::Content, "when returning the contents" do