From 2d8fef0c059c738119ab9b57b0ee685e3309b23f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ondruch?= Date: Fri, 4 Nov 2022 19:16:39 +0100 Subject: [PATCH] Fix RSpec 3.12 kwargs compatibility. This is broken by https://github.com/rspec/rspec-mocks/pull/1461 --- spec/lib/guard/commander_spec.rb | 6 ++-- spec/lib/guard/commands/scope_spec.rb | 4 +-- spec/lib/guard/deprecated/dsl_spec.rb | 2 +- spec/lib/guard/deprecated/guard_spec.rb | 12 +++---- spec/lib/guard/deprecated/guardfile_spec.rb | 2 +- spec/lib/guard/dsl_spec.rb | 36 ++++++++++----------- spec/lib/guard/internals/plugins_spec.rb | 8 ++--- spec/lib/guard/internals/state_spec.rb | 2 +- spec/lib/guard/notifier_spec.rb | 2 +- spec/lib/guard/ui/config_spec.rb | 4 +-- spec/lib/guard/ui_spec.rb | 6 ++-- spec/lib/guard_spec.rb | 4 +-- 12 files changed, 44 insertions(+), 44 deletions(-) diff --git a/spec/lib/guard/commander_spec.rb b/spec/lib/guard/commander_spec.rb index dcd63b8..55fee7d 100644 --- a/spec/lib/guard/commander_spec.rb +++ b/spec/lib/guard/commander_spec.rb @@ -46,7 +46,7 @@ RSpec.describe Guard::Commander do end it "calls Guard setup" do - expect(Guard).to receive(:setup).with(foo: "bar") + expect(Guard).to receive(:setup).with({ foo: "bar" }) Guard.start(foo: "bar") end @@ -167,7 +167,7 @@ RSpec.describe Guard::Commander do end it "reloads Guard" do - expect(runner).to receive(:run).with(:reload, groups: [group]) + expect(runner).to receive(:run).with(:reload, { groups: [group] }) Guard.reload(groups: [group]) end end @@ -183,7 +183,7 @@ RSpec.describe Guard::Commander do context "with a given scope" do it "runs all with the scope" do - expect(runner).to receive(:run).with(:run_all, groups: [group]) + expect(runner).to receive(:run).with(:run_all, { groups: [group] }) subject.run_all(groups: [group]) end diff --git a/spec/lib/guard/commands/scope_spec.rb b/spec/lib/guard/commands/scope_spec.rb index 5fd4e5a..adeb862 100644 --- a/spec/lib/guard/commands/scope_spec.rb +++ b/spec/lib/guard/commands/scope_spec.rb @@ -54,7 +54,7 @@ RSpec.describe Guard::Commands::Scope do it "sets up the scope with the given scope" do expect(scope).to receive(:from_interactor) - .with(groups: [foo_group], plugins: []) + .with({ groups: [foo_group], plugins: [] }) FakePry.process("foo") end end @@ -65,7 +65,7 @@ RSpec.describe Guard::Commands::Scope do it "runs the :scope= action with the given scope" do expect(scope).to receive(:from_interactor) - .with(plugins: [bar_guard], groups: []) + .with({ plugins: [bar_guard], groups: [] }) FakePry.process("bar") end end diff --git a/spec/lib/guard/deprecated/dsl_spec.rb b/spec/lib/guard/deprecated/dsl_spec.rb index 4a2594e..7ca9a04 100644 --- a/spec/lib/guard/deprecated/dsl_spec.rb +++ b/spec/lib/guard/deprecated/dsl_spec.rb @@ -48,7 +48,7 @@ unless Guard::Config.new.strict? it "delegates to Guard::Guardfile::Generator" do expect(Guard::Guardfile::Evaluator).to receive(:new) - .with(foo: "bar") { evaluator } + .with({ foo: "bar" }) { evaluator } expect(evaluator).to receive(:evaluate_guardfile) diff --git a/spec/lib/guard/deprecated/guard_spec.rb b/spec/lib/guard/deprecated/guard_spec.rb index 5981faf..f38d840 100644 --- a/spec/lib/guard/deprecated/guard_spec.rb +++ b/spec/lib/guard/deprecated/guard_spec.rb @@ -51,7 +51,7 @@ unless Guard::Config.new.strict? end it "delegates to Plugins" do - expect(plugins).to receive(:all).with(group: "backend") + expect(plugins).to receive(:all).with({ group: "backend" }) subject.guards(group: "backend") end end @@ -67,7 +67,7 @@ unless Guard::Config.new.strict? end it "delegates to Guard.plugins" do - expect(subject).to receive(:add_plugin).with("rspec", group: "backend") + expect(subject).to receive(:add_plugin).with("rspec", { group: "backend" }) subject.add_guard("rspec", group: "backend") end @@ -285,7 +285,7 @@ unless Guard::Config.new.strict? it "adds a group" do group = instance_double("Guard::Group") - expect(groups).to receive(:add).with(:foo, bar: 3).and_return(group) + expect(groups).to receive(:add).with(:foo, { bar: 3 }).and_return(group) expect(subject.add_group(:foo, bar: 3)).to eq(group) end end @@ -303,7 +303,7 @@ unless Guard::Config.new.strict? it "adds a plugin" do plugin = instance_double("Guard::Plugin") - expect(plugins).to receive(:add).with(:foo, bar: 3).and_return(plugin) + expect(plugins).to receive(:add).with(:foo, { bar: 3 }).and_return(plugin) expect(subject.add_plugin(:foo, bar: 3)).to be(plugin) end end @@ -405,7 +405,7 @@ unless Guard::Config.new.strict? describe ".scope=" do before do - allow(scope).to receive(:from_interactor).with(foo: :bar) + allow(scope).to receive(:from_interactor).with({ foo: :bar }) end it "show deprecation warning" do @@ -415,7 +415,7 @@ unless Guard::Config.new.strict? end it "provides a similar implementation" do - expect(scope).to receive(:from_interactor).with(foo: :bar) + expect(scope).to receive(:from_interactor).with({ foo: :bar }) subject.scope = { foo: :bar } end end diff --git a/spec/lib/guard/deprecated/guardfile_spec.rb b/spec/lib/guard/deprecated/guardfile_spec.rb index c52bd7d..6996e31 100644 --- a/spec/lib/guard/deprecated/guardfile_spec.rb +++ b/spec/lib/guard/deprecated/guardfile_spec.rb @@ -38,7 +38,7 @@ unless Guard::Config.new.strict? it "delegates to Guard::Guardfile::Generator" do expect(Guard::Guardfile::Generator).to receive(:new) - .with(foo: "bar") { generator } + .with({ foo: "bar" }) { generator } expect(generator).to receive(:create_guardfile) diff --git a/spec/lib/guard/dsl_spec.rb b/spec/lib/guard/dsl_spec.rb index 2fc7881..7eafc3f 100644 --- a/spec/lib/guard/dsl_spec.rb +++ b/spec/lib/guard/dsl_spec.rb @@ -114,7 +114,7 @@ RSpec.describe Guard::Dsl do let(:contents) { "notification :growl" } it "adds a notification to the notifier" do - expect(session).to receive(:guardfile_notification=).with(growl: {}) + expect(session).to receive(:guardfile_notification=).with({ growl: {} }) evaluator.call(contents) end @@ -126,9 +126,9 @@ RSpec.describe Guard::Dsl do end it "adds multiple notifiers" do - expect(session).to receive(:guardfile_notification=).with(growl: {}) + expect(session).to receive(:guardfile_notification=).with({ growl: {} }) expect(session).to receive(:guardfile_notification=).with( - ruby_gntp: { host: "192.168.1.5" } + { ruby_gntp: { host: "192.168.1.5" } } ) evaluator.call(contents) @@ -149,7 +149,7 @@ RSpec.describe Guard::Dsl do let(:contents) { "interactor option1: 'a', option2: 123" } it "passes the options to the interactor" do expect(Guard::Interactor).to receive(:options=) - .with(option1: "a", option2: 123) + .with({ option1: "a", option2: 123 }) evaluator.call(contents) end @@ -199,21 +199,21 @@ RSpec.describe Guard::Dsl do it "evaluates all groups" do expect(groups).to receive(:add).with(:w, {}) expect(groups).to receive(:add).with(:y, {}) - expect(groups).to receive(:add).with(:x, halt_on_fail: true) + expect(groups).to receive(:add).with(:x, { halt_on_fail: true }) expect(plugins).to receive(:add) - .with(:pow, watchers: [], callbacks: [], group: :default) + .with(:pow, { watchers: [], callbacks: [], group: :default }) expect(plugins).to receive(:add) - .with(:test, watchers: [], callbacks: [], group: :w) + .with(:test, { watchers: [], callbacks: [], group: :w }) expect(plugins).to receive(:add) - .with(:rspec, watchers: [], callbacks: [], group: :x).twice + .with(:rspec, { watchers: [], callbacks: [], group: :x }).twice expect(plugins).to receive(:add) - .with(:less, watchers: [], callbacks: [], group: :y) + .with(:less, { watchers: [], callbacks: [], group: :y }) - expect(session).to receive(:guardfile_notification=).with(growl: {}) + expect(session).to receive(:guardfile_notification=).with({ growl: {} }) evaluator.call(contents) end end @@ -235,7 +235,7 @@ RSpec.describe Guard::Dsl do it "loads a guard specified as a quoted string from the DSL" do expect(plugins).to receive(:add) - .with("test", watchers: [], callbacks: [], group: :default) + .with("test", { watchers: [], callbacks: [], group: :default }) evaluator.call(contents) end @@ -246,7 +246,7 @@ RSpec.describe Guard::Dsl do it "loads a guard specified as a double quoted string from the DSL" do expect(plugins).to receive(:add) - .with("test", watchers: [], callbacks: [], group: :default) + .with("test", { watchers: [], callbacks: [], group: :default }) evaluator.call(contents) end @@ -257,7 +257,7 @@ RSpec.describe Guard::Dsl do it "loads a guard specified as a symbol from the DSL" do expect(plugins).to receive(:add) - .with(:test, watchers: [], callbacks: [], group: :default) + .with(:test, { watchers: [], callbacks: [], group: :default }) evaluator.call(contents) end @@ -268,7 +268,7 @@ RSpec.describe Guard::Dsl do it "adds the plugin" do expect(plugins).to receive(:add) - .with(:test, watchers: [], callbacks: [], group: :default) + .with(:test, {watchers: [], callbacks: [], group: :default }) evaluator.call(contents) end end @@ -297,7 +297,7 @@ RSpec.describe Guard::Dsl do expect(groups).to receive(:add).with(:foo, {}) expect(groups).to receive(:add).with(:bar, {}) expect(plugins).to receive(:add) - .with(:test, watchers: [], callbacks: [], group: :bar) + .with(:test, { watchers: [], callbacks: [], group: :bar }) evaluator.call(contents) end @@ -313,10 +313,10 @@ RSpec.describe Guard::Dsl do expect(groups).to receive(:add).with(:bar, {}) expect(plugins).to receive(:add) - .with(:test, watchers: [], callbacks: [], group: :bar) + .with(:test, { watchers: [], callbacks: [], group: :bar }) expect(plugins).to receive(:add) - .with(:rspec, watchers: [], callbacks: [], group: :default) + .with(:rspec, { watchers: [], callbacks: [], group: :default }) evaluator.call(contents) end @@ -581,7 +581,7 @@ RSpec.describe Guard::Dsl do let(:contents) { "scope plugins: [:foo, :bar]" } it "sets the guardfile's default scope" do - expect(session).to receive(:guardfile_scope).with(plugins: %i[foo bar]) + expect(session).to receive(:guardfile_scope).with({ plugins: %i[foo bar] }) evaluator.call(contents) end end diff --git a/spec/lib/guard/internals/plugins_spec.rb b/spec/lib/guard/internals/plugins_spec.rb index 27eaaee..674260c 100644 --- a/spec/lib/guard/internals/plugins_spec.rb +++ b/spec/lib/guard/internals/plugins_spec.rb @@ -26,16 +26,16 @@ RSpec.describe Guard::Internals::Plugins do allow(Guard::PluginUtil).to receive(:new).with("foobaz") .and_return(pu_foobaz) - allow(pu_foobar).to receive(:initialize_plugin).with(group: "frontend") + allow(pu_foobar).to receive(:initialize_plugin).with({ group: "frontend" }) .and_return(foo_bar_frontend) - allow(pu_foobaz).to receive(:initialize_plugin).with(group: "frontend") + allow(pu_foobaz).to receive(:initialize_plugin).with({ group: "frontend" }) .and_return(foo_baz_frontend) - allow(pu_foobar).to receive(:initialize_plugin).with(group: "backend") + allow(pu_foobar).to receive(:initialize_plugin).with({ group: "backend" }) .and_return(foo_bar_backend) - allow(pu_foobaz).to receive(:initialize_plugin).with(group: "backend") + allow(pu_foobaz).to receive(:initialize_plugin).with({ group: "backend" }) .and_return(foo_baz_backend) end diff --git a/spec/lib/guard/internals/state_spec.rb b/spec/lib/guard/internals/state_spec.rb index f406a89..ea0959b 100644 --- a/spec/lib/guard/internals/state_spec.rb +++ b/spec/lib/guard/internals/state_spec.rb @@ -24,7 +24,7 @@ RSpec.describe Guard::Internals::State do let(:options) { { debug: debug } } before do allow(session).to receive(:debug?).and_return(debug) - expect(Guard::Internals::Session).to receive(:new).with(debug: debug) + expect(Guard::Internals::Session).to receive(:new).with({ debug: debug }) end context "when debug is set to true" do diff --git a/spec/lib/guard/notifier_spec.rb b/spec/lib/guard/notifier_spec.rb index 5f23724..d5362b3 100644 --- a/spec/lib/guard/notifier_spec.rb +++ b/spec/lib/guard/notifier_spec.rb @@ -62,7 +62,7 @@ RSpec.describe Guard::Notifier do context "with multiple parameters" do it "notifies" do expect(notifier).to receive(:notify) - .with("A", priority: 2, image: :failed) + .with("A", { priority: 2, image: :failed }) subject.notify("A", priority: 2, image: :failed) end end diff --git a/spec/lib/guard/ui/config_spec.rb b/spec/lib/guard/ui/config_spec.rb index 059dac6..224425e 100644 --- a/spec/lib/guard/ui/config_spec.rb +++ b/spec/lib/guard/ui/config_spec.rb @@ -48,7 +48,7 @@ RSpec.describe Guard::UI::Config do it "passes deprecated options to logger" do expect(Guard::UI::Logger::Config).to receive(:new) - .with(time_format: "foo") + .with({ time_format: "foo" }) subject end @@ -62,7 +62,7 @@ RSpec.describe Guard::UI::Config do it "passes deprecated options to logger" do expect(Guard::UI::Logger::Config).to receive(:new) - .with(time_format: "foo") + .with({ time_format: "foo" }) subject end diff --git a/spec/lib/guard/ui_spec.rb b/spec/lib/guard/ui_spec.rb index e70594b..3139d86 100644 --- a/spec/lib/guard/ui_spec.rb +++ b/spec/lib/guard/ui_spec.rb @@ -133,7 +133,7 @@ RSpec.describe Guard::UI do let(:new_config) { instance_double("Guard::UI::Config") } before do - allow(Guard::UI::Config).to receive(:new).with(hi: :ho) + allow(Guard::UI::Config).to receive(:new).with({ hi: :ho }) .and_return(new_config) allow(new_config).to receive(:[]).with(:hi).and_return(:ho) @@ -326,7 +326,7 @@ RSpec.describe Guard::UI do context "with a plugins scope" do it "shows the plugin scoped action" do - allow(scope).to receive(:titles).with(plugins: [rspec, jasmine]) + allow(scope).to receive(:titles).with({ plugins: [rspec, jasmine] }) .and_return(%w[Rspec Jasmine]) expect(Guard::UI).to receive(:info).with("Reload Rspec, Jasmine") @@ -336,7 +336,7 @@ RSpec.describe Guard::UI do context "with a groups scope" do it "shows the group scoped action" do - allow(scope).to receive(:titles).with(groups: [group]) + allow(scope).to receive(:titles).with({ groups: [group] }) .and_return(%w[Frontend]) expect(Guard::UI).to receive(:info).with("Reload Frontend") diff --git a/spec/lib/guard_spec.rb b/spec/lib/guard_spec.rb index 79ded1c..6c6e1dc 100644 --- a/spec/lib/guard_spec.rb +++ b/spec/lib/guard_spec.rb @@ -79,7 +79,7 @@ RSpec.describe Guard do it "initializes the listener" do allow(Listen).to receive(:to) - .with("/foo", latency: 2, wait_for_delay: 1).and_return(listener) + .with("/foo", { latency: 2, wait_for_delay: 1 }).and_return(listener) allow(session).to receive(:listener_args).and_return( [:to, "/foo", { latency: 2, wait_for_delay: 1 }] @@ -157,7 +157,7 @@ RSpec.describe Guard do end it "connects to the notifier" do - expect(Guard::Notifier).to receive(:connect).with(notify: true) + expect(Guard::Notifier).to receive(:connect).with({ notify: true }) subject end -- 2.38.1