Sha256: 135333ba118ebdea801249518671518faa9c6b01bcd30ce2c05070332329edb8

Contents?: true

Size: 1023 Bytes

Versions: 1

Compression:

Stored size: 1023 Bytes

Contents

require "massive_sitemap/lock"

describe MassiveSitemap do
  describe "lock!" do
    let(:lock_file) { MassiveSitemap::LOCK_FILE }

    after do
      FileUtils.rm(lock_file) rescue nil
    end

    it 'does nothing without block' do
      MassiveSitemap.lock!
      ::File.exists?(lock_file).should be_false
    end

    it 'creates lockfile' do
      File.exists?(lock_file).should be_false
      MassiveSitemap.lock! do
        ::File.exists?(lock_file).should be_true
      end
    end

    it 'deletes lockfile' do
      MassiveSitemap.lock! {}
      ::File.exists?(lock_file).should be_false
    end

    it 'deletes lockfile in case of error' do
      expect do
        MassiveSitemap.lock! do
          raise ArgumentError
        end
      end.to raise_error
      ::File.exists?(lock_file).should be_false
    end

    it 'fails if lockfile exists' do
      ::File.open(lock_file, 'w',) {}
      expect do
        MassiveSitemap.lock! do
          puts "Hi"
        end
      end.to raise_error
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
massive_sitemap-2.0.0.rc4 spec/lock_spec.rb