Sha256: 90c5020b971343cab47f635de88a84376d15925563d41d6059c2d85979f36d62

Contents?: true

Size: 769 Bytes

Versions: 14

Compression:

Stored size: 769 Bytes

Contents

require 'spec_helper'

require 'vagrant-notify/data'

describe Vagrant::Notify::Data do
  let!(:data_dir) { Pathname.new(Dir.mktmpdir) }
  let(:key)       { :pid }
  let(:value)     { '123456' }

  subject { described_class.new(data_dir) }

  after { FileUtils.rm_rf data_dir.to_s }

  it 'writes data out to a file' do
    subject[key] = value

    data_dir.join(key.to_s).read.should eq value
  end

  it 'reads data from files' do
    data_dir.join(key.to_s).open('w+') { |f| f.write(value) }

    subject[key].should eq value
  end

  it 'handles unset keys' do
    subject[key].should be_nil
  end

  it 'removes the file when a value is set to nil' do
    subject.tap { |s| s[key] = value; s[key] = nil }

    data_dir.join(key.to_s).should_not be_file
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
vagrant-notify-0.6.1 spec/data_spec.rb
vagrant-notify-0.6.0 spec/data_spec.rb
vagrant-notify-0.5.6 spec/data_spec.rb
vagrant-notify-0.5.5 spec/data_spec.rb
vagrant-notify-0.5.4 spec/data_spec.rb
vagrant-notify-0.5.3 spec/data_spec.rb
vagrant-notify-0.5.2 spec/data_spec.rb
vagrant-notify-0.5.1 spec/data_spec.rb
vagrant-notify-0.5.0 spec/data_spec.rb
vagrant-notify-0.4.0 spec/data_spec.rb
vagrant-notify-0.3.0 spec/data_spec.rb
vagrant-notify-0.2.2 spec/data_spec.rb
vagrant-notify-0.2.1 spec/data_spec.rb
vagrant-notify-0.2.0 spec/data_spec.rb