Sha256: 887bea70cc54f9c630adfe93c7379827239c5a70107d1404a4079cc68bb5b98c

Contents?: true

Size: 765 Bytes

Versions: 11

Compression:

Stored size: 765 Bytes

Contents

#
# Specifying rufus-scheduler
#
# Sat Aug 16 05:43:06 JST 2014
# added by @ecin
#

require 'spec_helper'


describe Rufus::Scheduler::FileLock do

  before :each do

    @lock_path = '.rufus-scheduler.lock'
    @lock = Rufus::Scheduler::FileLock.new(@lock_path)
  end

  after :each do

    FileUtils.rm_f(@lock_path)
    FileUtils.rm_f('lock.txt')
  end

  context ':scheduler_lock => Rufus::Scheduler::FileLock.new(path)' do

    it 'writes down a .rufus-scheduler.lock file' do

      @lock.lock

      line = File.read(@lock_path)

      expect(line).to match(/pid: #{$$}/)
    end

    it '"flocks" the lock file' do

      @lock.lock

      f = File.new(@lock_path, 'a')

      expect(f.flock(File::LOCK_NB | File::LOCK_EX)).to eq(false)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
rufus-scheduler-3.1.9 spec/lock_flock_spec.rb
rufus-scheduler-3.1.8 spec/lock_flock_spec.rb
rufus-scheduler-3.1.7 spec/lock_flock_spec.rb
rufus-scheduler-3.1.6 spec/lock_flock_spec.rb
rufus-scheduler-3.1.5 spec/lock_flock_spec.rb
rufus-scheduler-3.1.4 spec/lock_flock_spec.rb
rufus-scheduler-3.1.3 spec/lock_flock_spec.rb
rufus-scheduler-3.1.2 spec/lock_flock_spec.rb
rufus-scheduler-3.1.1 spec/lock_flock_spec.rb
rufus-scheduler-3.1.0 spec/lock_flock_spec.rb
rufus-scheduler-3.0.9 spec/lock_flock_spec.rb