diff options
Diffstat (limited to 'spec/unit')
| -rwxr-xr-x | spec/unit/network/format.rb | 12 | ||||
| -rwxr-xr-x | spec/unit/network/format_handler.rb | 31 | ||||
| -rwxr-xr-x | spec/unit/network/formats.rb | 4 |
3 files changed, 38 insertions, 9 deletions
diff --git a/spec/unit/network/format.rb b/spec/unit/network/format.rb index 818ecdce3..244bff306 100755 --- a/spec/unit/network/format.rb +++ b/spec/unit/network/format.rb @@ -83,6 +83,18 @@ describe Puppet::Network::Format do @format.mime = "Foo/Bar" @format.mime.should == "foo/bar" end + + it "should support having a weight" do + @format.should respond_to(:weight) + end + + it "should default to a weight of of 5" do + @format.weight.should == 5 + end + + it "should be able to override its weight at initialization" do + Puppet::Network::Format.new(:foo, :weight => 1).weight.should == 1 + end end describe "when converting between instances and formatted text" do diff --git a/spec/unit/network/format_handler.rb b/spec/unit/network/format_handler.rb index 35e996516..3dcff6199 100755 --- a/spec/unit/network/format_handler.rb +++ b/spec/unit/network/format_handler.rb @@ -21,18 +21,31 @@ describe Puppet::Network::FormatHandler do end it "should include all supported formats" do - one = stub 'supported', :supported? => true, :name => "one" - two = stub 'supported', :supported? => false, :name => "two" - three = stub 'supported', :supported? => true, :name => "three" - four = stub 'supported', :supported? => false, :name => "four" - Puppet::Network::FormatHandler.expects(:formats).returns %w{one two three four} - Puppet::Network::FormatHandler.expects(:format).with("one").returns one - Puppet::Network::FormatHandler.expects(:format).with("two").returns two - Puppet::Network::FormatHandler.expects(:format).with("three").returns three - Puppet::Network::FormatHandler.expects(:format).with("four").returns four + one = stub 'supported', :supported? => true, :name => "one", :weight => 1 + two = stub 'supported', :supported? => false, :name => "two", :weight => 1 + three = stub 'supported', :supported? => true, :name => "three", :weight => 1 + four = stub 'supported', :supported? => false, :name => "four", :weight => 1 + Puppet::Network::FormatHandler.stubs(:formats).returns %w{one two three four} + Puppet::Network::FormatHandler.stubs(:format).with("one").returns one + Puppet::Network::FormatHandler.stubs(:format).with("two").returns two + Puppet::Network::FormatHandler.stubs(:format).with("three").returns three + Puppet::Network::FormatHandler.stubs(:format).with("four").returns four FormatTester.supported_formats.sort.should == %w{one three}.sort end + it "should return the supported formats in decreasing order of weight" do + one = stub 'supported', :supported? => true, :name => "one", :weight => 1 + two = stub 'supported', :supported? => true, :name => "two", :weight => 6 + three = stub 'supported', :supported? => true, :name => "three", :weight => 2 + four = stub 'supported', :supported? => true, :name => "four", :weight => 8 + Puppet::Network::FormatHandler.stubs(:formats).returns %w{one two three four} + Puppet::Network::FormatHandler.stubs(:format).with("one").returns one + Puppet::Network::FormatHandler.stubs(:format).with("two").returns two + Puppet::Network::FormatHandler.stubs(:format).with("three").returns three + Puppet::Network::FormatHandler.stubs(:format).with("four").returns four + FormatTester.supported_formats.should == %w{four two three one} + end + it "should return the first format as the default format" do FormatTester.expects(:supported_formats).returns %w{one two} FormatTester.default_format.should == "one" diff --git a/spec/unit/network/formats.rb b/spec/unit/network/formats.rb index 527fd9d79..0e21fefa7 100755 --- a/spec/unit/network/formats.rb +++ b/spec/unit/network/formats.rb @@ -124,5 +124,9 @@ describe "Puppet Network Format" do it "should fail if its multiple_intern method is used" do lambda { @format.intern_multiple(String, "foo") }.should raise_error(NotImplementedError) end + + it "should have a weight of 1" do + @format.weight.should == 1 + end end end |
