Skip to content

Commit

Permalink
Merge pull request #3672 from joshcooper/maint/master/PUP-3706-consol…
Browse files Browse the repository at this point in the history
…e-rendering

(PUP-3706) Render console output using PSON
  • Loading branch information
Kylo Ginsberg committed Mar 3, 2015
2 parents 5a96c82 + 9ecf151 commit e155144
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/puppet/network/formats.rb
Expand Up @@ -151,7 +151,7 @@ def render(datum)
end

# ...or pretty-print the inspect outcome.
return JSON.pretty_generate(datum)
return PSON.pretty_generate(datum)
end

def render_multiple(data)
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/application/face_base_spec.rb
Expand Up @@ -325,9 +325,9 @@ class Puppet::Application::FaceBase::Basetest < Puppet::Application::FaceBase
end
end

it "should render a non-trivially-keyed Hash with using pretty printed JSON" do
it "should render a non-trivially-keyed Hash with using pretty printed PSON" do
hash = { [1,2] => 3, [2,3] => 5, [3,4] => 7 }
expect(app.render(hash, {})).to eq(JSON.pretty_generate(hash).chomp)
expect(app.render(hash, {})).to eq(PSON.pretty_generate(hash).chomp)
end

it "should render a {String,Numeric}-keyed Hash into a table" do
Expand Down
10 changes: 8 additions & 2 deletions spec/unit/network/formats_spec.rb
Expand Up @@ -279,6 +279,12 @@ def to_pson(*args)
end
end

[true, false, nil, Object.new].each do |input|
it "renders #{input.class} using PSON" do
expect(subject.render(input)).to eq(input.to_pson)
end
end

[[1, 2], ["one"], [{ 1 => 1 }]].each do |input|
it "should render #{input.inspect} as one item per line" do
expect(subject.render(input)).to eq(input.collect { |item| item.to_s + "\n" }.join(''))
Expand All @@ -289,9 +295,9 @@ def to_pson(*args)
expect(subject.render({})).to eq('')
end

it "should render a non-trivially-keyed Hash as pretty printed JSON" do
it "should render a non-trivially-keyed Hash as pretty printed PSON" do
hash = { [1,2] => 3, [2,3] => 5, [3,4] => 7 }
expect(subject.render(hash)).to eq(JSON.pretty_generate(hash).chomp)
expect(subject.render(hash)).to eq(PSON.pretty_generate(hash).chomp)
end

it "should render a {String,Numeric}-keyed Hash into a table" do
Expand Down

0 comments on commit e155144

Please sign in to comment.