5e872b8
From 2947373cd6325b273e3206b63d16ddbfc1118ecf Mon Sep 17 00:00:00 2001
5e872b8
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com>
5e872b8
Date: Thu, 3 Nov 2022 17:28:43 +0100
5e872b8
Subject: [PATCH] Fix kwargs matching with rspec-mock 3.12 and Ruby 3+
5e872b8
5e872b8
The test seems to be broken by:
5e872b8
5e872b8
https://github.com/rspec/rspec-mocks/pull/1461
5e872b8
---
5e872b8
 spec/lib/listen/adapter/base_spec.rb        |  2 +-
5e872b8
 spec/lib/listen/adapter/linux_spec.rb       |  6 ++++--
5e872b8
 spec/lib/listen/adapter/polling_spec.rb     |  2 +-
5e872b8
 spec/lib/listen/directory_spec.rb           | 12 ++++++------
5e872b8
 spec/lib/listen/listener_spec.rb            | 20 ++++++++++----------
5e872b8
 spec/lib/listen/silencer/controller_spec.rb | 12 ++++++------
5e872b8
 6 files changed, 28 insertions(+), 26 deletions(-)
5e872b8
5e872b8
diff --git a/spec/lib/listen/adapter/base_spec.rb b/spec/lib/listen/adapter/base_spec.rb
5e872b8
index 6cf0cad..2b53127 100644
5e872b8
--- a/spec/lib/listen/adapter/base_spec.rb
5e872b8
+++ b/spec/lib/listen/adapter/base_spec.rb
5e872b8
@@ -91,7 +91,7 @@ RSpec.describe Listen::Adapter::Base do
5e872b8
       it 'passes invalidates the snapshot based on the event' do
5e872b8
         subject.start
5e872b8
 
5e872b8
-        expect(snapshot).to receive(:invalidate).with(:file, 'bar', cookie: 3)
5e872b8
+        expect(snapshot).to receive(:invalidate).with(:file, 'bar', { cookie: 3 })
5e872b8
 
5e872b8
         event = { dir: '/foo/dir1', file: 'bar', type: :moved, cookie: 3 }
5e872b8
         subject.fake_event(event)
5e872b8
diff --git a/spec/lib/listen/adapter/linux_spec.rb b/spec/lib/listen/adapter/linux_spec.rb
5e872b8
index e55bbf6..14f5d48 100644
5e872b8
--- a/spec/lib/listen/adapter/linux_spec.rb
5e872b8
+++ b/spec/lib/listen/adapter/linux_spec.rb
5e872b8
@@ -112,8 +112,10 @@ RSpec.describe Listen::Adapter::Linux do
5e872b8
             expect(snapshot).to receive(:invalidate).with(
5e872b8
               :file,
5e872b8
               'path/foo.txt',
5e872b8
-              cookie: 123,
5e872b8
-              change: change
5e872b8
+              {
5e872b8
+                cookie: 123,
5e872b8
+                change: change
5e872b8
+              }
5e872b8
             )
5e872b8
           end
5e872b8
         end
5e872b8
diff --git a/spec/lib/listen/adapter/polling_spec.rb b/spec/lib/listen/adapter/polling_spec.rb
5e872b8
index 925db74..fae546f 100644
5e872b8
--- a/spec/lib/listen/adapter/polling_spec.rb
5e872b8
+++ b/spec/lib/listen/adapter/polling_spec.rb
5e872b8
@@ -56,7 +56,7 @@ RSpec.describe Adapter::Polling do
5e872b8
 
5e872b8
       it 'notifies change on every listener directories path' do
5e872b8
         expect(snapshot).to receive(:invalidate).
5e872b8
-          with(:dir, '.', recursive: true)
5e872b8
+          with(:dir, '.', { recursive: true })
5e872b8
 
5e872b8
         t = Thread.new { subject.start }
5e872b8
         sleep 0.25
5e872b8
diff --git a/spec/lib/listen/directory_spec.rb b/spec/lib/listen/directory_spec.rb
5e872b8
index 43ea522..3340067 100644
5e872b8
--- a/spec/lib/listen/directory_spec.rb
5e872b8
+++ b/spec/lib/listen/directory_spec.rb
5e872b8
@@ -76,7 +76,7 @@ RSpec.describe Directory do
5e872b8
           expect(snapshot).to receive(:invalidate).with(:file, 'file.rb', {})
5e872b8
 
5e872b8
           expect(snapshot).to receive(:invalidate).
5e872b8
-            with(:dir, 'subdir', recursive: false)
5e872b8
+            with(:dir, 'subdir', { recursive: false })
5e872b8
 
5e872b8
           described_class.scan(snapshot, '.', options)
5e872b8
         end
5e872b8
@@ -91,7 +91,7 @@ RSpec.describe Directory do
5e872b8
 
