Sha256: 5fa69f26bf378f8dd5e62593788383a942084cb50591436c78b6065fa1bb6d59

Contents?: true

Size: 1.43 KB

Versions: 8

Compression:

Stored size: 1.43 KB

Contents

require 'spec_helper'

describe Listen::Adapter::Base do
  let(:adapter) { described_class.new(listener) }
  let(:listener) { double(Listen::Listener, options: {}) }

  describe "#_latency" do
    it "returns default_latency with listener actor latency not present" do
      expect(adapter.send(:_latency)).to eq Listen::Adapter::Base::DEFAULT_LATENCY
    end

    it "returns latency from listener actor if present" do
      listener.stub(:options) { { latency: 1234 } }
      expect(adapter.send(:_latency)).to eq 1234
    end
  end

  describe "#_notify_change" do
    let(:change_pool) { double(Listen::Change) }
    let(:change_pool_async) { double('ChangePoolAsync') }
    before {
      change_pool.stub(:async) { change_pool_async }
      Celluloid::Actor.stub(:[]).with(:listen_change_pool) { change_pool }
    }

    context "listener listen" do
      before { listener.stub(:listen?) { true} }

      it "calls change on change_pool asynchronously" do
        expect(change_pool_async).to receive(:change).with('path', type: 'Dir', recurcise: true)
        adapter.send(:_notify_change, 'path', type: 'Dir', recurcise: true)
      end
    end

    context "listener doesn't listen" do
      before { listener.stub(:listen?) { false } }

      it "calls change on change_pool asynchronously" do
        expect(change_pool_async).to_not receive(:change)
        adapter.send(:_notify_change, 'path', type: 'Dir', recurcise: true)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
listen-2.2.0 spec/lib/listen/adapter/base_spec.rb
listen-2.1.2 spec/lib/listen/adapter/base_spec.rb
listen-2.1.1 spec/lib/listen/adapter/base_spec.rb
listen-2.1.0 spec/lib/listen/adapter/base_spec.rb
listen-2.0.4 spec/lib/listen/adapter/base_spec.rb
listen-2.0.3 spec/lib/listen/adapter/base_spec.rb
listen-2.0.2 spec/lib/listen/adapter/base_spec.rb
listen-2.0.1 spec/lib/listen/adapter/base_spec.rb