summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-08-25 17:43:35 -0500
committerLuke Kanies <luke@madstop.com>2008-08-26 22:40:41 -0700
commit6ed8dfaf7c0cf091dca0374de310f524b0a033cc (patch)
tree77c97024fe929c61d6efdf2b707b365c111b079c
parent92e144b3051ebd177c034e692a59162b3902e128 (diff)
downloadpuppet-6ed8dfaf7c0cf091dca0374de310f524b0a033cc.tar.gz
puppet-6ed8dfaf7c0cf091dca0374de310f524b0a033cc.tar.xz
puppet-6ed8dfaf7c0cf091dca0374de310f524b0a033cc.zip
Adding the content writer to the content class.
Also choosing a fully qualified fake name when creating content instances from raw content. Signed-off-by: Luke Kanies <luke@madstop.com>
-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