diff options
| author | Luke Kanies <luke@madstop.com> | 2008-07-30 22:19:01 -0500 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2008-07-30 22:19:01 -0500 |
| commit | 29d704c3f7d69f04e27aae69f4c1ef9dfc979972 (patch) | |
| tree | 0e2dacf7c12cd6844277f14ea8153d9d52d5143d /spec | |
| parent | c55acee2264b126541ea26d49e1994b263568548 (diff) | |
The REST formats are now fully functional, with yaml and marshal support.
This is the last of the REST plumbing. The only flaw right now
is that the formats are managed by name rather than by
mimetype, which I'll fix next.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec')
| -rwxr-xr-x | spec/unit/network/formats.rb | 67 |
1 files changed, 66 insertions, 1 deletions
diff --git a/spec/unit/network/formats.rb b/spec/unit/network/formats.rb index 94104289d..a7d74e95c 100755 --- a/spec/unit/network/formats.rb +++ b/spec/unit/network/formats.rb @@ -10,8 +10,40 @@ describe "Puppet Network Format" do end describe "yaml" do + before do + @yaml = Puppet::Network::FormatHandler.format(:yaml) + end + it "should have its mime type set to text/yaml" do - Puppet::Network::FormatHandler.format(:yaml).mime.should == "text/yaml" + @yaml.mime.should == "text/yaml" + end + + it "should be supported on Strings" do + @yaml.should be_supported(String) + end + + it "should render by calling 'to_yaml' on the instance" do + instance = mock 'instance' + instance.expects(:to_yaml).returns "foo" + @yaml.render(instance).should == "foo" + end + + it "should render multiple instances by calling 'to_yaml' on the array" do + instances = [mock('instance')] + instances.expects(:to_yaml).returns "foo" + @yaml.render_multiple(instances).should == "foo" + end + + it "should intern by calling 'YAML.load'" do + text = "foo" + YAML.expects(:load).with("foo").returns "bar" + @yaml.intern(String, text).should == "bar" + end + + it "should intern multiples by calling 'YAML.load'" do + text = "foo" + YAML.expects(:load).with("foo").returns "bar" + @yaml.intern_multiple(String, text).should == "bar" end end @@ -20,8 +52,41 @@ describe "Puppet Network Format" do end describe "marshal" do + before do + @marshal = Puppet::Network::FormatHandler.format(:marshal) + end + it "should have its mime type set to text/marshal" do Puppet::Network::FormatHandler.format(:marshal).mime.should == "text/marshal" end + + it "should be supported on Strings" do + @marshal.should be_supported(String) + end + + it "should render by calling 'Marshal.dump' on the instance" do + instance = mock 'instance' + Marshal.expects(:dump).with(instance).returns "foo" + @marshal.render(instance).should == "foo" + end + + it "should render multiple instances by calling 'to_marshal' on the array" do + instances = [mock('instance')] + + Marshal.expects(:dump).with(instances).returns "foo" + @marshal.render_multiple(instances).should == "foo" + end + + it "should intern by calling 'Marshal.load'" do + text = "foo" + Marshal.expects(:load).with("foo").returns "bar" + @marshal.intern(String, text).should == "bar" + end + + it "should intern multiples by calling 'Marshal.load'" do + text = "foo" + Marshal.expects(:load).with("foo").returns "bar" + @marshal.intern_multiple(String, text).should == "bar" + end end end |