5e872b8
         it 'notices subdir does not exist' do
5e872b8
           expect(snapshot).to receive(:invalidate).
5e872b8
-            with(:dir, 'subdir', recursive: false)
5e872b8
+            with(:dir, 'subdir', { recursive: false })
5e872b8
 
5e872b8
           described_class.scan(snapshot, '.', options)
5e872b8
         end
5e872b8
@@ -219,7 +219,7 @@ RSpec.describe Directory do
5e872b8
           expect(snapshot).to receive(:invalidate).with(:file, 'file.rb', {})
5e872b8
 
5e872b8
           expect(snapshot).to receive(:invalidate).
5e872b8
-            with(:dir, 'subdir', recursive: true)
5e872b8
+            with(:dir, 'subdir', { recursive: true })
5e872b8
 
5e872b8
           described_class.scan(snapshot, '.', options)
5e872b8
         end
5e872b8
@@ -240,10 +240,10 @@ RSpec.describe Directory do
5e872b8
           expect(snapshot).to receive(:invalidate).with(:file, 'file.rb', {})
5e872b8
 
5e872b8
           expect(snapshot).to receive(:invalidate).
5e872b8
-            with(:dir, 'subdir', recursive: true)
5e872b8
+            with(:dir, 'subdir', { recursive: true })
5e872b8
 
5e872b8
           expect(snapshot).to receive(:invalidate).
5e872b8
-            with(:dir, 'subdir2', recursive: true)
5e872b8
+            with(:dir, 'subdir2', { recursive: true })
5e872b8
 
5e872b8
           described_class.scan(snapshot, '.', options)
5e872b8
         end
5e872b8
@@ -274,7 +274,7 @@ RSpec.describe Directory do
5e872b8
 
5e872b8
         it 'snapshots changes for subdir' do
5e872b8
           expect(snapshot).to receive(:invalidate).
5e872b8
-            with(:dir, 'subdir', recursive: true)
5e872b8
+            with(:dir, 'subdir', { recursive: true })
5e872b8
 
5e872b8
           described_class.scan(snapshot, '.', options)
5e872b8
         end
5e872b8
diff --git a/spec/lib/listen/listener_spec.rb b/spec/lib/listen/listener_spec.rb
5e872b8
index 9b67e27..8dd9a7a 100644
5e872b8
--- a/spec/lib/listen/listener_spec.rb
5e872b8
+++ b/spec/lib/listen/listener_spec.rb
5e872b8
@@ -245,12 +245,12 @@ RSpec.describe Listener do
5e872b8
       let(:options) { { ignore: /bar/ } }
5e872b8
 
5e872b8
       it 'adds up to existing ignore options' do
5e872b8
-        expect(silencer).to receive(:configure).once.with(ignore: [/bar/])
5e872b8
+        expect(silencer).to receive(:configure).once.with({ ignore: [/bar/] })
5e872b8
 
5e872b8
         subject
5e872b8
 
5e872b8
         expect(silencer).to receive(:configure).once.
5e872b8
-          with(ignore: [/bar/, /foo/])
5e872b8
+          with({ ignore: [/bar/, /foo/] })
5e872b8
 
5e872b8
         subject.ignore(/foo/)
5e872b8
       end
5e872b8
@@ -260,12 +260,12 @@ RSpec.describe Listener do
5e872b8
       let(:options) { { ignore: [/bar/] } }
5e872b8
 
5e872b8
       it 'adds up to existing ignore options' do
5e872b8
-        expect(silencer).to receive(:configure).once.with(ignore: [/bar/])
5e872b8
+        expect(silencer).to receive(:configure).once.with({ ignore: [/bar/] })
5e872b8
 
5e872b8
         subject
5e872b8
 
5e872b8
         expect(silencer).to receive(:configure).once.
5e872b8
-          with(ignore: [/bar/, /foo/])
5e872b8
+          with({ ignore: [/bar/, /foo/] })
5e872b8
 
5e872b8
         subject.ignore(/foo/)
5e872b8
       end
5e872b8
@@ -287,9 +287,9 @@ RSpec.describe Listener do
5e872b8
       let(:options) { { ignore!: /bar/ } }
5e872b8
 
5e872b8
       it 'overwrites existing ignore options' do
5e872b8
-        expect(silencer).to receive(:configure).once.with(ignore!: [/bar/])
5e872b8
+        expect(silencer).to receive(:configure).once.with({ ignore!: [/bar/] })
5e872b8
         subject
5e872b8
-        expect(silencer).to receive(:configure).once.with(ignore!: [/foo/])
5e872b8
+        expect(silencer).to receive(:configure).once.with({ ignore!: [/foo/] })
5e872b8
         subject.ignore!([/foo/])
5e872b8
       end
5e872b8
     end
