Skip to content

Commit

Permalink
issue #450: linux driver: add :modify to default events listened to
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinDKelley committed Nov 4, 2020
1 parent 26f5848 commit 76d5a00
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/listen/adapter/linux.rb
Expand Up @@ -11,6 +11,7 @@ class Linux < Base
:recursive,
:attrib,
:create,
:modify,
:delete,
:move,
:close_write
Expand Down
26 changes: 25 additions & 1 deletion spec/lib/listen/adapter/linux_spec.rb
Expand Up @@ -12,6 +12,9 @@
end

if linux?
before(:all) do
require 'rb-inotify'
end
let(:dir1) { Pathname.new("/foo/dir1") }

let(:config) { instance_double(Listen::Adapter::Config, "config") }
Expand All @@ -23,12 +26,33 @@
# TODO: fix other adapters too!
subject { described_class.new(config) }

describe 'watch events' do
let(:directories) { [Pathname.pwd] }
let(:adapter_options) { {} }
let(:default_events) { [:recursive, :attrib, :create, :modify, :delete, :move, :close_write] }
let(:fake_worker) { double(:fake_worker) }
let(:fake_notifier) { double(:fake_notifier, new: fake_worker) }

before do
stub_const('INotify::Notifier', fake_notifier)

allow(config).to receive(:directories).and_return(directories)
allow(config).to receive(:adapter_options).and_return(adapter_options)
allow(config).to receive(:queue).and_return(queue)
allow(config).to receive(:silencer).and_return(silencer)
end

it 'starts by calling watch with default events' do
expect(fake_worker).to receive(:watch).with(*directories.map(&:to_s), *default_events)
subject.start
end
end

describe 'inotify limit message' do
let(:directories) { [Pathname.pwd] }
let(:adapter_options) { {} }

before do
require 'rb-inotify'
fake_worker = double(:fake_worker)
allow(fake_worker).to receive(:watch).and_raise(Errno::ENOSPC)

Expand Down

0 comments on commit 76d5a00

Please sign in to comment.