diff options
| author | Luke Kanies <luke@madstop.com> | 2008-07-28 18:05:41 -0500 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2008-07-29 00:51:22 -0500 |
| commit | 55e29444c15fe2f810b3d5332605f27ac5942fda (patch) | |
| tree | 5cd663fa5a55920f59f04dd4fa58677078d982b1 /spec/unit | |
| parent | 4632cfd9e6ce0ff59dfa7562a02a1ae3f14488d4 (diff) | |
| download | puppet-55e29444c15fe2f810b3d5332605f27ac5942fda.tar.gz puppet-55e29444c15fe2f810b3d5332605f27ac5942fda.tar.xz puppet-55e29444c15fe2f810b3d5332605f27ac5942fda.zip | |
Adding support for rendering and converting multiple instances.
It's a touch hackish in terms of design, but it should work,
and it's the last major piece of plumbing necessary for REST support.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec/unit')
| -rwxr-xr-x | spec/unit/network/format_handler.rb | 45 |
1 files changed, 36 insertions, 9 deletions
diff --git a/spec/unit/network/format_handler.rb b/spec/unit/network/format_handler.rb index 3e0571eb6..4def67fef 100755 --- a/spec/unit/network/format_handler.rb +++ b/spec/unit/network/format_handler.rb @@ -8,18 +8,24 @@ class FormatTester extend Puppet::Network::FormatHandler # Not a supported format; missing the 'to' - def self.from_nothing - end + def self.from_nothing; end # Not a supported format; missing the 'from' - def to_nowhere - end + def to_nowhere; end - def self.from_good - end + # A largely functional format. + def self.from_good; end - def to_good - end + def to_good; end + + # A format that knows how to handle multiple instances specially. + def self.from_mults; end + + def self.from_multiple_mults; end + + def self.to_multiple_mults; end + + def to_mults; end end describe Puppet::Network::FormatHandler do @@ -53,12 +59,33 @@ describe Puppet::Network::FormatHandler do FormatTester.convert_from(:good, "mydata") end + it "should be able to use a specific hook for converting into multiple instances" do + FormatTester.expects(:from_multiple_mults).with("mydata") + FormatTester.convert_from_multiple(:mults, "mydata") + end + + it "should default to the normal conversion method when no special method is available" do + FormatTester.expects(:from_good).with("mydata") + FormatTester.convert_from_multiple(:good, "mydata") + end + + it "should be able to use a specific hook for rendering multiple instances" do + FormatTester.expects(:to_multiple_mults).with("mydata") + FormatTester.render_multiple(:mults, "mydata") + end + + it "should use the instance method if no multiple-render hook is available" do + instances = mock 'instances' + instances.expects(:to_good) + FormatTester.render_multiple(:good, instances) + end + it "should be able to list supported formats" do FormatTester.should respond_to(:supported_formats) end it "should include all formats that include both the to_ and from_ methods in the list of supported formats" do - FormatTester.supported_formats.should == %w{good} + FormatTester.supported_formats.should == %w{good mults} end it "should return the first format as the default format" do |
