Skip to content

Commit

Permalink
Fix kwargs matching with rspec-mock 3.12 and Ruby 3+
Browse files Browse the repository at this point in the history
The test seems to be broken by:

rspec/rspec-mocks#1461
  • Loading branch information
voxik authored and ColinDKelley committed Nov 28, 2022
1 parent ded2016 commit abb90a5
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 26 deletions.
2 changes: 1 addition & 1 deletion spec/lib/listen/adapter/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def _process_event(dir, event)
it 'passes invalidates the snapshot based on the event' do
subject.start

expect(snapshot).to receive(:invalidate).with(:file, 'bar', cookie: 3)
expect(snapshot).to receive(:invalidate).with(:file, 'bar', { cookie: 3 })

event = { dir: '/foo/dir1', file: 'bar', type: :moved, cookie: 3 }
subject.fake_event(event)
Expand Down
6 changes: 4 additions & 2 deletions spec/lib/listen/adapter/linux_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,10 @@
expect(snapshot).to receive(:invalidate).with(
:file,
'path/foo.txt',
cookie: 123,
change: change
{
cookie: 123,
change: change
}
)
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/listen/adapter/polling_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

it 'notifies change on every listener directories path' do
expect(snapshot).to receive(:invalidate).
with(:dir, '.', recursive: true)
with(:dir, '.', { recursive: true })

t = Thread.new { subject.start }
sleep 0.25
Expand Down
12 changes: 6 additions & 6 deletions spec/lib/listen/directory_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def fake_children(exception, dir, *args, &block)
expect(snapshot).to receive(:invalidate).with(:file, 'file.rb', {})

expect(snapshot).to receive(:invalidate).
with(:dir, 'subdir', recursive: false)
with(:dir, 'subdir', { recursive: false })

described_class.scan(snapshot, '.', options)
end
Expand All @@ -91,7 +91,7 @@ def fake_children(exception, dir, *args, &block)

it 'notices subdir does not exist' do
expect(snapshot).to receive(:invalidate).
with(:dir, 'subdir', recursive: false)
with(:dir, 'subdir', { recursive: false })

described_class.scan(snapshot, '.', options)
end
Expand Down Expand Up @@ -219,7 +219,7 @@ def fake_children(exception, dir, *args, &block)
expect(snapshot).to receive(:invalidate).with(:file, 'file.rb', {})

expect(snapshot).to receive(:invalidate).
with(:dir, 'subdir', recursive: true)
with(:dir, 'subdir', { recursive: true })

described_class.scan(snapshot, '.', options)
end
Expand All @@ -240,10 +240,10 @@ def fake_children(exception, dir, *args, &block)
expect(snapshot).to receive(:invalidate).with(:file, 'file.rb', {})

expect(snapshot).to receive(:invalidate).
with(:dir, 'subdir', recursive: true)
with(:dir, 'subdir', { recursive: true })

expect(snapshot).to receive(:invalidate).
with(:dir, 'subdir2', recursive: true)
with(:dir, 'subdir2', { recursive: true })

described_class.scan(snapshot, '.', options)
end
Expand Down Expand Up @@ -274,7 +274,7 @@ def fake_children(exception, dir, *args, &block)

it 'snapshots changes for subdir' do
expect(snapshot).to receive(:invalidate).
with(:dir, 'subdir', recursive: true)
with(:dir, 'subdir', { recursive: true })

described_class.scan(snapshot, '.', options)
end
Expand Down
20 changes: 10 additions & 10 deletions spec/lib/listen/listener_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,12 @@
let(:options) { { ignore: /bar/ } }

it 'adds up to existing ignore options' do
expect(silencer).to receive(:configure).once.with(ignore: [/bar/])
expect(silencer).to receive(:configure).once.with({ ignore: [/bar/] })

subject

expect(silencer).to receive(:configure).once.
with(ignore: [/bar/, /foo/])
with({ ignore: [/bar/, /foo/] })

