Sha256: 15669cf3b41cd7b8c658d24a7aada7022d38a017948d6cee4ec0fb95cc0ddb75

Contents?: true

Size: 929 Bytes

Versions: 2

Compression:

Stored size: 929 Bytes

Contents

require 'spec_helper'
require 'yaml'

module MyModule
  extend YmlReader

  def self.data
    @yml
  end
  def self.default_directory
    'default_directory'
  end
end

describe YmlReader do
  context "when configuring the yml directory" do
    before(:each) do
      MyModule.yml_directory = nil
    end
    
    it "should store a yml directory" do
      MyModule.yml_directory = 'some_directory'
      MyModule.yml_directory.should == 'some_directory'
    end

    it "should default to a directory specified by the containing class" do
      MyModule.yml_directory.should == 'default_directory'
    end
  end

  context 'when including files' do
    before(:each) do
      MyModule.yml_directory = File.expand_path('data', File.dirname(__FILE__))
    end

    it 'should load data from included yaml' do
      MyModule.load 'with_includes.yml'
      MyModule.data['include_1']['key_1'].should == 'Value 1'
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
yml_reader-0.7 spec/yml_reader/yml_reader_spec.rb
yml_reader-0.6 spec/yml_reader/yml_reader_spec.rb