Skip to content

Commit b75afb3

Browse files
authored
Merge pull request #130 from bastelfreak/rspecmock7
rspec-mocks: Pin to < 3.13.3
2 parents 77e2590 + c824fbb commit b75afb3

File tree

5 files changed

+19
-2
lines changed

5 files changed

+19
-2
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ group(:test) do
4747
gem "rspec", "~> 3.1", require: false
4848
gem "rspec-expectations", ["~> 3.9", "!= 3.9.3"]
4949
gem "rspec-its", "~> 1.1", require: false
50+
gem 'rspec-mocks', '< 3.13.3', require: false # breaking change afterwards: https://github.com/rspec/rspec-mocks/pull/1596
5051
gem 'vcr', '~> 5.0', require: false
5152
gem 'webmock', '~> 3.0', require: false
5253
gem 'webrick', '~> 1.7', require: false if RUBY_VERSION.to_f >= 3.0

lib/puppet/face/facts.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,15 @@
164164

165165
case result
166166
when Array, Hash
167-
Puppet::Util::Json.dump(result, :pretty => true)
167+
# JSON < 2.8.0 would pretty print empty arrays and hashes with newlines
168+
# Maintain that behavior for our users for now
169+
if result.is_a?(Array) && result.empty?
170+
"[\n\n]"
171+
elsif result.is_a?(Hash) && result.empty?
172+
"{\n}"
173+
else
174+
Puppet::Util::Json.dump(result, :pretty => true)
175+
end
168176
else # one of VALID_TYPES above
169177
result
170178
end

puppet.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Gem::Specification.new do |spec|
2929
spec.add_runtime_dependency(%q<concurrent-ruby>, "~> 1.0")
3030
spec.add_runtime_dependency(%q<deep_merge>, "~> 1.0")
3131
spec.add_runtime_dependency(%q<scanf>, "~> 1.0")
32+
spec.add_runtime_dependency(%q<json>, "< 2.9") # last known good version is 2.8.2
3233

3334
# For building platform specific puppet gems...the --platform flag is only supported in newer Ruby versions
3435
platform = spec.platform.to_s

spec/unit/application/facts_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191

9292
{
9393
"type_hash" => [{'a' => 2}, "{\n \"a\": 2\n}"],
94+
"type_empty_hash" => [{}, "{\n}"],
9495
"type_array" => [[], "[\n\n]"],
9596
"type_string" => ["str", "str"],
9697
"type_int" => [1, "1"],

spec/unit/provider/package/puppetserver_gem_spec.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,13 @@
7777

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

0 commit comments

Comments
 (0)