Sha256: 23641e15cee4183a76d8e9ba3b76b7fe0f5e41fb26603a9a32db983fd67670b2

Contents?: true

Size: 817 Bytes

Versions: 3

Compression:

Stored size: 817 Bytes

Contents

describe Econfig::YAML do
  let(:backend) { Econfig::YAML.new("config/app.yml").tap(&:init) }
  describe "#get" do
    it "fetches option from yaml config file" do
      backend.get("quox").should == "baz"
    end

    it "returns nil when the option does not exist" do
      backend.get("does_not_exist").should be_nil
    end

    it "returns nil when there is no config file" do
      backend = Econfig::YAML.new("/does/not/exist").tap(&:init)
      backend.get("does_not_exist").should be_nil
    end

    it "evaluates the YAML config as ERB" do
      with_env do
        ENV['ECONFIG_EXAMPLE'] = "onment"
        backend.get("envir").should == "onment"
      end
    end

    def with_env(&block)
      original = ENV.to_hash
      yield if block_given?
    ensure
      ENV.replace(original)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
econfig-1.0.2 spec/yaml_spec.rb
econfig-1.0.1 spec/yaml_spec.rb
econfig-1.0.0 spec/yaml_spec.rb