5e872b8
@@ -298,9 +298,9 @@ RSpec.describe Listener do
5e872b8
       let(:options) { { ignore: /bar/ } }
5e872b8
 
5e872b8
       it 'deletes ignore options' do
5e872b8
-        expect(silencer).to receive(:configure).once.with(ignore: [/bar/])
5e872b8
+        expect(silencer).to receive(:configure).once.with({ ignore: [/bar/] })
5e872b8
         subject
5e872b8
-        expect(silencer).to receive(:configure).once.with(ignore!: [/foo/])
5e872b8
+        expect(silencer).to receive(:configure).once.with({ ignore!: [/foo/] })
5e872b8
         subject.ignore!([/foo/])
5e872b8
       end
5e872b8
     end
5e872b8
@@ -311,9 +311,9 @@ RSpec.describe Listener do
5e872b8
       let(:options) { { only: /bar/ } }
5e872b8
 
5e872b8
       it 'overwrites existing ignore options' do
5e872b8
-        expect(silencer).to receive(:configure).once.with(only: [/bar/])
5e872b8
+        expect(silencer).to receive(:configure).once.with({ only: [/bar/] })
5e872b8
         subject
5e872b8
-        expect(silencer).to receive(:configure).once.with(only: [/foo/])
5e872b8
+        expect(silencer).to receive(:configure).once.with({ only: [/foo/] })
5e872b8
         subject.only([/foo/])
5e872b8
       end
5e872b8
     end
5e872b8
diff --git a/spec/lib/listen/silencer/controller_spec.rb b/spec/lib/listen/silencer/controller_spec.rb
5e872b8
index 984630c..5393a34 100644
5e872b8
--- a/spec/lib/listen/silencer/controller_spec.rb
5e872b8
+++ b/spec/lib/listen/silencer/controller_spec.rb
5e872b8
@@ -26,7 +26,7 @@ RSpec.describe Listen::Silencer::Controller do
5e872b8
       context 'when providing a single regexp as argument' do
5e872b8
         it 'sets the given :ignore rules as array' do
5e872b8
           subject
5e872b8
-          allow(silencer).to receive(:configure).with(ignore: [/foo/])
5e872b8
+          allow(silencer).to receive(:configure).with({ ignore: [/foo/] })
5e872b8
           subject.append_ignores(/foo/)
5e872b8
         end
5e872b8
       end
5e872b8
@@ -34,7 +34,7 @@ RSpec.describe Listen::Silencer::Controller do
5e872b8
       context 'when providing multiple arguments' do
5e872b8
         it 'sets the given :ignore rules as a flat array' do
5e872b8
           subject
5e872b8
-          allow(silencer).to receive(:configure).with(ignore: [/foo/, /bar/])
5e872b8
+          allow(silencer).to receive(:configure).with({ ignore: [/foo/, /bar/] })
5e872b8
           subject.append_ignores(/foo/, /bar/)
5e872b8
         end
5e872b8
       end
5e872b8
@@ -42,7 +42,7 @@ RSpec.describe Listen::Silencer::Controller do
5e872b8
       context 'when providing as array' do
5e872b8
         it 'sets the given :ignore rules' do
5e872b8
           subject
5e872b8
-          allow(silencer).to receive(:configure).with(ignore: [/foo/, /bar/])
5e872b8
+          allow(silencer).to receive(:configure).with({ ignore: [/foo/, /bar/] })
5e872b8
           subject.append_ignores([/foo/, /bar/])
5e872b8
         end
5e872b8
       end
5e872b8
@@ -50,18 +50,18 @@ RSpec.describe Listen::Silencer::Controller do
5e872b8
 
5e872b8
     context 'with previous :ignore rules' do
5e872b8
       subject do
5e872b8
-        described_class.new(silencer, ignore: [/foo/, /bar/])
5e872b8
+        described_class.new(silencer, { ignore: [/foo/, /bar/] })
5e872b8
       end
5e872b8
 
5e872b8
       before do
5e872b8
-        allow(silencer).to receive(:configure).with(ignore: [/foo/, /bar/])
5e872b8
+        allow(silencer).to receive(:configure).with({ ignore: [/foo/, /bar/] })
5e872b8
       end
5e872b8
 
5e872b8
       context 'when providing a nil' do
5e872b8
         # TODO: should this invocation maybe reset the rules?
5e872b8
         it 'reconfigures with existing :ignore rules' do
5e872b8
           subject
5e872b8
-          allow(silencer).to receive(:configure).with(ignore: [/foo/, /bar/])
5e872b8
+          allow(silencer).to receive(:configure).with({ ignore: [/foo/, /bar/] })
5e872b8
           subject.append_ignores(nil)
5e872b8
         end
5e872b8
       end
5e872b8
-- 
5e872b8
2.38.1
5e872b8