Sha256: a9d24ee8e7aece1a6ceccb34c049866934c81ae405a51635cb843e5df8fa363a

Contents?: true

Size: 1.82 KB

Versions: 6

Compression:

Stored size: 1.82 KB

Contents

require 'spec_helper'
require 'uri'

describe EY::Config do
  describe "environments" do
    after { File.unlink('ey.yml') if File.exist?('ey.yml') }

    it "get loaded from the config file" do
      write_yaml({"environments" => {"production" => {"default" => true}}}, 'ey.yml')
      EY::Config.new.environments["production"]["default"].should be_true
    end

    it "are present when the config file has no environments key" do
      write_yaml({}, 'ey.yml')
      EY::Config.new.environments.should == {}
    end

    it "rases an error when yaml produces an unexpected result" do
      File.open('ey.yml', "w") {|f| f << "this isn't a hash" }
      expect { EY::Config.new }.to raise_error(RuntimeError, "ey.yml load error: Expected a Hash but a String was returned.")
    end
  end

  describe "endpoint" do
    it "defaults to production Engine Yard Cloud" do
      EY::Config.new.endpoint.should == EY::Config.new.default_endpoint
    end

    it "loads the endpoint from $CLOUD_URL" do
      ENV['CLOUD_URL'] = "http://fake.local/"
      EY::Config.new.endpoint.should == 'http://fake.local/'
      ENV.delete('CLOUD_URL')
    end
  end

  describe "files" do
    it "looks for config/ey.yml" do
      FileUtils.mkdir_p('config')

      write_yaml({"environments" => {"staging"    => {"default" => true}}}, "ey.yml")
      write_yaml({"environments" => {"production" => {"default" => true}}}, "config/ey.yml")
      EY::Config.new.default_environment.should == "production"

      File.unlink('config/ey.yml') if File.exist?('config/ey.yml')
      File.unlink('ey.yml') if File.exist?('ey.yml')
    end

    it "looks for ey.yml" do
      write_yaml({"environments" => {"staging" => {"default" => true}}}, "ey.yml")

      EY::Config.new.default_environment.should == "staging"

      File.unlink('ey.yml') if File.exist?('ey.yml')
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
engineyard-2.3.2 spec/engineyard/config_spec.rb
engineyard-2.3.1 spec/engineyard/config_spec.rb
engineyard-2.3.0 spec/engineyard/config_spec.rb
engineyard-2.2.1 spec/engineyard/config_spec.rb
engineyard-2.2.0 spec/engineyard/config_spec.rb
engineyard-2.2.0.rc1 spec/engineyard/config_spec.rb