Sha256: d1b0142b9ffd82ca4355fa529bcdfe328b427f5ea678e33aa96c7f38c2fe66c0

Contents?: true

Size: 1.35 KB

Versions: 15

Compression:

Stored size: 1.35 KB

Contents

# encoding: utf-8
require 'stud/temporary'
require_relative 'spec_helper'

module FileWatch
  describe WatchedFile do
    let(:pathname) { Pathname.new(__FILE__) }

    context 'Given two instances of the same file' do
      it 'their sincedb_keys should equate' do
        wf_key1 = WatchedFile.new(pathname, PathStatClass.new(pathname), Settings.new).sincedb_key
        hash_db = { wf_key1 => 42 }
        wf_key2 = WatchedFile.new(pathname, PathStatClass.new(pathname), Settings.new).sincedb_key
        expect(wf_key1).to eq(wf_key2)
        expect(wf_key1).to eql(wf_key2)
        expect(wf_key1.hash).to eq(wf_key2.hash)
        expect(hash_db[wf_key2]).to eq(42)
      end
    end

    context 'Given a barrage of state changes' do
      it 'only the previous N state changes are remembered' do
        watched_file = WatchedFile.new(pathname, PathStatClass.new(pathname), Settings.new)
        watched_file.ignore
        watched_file.watch
        watched_file.activate
        watched_file.watch
        watched_file.close
        watched_file.watch
        watched_file.activate
        watched_file.unwatch
        watched_file.activate
        watched_file.close
        expect(watched_file.closed?).to be_truthy
        expect(watched_file.recent_states).to eq([:watched, :active, :watched, :closed, :watched, :active, :unwatched, :active])
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
logstash-input-file-4.1.18 spec/filewatch/watched_file_spec.rb
logstash-input-file-4.1.17 spec/filewatch/watched_file_spec.rb
logstash-input-file-4.1.16 spec/filewatch/watched_file_spec.rb
logstash-input-file-4.1.15 spec/filewatch/watched_file_spec.rb
logstash-input-file-4.1.14 spec/filewatch/watched_file_spec.rb
logstash-input-file-4.1.13 spec/filewatch/watched_file_spec.rb
logstash-input-file-4.1.12 spec/filewatch/watched_file_spec.rb
logstash-input-file-4.1.11 spec/filewatch/watched_file_spec.rb
logstash-input-file-4.1.10 spec/filewatch/watched_file_spec.rb
logstash-input-file-4.1.9 spec/filewatch/watched_file_spec.rb
logstash-input-file-4.1.8 spec/filewatch/watched_file_spec.rb
logstash-input-file-4.1.7 spec/filewatch/watched_file_spec.rb
logstash-input-file-4.1.6 spec/filewatch/watched_file_spec.rb
logstash-input-file-4.1.5 spec/filewatch/watched_file_spec.rb
logstash-input-file-4.1.4 spec/filewatch/watched_file_spec.rb