summaryrefslogtreecommitdiffstats
path: root/spec/unit/network/format.rb
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-07-28 18:50:24 -0500
committerLuke Kanies <luke@madstop.com>2008-07-29 00:51:22 -0500
commit352e2d0fb74fd7226ecac06b6108e672c221baa1 (patch)
tree859bc5a7b73af3ac3e22a16dac68877636bd72df /spec/unit/network/format.rb
parent55e29444c15fe2f810b3d5332605f27ac5942fda (diff)
downloadpuppet-352e2d0fb74fd7226ecac06b6108e672c221baa1.tar.gz
puppet-352e2d0fb74fd7226ecac06b6108e672c221baa1.tar.xz
puppet-352e2d0fb74fd7226ecac06b6108e672c221baa1.zip
Adding rudimentary support for directly managing formats.
We have a simple Format class, and the FormatHandler module is responsible for managing its instances, including providing access by mime type or name. It will soon replace some of the testing functionality in the FormatHandler module, but for now, it's just there as a name => mimetype converter, which makes it seem a lot like overkill. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec/unit/network/format.rb')
-rwxr-xr-xspec/unit/network/format.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/unit/network/format.rb b/spec/unit/network/format.rb
new file mode 100755
index 000000000..78e677e9b
--- /dev/null
+++ b/spec/unit/network/format.rb
@@ -0,0 +1,38 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+require 'puppet/network/format'
+
+describe Puppet::Network::Format do
+ it "should require a name" do
+ lambda { Puppet::Network::Format.new }.should raise_error(ArgumentError)
+ end
+
+ it "should be able to provide its name" do
+ Puppet::Network::Format.new(:my_format).name.should == :my_format
+ end
+
+ it "should be able to set its mime type at initialization" do
+ format = Puppet::Network::Format.new(:my_format, :mime => "foo/bar")
+ format.mime.should == "foo/bar"
+ end
+
+ it "should default to text plus the name of the format as the mime type" do
+ Puppet::Network::Format.new(:my_format).mime.should == "text/my_format"
+ end
+
+ it "should fail if unsupported options are provided" do
+ lambda { Puppet::Network::Format.new(:my_format, :foo => "bar") }.should raise_error(ArgumentError)
+ end
+
+ it "should support being confined" do
+ Puppet::Network::Format.new(:my_format).should respond_to(:confine)
+ end
+
+ it "should not be considered suitable if confinement conditions are not met" do
+ format = Puppet::Network::Format.new(:my_format)
+ format.confine :true => false
+ format.should_not be_suitable
+ end
+end