Sha256: d8e1982fa6f2ecc31cead9fea2e07eea44a4fc350f4db322a840e38fa727be7f

Contents?: true

Size: 824 Bytes

Versions: 1

Compression:

Stored size: 824 Bytes

Contents

require 'helper'
require 'tempfile'

describe ProperProperties do
  subject{ ProperProperties }

  it "parses from string" do
    subject.parse("item1=item1").must_equal({:item1 => "item1"})
  end

  it "generates from hash" do
    subject.generate({:item1 => "item1"}).must_equal("item1=item1")
  end

  it "loads from file" do
    with_temp_file do |file|
      file << "item1=item1"
      file.flush

      subject.load(file.path).must_equal({:item1 => "item1"})
    end
  end

  it "writes to file" do
    with_temp_file do |file|      
      subject.write({:item1 => "item1"}, file.path)

      file.rewind
      file.read.must_equal "item1=item1"
    end
  end

  private

  def with_temp_file(&block)
    file = Tempfile.new("proper_properties")
    block.call(file)
  ensure
    file.close
    file.unlink
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
proper_properties-0.0.1 spec/proper_properties_spec.rb