Sha256: 0a88b1627fd9179dc53b9e89f8390b3f16c4de52906b0a1d7c211232983a5d88

Contents?: true

Size: 1.35 KB

Versions: 5

Compression:

Stored size: 1.35 KB

Contents

require File.expand_path('spec/spec_helper')
require './lib/yaml_properties'

describe YamlProperties do
  context "in general" do
    before do
      File.stub(:open)

      YAML.stub(:load).and_return properties
    end

    let(:properties) do
      {
        "life_the_universe_and_everything" => 42,
        "some_string_value"                => "something",
        "a boolean"                        => true,
        "parent"                           => {
         "child"=>"Egg"}
      }
    end

    specify do
      YamlProperties.properties.should == properties
    end
    specify do
      YamlProperties.life_the_universe_and_everything.should == 42
    end

    specify do
      YamlProperties.some_string_value.should == "something"
    end

    specify do
      YamlProperties.send("a boolean").should == true
    end

    specify do
      YamlProperties.parent.should == {"child" => "Egg"}
    end

    context "extending a module" do
      module Acme
        extend YamlProperties
      end

      specify do
        Acme.life_the_universe_and_everything.should == 42
      end
    end
  end

  context "overriding yaml_file default" do
    module Mystery
      extend YamlProperties

      def self.yaml_file
        "./spec/test.yml"
      end
    end

    specify do
      Mystery.life_the_universe_and_everything.should == "Nobody knows"
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
yaml_properties-0.0.5 spec/yaml_config_spec.rb
yaml_properties-0.0.4 spec/yaml_config_spec.rb
yaml_properties-0.0.3 spec/yaml_config_spec.rb
yaml_properties-0.0.2 spec/yaml_config_spec.rb
yaml_properties-0.0.1 spec/yaml_config_spec.rb