Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,10 @@ Naming/VariableNumber:
# SupportedStyles: inline, group
Style/AccessModifierDeclarations:
Exclude:
- 'lib/puppet/util/command_line/trollop.rb'
- 'lib/puppet/util/suidmanager.rb'
- 'lib/puppet/util/windows/com.rb'
- 'lib/puppet/util/windows/monkey_patches/process.rb'

# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: EnforcedStyle.
Expand Down
10 changes: 9 additions & 1 deletion lib/puppet/face/facts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,15 @@

case result
when Array, Hash
Puppet::Util::Json.dump(result, :pretty => true)
# JSON < 2.8.0 would pretty print empty arrays and hashes with newlines
# Maintain that behavior for our users for now
if result.is_a?(Array) && result.empty?
"[\n\n]"
elsif result.is_a?(Hash) && result.empty?
"{\n}"
else
Puppet::Util::Json.dump(result, :pretty => true)
end
else # one of VALID_TYPES above
result
end
Expand Down
1 change: 1 addition & 0 deletions spec/unit/application/facts_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@

{
"type_hash" => [{'a' => 2}, "{\n \"a\": 2\n}"],
"type_empty_hash" => [{}, "{\n}"],
"type_array" => [[], "[\n\n]"],
"type_string" => ["str", "str"],
"type_int" => [1, "1"],
Expand Down
8 changes: 7 additions & 1 deletion spec/unit/provider/package/puppetserver_gem_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,13 @@

it "raises if given an invalid URI" do
resource[:source] = 'h;ttp://rubygems.com'
expect { provider.install }.to raise_error(Puppet::Error, /Invalid source '': bad URI\(is not URI\?\)/)
# Older versions of URI don't have a space before the opening
# parenthesis in the error message, newer versions do
if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('3.0.0')
expect { provider.install }.to raise_error(Puppet::Error, /Invalid source '': bad URI\(is not URI\?\)/)
else
expect { provider.install }.to raise_error(Puppet::Error, /Invalid source '': bad URI \(is not URI\?\)/)
end
end
end
end
Expand Down