From 5986e8a3747ebb0fe48169f88fecb481be76d16c Mon Sep 17 00:00:00 2001 From: Daniel Pittman Date: Wed, 4 May 2011 10:36:50 -0700 Subject: (#7353) Unify rendering in the face_bace application. We now move over to using only network FormatHandler rendering code for output, ditching all the support we had in the application. We include a compatibility shim to ensure that the :for_humans format that was supported for a while is now an alias for the :console format we are using moving forward. Reviewed-By: Jacob Helwig --- spec/unit/application/face_base_spec.rb | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'spec/unit/application') diff --git a/spec/unit/application/face_base_spec.rb b/spec/unit/application/face_base_spec.rb index 133e6b2e9..25797ea3e 100755 --- a/spec/unit/application/face_base_spec.rb +++ b/spec/unit/application/face_base_spec.rb @@ -246,14 +246,14 @@ describe Puppet::Application::FaceBase do end [[1, 2], ["one"], [{ 1 => 1 }]].each do |input| - it "should render #{input.class} using the 'pp' library" do - app.render(input).should == input.pretty_inspect + it "should render #{input.class} using JSON" do + app.render(input).should == input.to_pson.chomp end end - it "should render a non-trivially-keyed Hash with the 'pp' library" do + it "should render a non-trivially-keyed Hash with using JSON" do hash = { [1,2] => 3, [2,3] => 5, [3,4] => 7 } - app.render(hash).should == hash.pretty_inspect + app.render(hash).should == hash.to_pson.chomp end it "should render a {String,Numeric}-keyed Hash into a table" do @@ -266,7 +266,7 @@ describe Puppet::Application::FaceBase do app.render(hash).should == < { "1" => '1' * 40, "2" => '2' * 40, '3' => '3' * 40 }, "text" => { "a" => 'a' * 40, 'b' => 'b' * 40, 'c' => 'c' * 40 } @@ -289,7 +290,7 @@ EOT end it "should invoke the action rendering hook while rendering" do - app.action.set_rendering_method_for(:for_humans, proc { |value| "bi-winning!" }) + app.action.set_rendering_method_for(:console, proc { |value| "bi-winning!" }) app.render("bi-polar?").should == "bi-winning!" end @@ -328,4 +329,15 @@ EOT }.to have_printed(/you invoked the 's' rendering hook/) end end + + describe "#render_as=" do + # This is for compatibility with the format name in 2.7.0rc1, but isn't a + # long term desirable name. We can't just randomly drop it since it was + # released, though, so it will live for a couple of major versions. + # --daniel 2011-05-04 + it "should treat :for_humans as a synonym for :console" do + app.render_as = :for_humans + app.render_as.name.should == :console + end + end end -- cgit