2023-01-17 16:17:15 +08:00
|
|
|
From 00bdf8d9468f88356307f0fa7bdc6c0d05925aaf Mon Sep 17 00:00:00 2001
|
|
|
|
|
From: wang--ge <wang__ge@126.com>
|
|
|
|
|
Date: Thu, 12 Jan 2023 15:08:14 +0800
|
|
|
|
|
Subject: [PATCH] RSpec 3.11.0+ distinguish between hashes and Ruby 3 keywords
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
spec/multi_json_spec.rb | 4 ++--
|
|
|
|
|
spec/shared/adapter.rb | 8 ++++----
|
|
|
|
|
spec/shared/json_common_adapter.rb | 4 ++--
|
|
|
|
|
3 files changed, 8 insertions(+), 8 deletions(-)
|
|
|
|
|
|
2023-11-16 09:59:31 +08:00
|
|
|
|
2023-01-17 16:17:15 +08:00
|
|
|
diff --git a/spec/multi_json_spec.rb b/spec/multi_json_spec.rb
|
2023-11-16 09:59:31 +08:00
|
|
|
index 323bff9..b3ffb4f 100644
|
2023-01-17 16:17:15 +08:00
|
|
|
--- a/spec/multi_json_spec.rb
|
|
|
|
|
+++ b/spec/multi_json_spec.rb
|
2023-11-16 09:59:31 +08:00
|
|
|
@@ -166,8 +166,8 @@
|
2023-01-17 16:17:15 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'sets both load and dump options' do
|
|
|
|
|
- expect(MultiJson).to receive(:dump_options=).with(:foo => 'bar')
|
|
|
|
|
- expect(MultiJson).to receive(:load_options=).with(:foo => 'bar')
|
|
|
|
|
+ expect(MultiJson).to receive(:dump_options=).with({:foo => 'bar'})
|
|
|
|
|
+ expect(MultiJson).to receive(:load_options=).with({:foo => 'bar'})
|
|
|
|
|
silence_warnings { MultiJson.default_options = {:foo => 'bar'} }
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
diff --git a/spec/shared/adapter.rb b/spec/shared/adapter.rb
|
|
|
|
|
index e850b99..52a6bc9 100644
|
|
|
|
|
--- a/spec/shared/adapter.rb
|
|
|
|
|
+++ b/spec/shared/adapter.rb
|
2023-11-16 09:59:31 +08:00
|
|
|
@@ -19,7 +19,7 @@
|
2023-01-17 16:17:15 +08:00
|
|
|
before { MultiJson.dump_options = MultiJson.adapter.dump_options = {} }
|
|
|
|
|
|
|
|
|
|
after do
|
|
|
|
|
- expect(MultiJson.adapter.instance).to receive(:dump).with(1, :foo => 'bar', :fizz => 'buzz')
|
|
|
|
|
+ expect(MultiJson.adapter.instance).to receive(:dump).with(1, {:foo => 'bar', :fizz => 'buzz'})
|
|
|
|
|
MultiJson.dump(1, :fizz => 'buzz')
|
|
|
|
|
MultiJson.dump_options = MultiJson.adapter.dump_options = nil
|
|
|
|
|
end
|
2023-11-16 09:59:31 +08:00
|
|
|
@@ -100,8 +100,8 @@
|
2023-01-17 16:17:15 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'passes options to the adapter' do
|
|
|
|
|
- expect(MultiJson.adapter).to receive(:dump).with('foo', :bar => :baz)
|
|
|
|
|
- MultiJson.dump('foo', :bar => :baz)
|
|
|
|
|
+ expect(MultiJson.adapter).to receive(:dump).with('foo', {:bar => :baz})
|
|
|
|
|
+ MultiJson.dump('foo', {:bar => :baz})
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'dumps custom objects that implement to_json' do
|
2023-11-16 09:59:31 +08:00
|
|
|
@@ -128,7 +128,7 @@ def to_json(*)
|
2023-01-17 16:17:15 +08:00
|
|
|
before { MultiJson.load_options = MultiJson.adapter.load_options = {} }
|
|
|
|
|
|
|
|
|
|
after do
|
|
|
|
|
- expect(MultiJson.adapter.instance).to receive(:load).with('1', :foo => 'bar', :fizz => 'buzz')
|
|
|
|
|
+ expect(MultiJson.adapter.instance).to receive(:load).with('1', {:foo => 'bar', :fizz => 'buzz'})
|
|
|
|
|
MultiJson.load('1', :fizz => 'buzz')
|
|
|
|
|
MultiJson.load_options = MultiJson.adapter.load_options = nil
|
|
|
|
|
end
|
|
|
|
|
diff --git a/spec/shared/json_common_adapter.rb b/spec/shared/json_common_adapter.rb
|
|
|
|
|
index 9597d90..5a23c38 100644
|
|
|
|
|
--- a/spec/shared/json_common_adapter.rb
|
|
|
|
|
+++ b/spec/shared/json_common_adapter.rb
|
2023-11-16 09:59:31 +08:00
|
|
|
@@ -15,7 +15,7 @@
|
2023-01-17 16:17:15 +08:00
|
|
|
describe 'with :indent option' do
|
|
|
|
|
it 'passes it on dump' do
|
|
|
|
|
object = 'foo'
|
|
|
|
|
- expect(object).to receive(:to_json).with(:indent => "\t")
|
|
|
|
|
+ expect(object).to receive(:to_json).with({:indent => "\t"})
|
|
|
|
|
MultiJson.dump(object, :indent => "\t")
|
|
|
|
|
end
|
|
|
|
|
end
|
2023-11-16 09:59:31 +08:00
|
|
|
@@ -23,7 +23,7 @@
|
2023-01-17 16:17:15 +08:00
|
|
|
|
|
|
|
|
describe '.load' do
|
|
|
|
|
it 'passes :quirks_mode option' do
|
|
|
|
|
- expect(::JSON).to receive(:parse).with('[123]', :quirks_mode => false, :create_additions => false)
|
|
|
|
|
+ expect(::JSON).to receive(:parse).with('[123]', {:quirks_mode => false, :create_additions => false})
|
|
|
|
|
MultiJson.load('[123]', :quirks_mode => false)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
--
|
|
|
|
|
2.27.0
|
|
|
|
|
|