Sha256: b1868f27768a74f654367b465a5fba1d8b81ffe1b71ffceea3649f5aeacbb867

Contents?: true

Size: 1.01 KB

Versions: 12

Compression:

Stored size: 1.01 KB

Contents

require 'test_helper'
require 'robut/storage/yaml_store'

class Robut::Storage::YamlStoreTest < Test::Unit::TestCase

  def setup
    @store = Robut::Storage::YamlStore
    @store.file = new_yaml_file
  end

  def teardown
    File.delete new_yaml_file if File.exists?(new_yaml_file)
  end

  def test_can_write_and_read
    assert_equal 'in the trunk', (@store['junk'] = 'in the trunk')
    assert_equal 'in the trunk', @store['junk']
  end

  def test_load_an_empty_file
    FileUtils.touch(new_yaml_file)
    assert_equal nil, @store['non-exising-key']
  end

  def test_read_from_file
    @store.file = test_yaml_file
    assert_equal 'bar', @store['foo']
  end

  def test_persists_to_file
    @store['pot'] = 'roast'
    assert File.exists?(new_yaml_file)
    yaml = YAML.load_file(new_yaml_file)
    assert_equal 'roast', yaml['pot']
  end

  private

  def test_yaml_file
    File.join(File.dirname(__FILE__), 'yaml_test.yml')
  end

  def new_yaml_file
    File.join(File.dirname(__FILE__), 'new_yaml_test.yml')
  end

end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
sclemmer-robut-0.6.3 test/unit/storage/yaml_store_test.rb
sclemmer-robut-0.6.2 test/unit/storage/yaml_store_test.rb
sclemmer-robut-0.6.1 test/unit/storage/yaml_store_test.rb
sclemmer-robut-0.6.0 test/unit/storage/yaml_store_test.rb
sclemmer-robut-0.5.4 test/unit/storage/yaml_store_test.rb
sclemmer-robut-0.5.3 test/unit/storage/yaml_store_test.rb
sclemmer-robut-0.5.2 test/unit/storage/yaml_store_test.rb
robut-0.5.2 test/unit/storage/yaml_store_test.rb
robut-0.5.1 test/unit/storage/yaml_store_test.rb
robut-0.5.0 test/unit/storage/yaml_store_test.rb
robut-0.4.0 test/unit/storage/yaml_store_test.rb
robut-0.3.0 test/unit/storage/yaml_store_test.rb