subject.ignore(/foo/)
end
Expand All @@ -260,12 +260,12 @@
let(:options) { { ignore: [/bar/] } }

it 'adds up to existing ignore options' do
expect(silencer).to receive(:configure).once.with(ignore: [/bar/])
expect(silencer).to receive(:configure).once.with({ ignore: [/bar/] })

subject

expect(silencer).to receive(:configure).once.
with(ignore: [/bar/, /foo/])
with({ ignore: [/bar/, /foo/] })

subject.ignore(/foo/)
end
Expand All @@ -287,9 +287,9 @@
let(:options) { { ignore!: /bar/ } }

it 'overwrites existing ignore options' do
expect(silencer).to receive(:configure).once.with(ignore!: [/bar/])
expect(silencer).to receive(:configure).once.with({ ignore!: [/bar/] })
subject
expect(silencer).to receive(:configure).once.with(ignore!: [/foo/])
expect(silencer).to receive(:configure).once.with({ ignore!: [/foo/] })
subject.ignore!([/foo/])
end
end
Expand All @@ -298,9 +298,9 @@
let(:options) { { ignore: /bar/ } }

it 'deletes ignore options' do
expect(silencer).to receive(:configure).once.with(ignore: [/bar/])
expect(silencer).to receive(:configure).once.with({ ignore: [/bar/] })
subject
expect(silencer).to receive(:configure).once.with(ignore!: [/foo/])
expect(silencer).to receive(:configure).once.with({ ignore!: [/foo/] })
subject.ignore!([/foo/])
end
end
Expand All @@ -311,9 +311,9 @@
let(:options) { { only: /bar/ } }

it 'overwrites existing ignore options' do
expect(silencer).to receive(:configure).once.with(only: [/bar/])
expect(silencer).to receive(:configure).once.with({ only: [/bar/] })
subject
expect(silencer).to receive(:configure).once.with(only: [/foo/])
expect(silencer).to receive(:configure).once.with({ only: [/foo/] })
subject.only([/foo/])
end
end
Expand Down
12 changes: 6 additions & 6 deletions spec/lib/listen/silencer/controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,42 +26,42 @@
context 'when providing a single regexp as argument' do
it 'sets the given :ignore rules as array' do
subject
allow(silencer).to receive(:configure).with(ignore: [/foo/])
allow(silencer).to receive(:configure).with({ ignore: [/foo/] })
subject.append_ignores(/foo/)
end
end

context 'when providing multiple arguments' do
it 'sets the given :ignore rules as a flat array' do
subject
allow(silencer).to receive(:configure).with(ignore: [/foo/, /bar/])
allow(silencer).to receive(:configure).with({ ignore: [/foo/, /bar/] })
subject.append_ignores(/foo/, /bar/)
end
end

context 'when providing as array' do
it 'sets the given :ignore rules' do
subject
allow(silencer).to receive(:configure).with(ignore: [/foo/, /bar/])
allow(silencer).to receive(:configure).with({ ignore: [/foo/, /bar/] })
subject.append_ignores([/foo/, /bar/])
end
end
end

context 'with previous :ignore rules' do
subject do
described_class.new(silencer, ignore: [/foo/, /bar/])
described_class.new(silencer, { ignore: [/foo/, /bar/] })
end

before do
allow(silencer).to receive(:configure).with(ignore: [/foo/, /bar/])
allow(silencer).to receive(:configure).with({ ignore: [/foo/, /bar/] })
end

context 'when providing a nil' do
# TODO: should this invocation maybe reset the rules?
it 'reconfigures with existing :ignore rules' do
subject
allow(silencer).to receive(:configure).with(ignore: [/foo/, /bar/])
allow(silencer).to receive(:configure).with({ ignore: [/foo/, /bar/] })
subject.append_ignores(nil)
end
end
Expand Down

0 comments on commit abb90a5

Please sign in to comment.