Sha256: 49e1748e3b2ec65d04c98dea7834fa2f537b08729c798fbdc4943f3f21a7cf88

Contents?: true

Size: 1.83 KB

Versions: 23

Compression:

Stored size: 1.83 KB

Contents

describe Ridgepole::Config do
  subject { Ridgepole::Config.load(config, env) }

  context 'when passed toplevel yaml' do
    let(:config) {
      <<-YAML.strip_heredoc
        adapter: mysql2
        encoding: utf8
        database: blog
        username: root
      YAML
    }
    let(:env) { 'development' }
    it {
      expect(subject['adapter']).to eq "mysql2"
      expect(subject['encoding']).to eq "utf8"
      expect(subject['database']).to eq "blog"
      expect(subject['username']).to eq "root"
    }
  end

  context 'when passed dynamic yaml' do
    let(:config) {
      <<-YAML.strip_heredoc
        adapter: mysql2
        encoding: utf8
        database: blog_<%= 1 + 2 %>
        username: user_<%= 3 * 4 %>
      YAML
    }
    let(:env) { 'development' }
    it {
      expect(subject['adapter']).to eq "mysql2"
      expect(subject['encoding']).to eq "utf8"
      expect(subject['database']).to eq "blog_3"
      expect(subject['username']).to eq "user_12"
    }
  end

  context 'when passed rails database.yml style yaml' do
    let(:config) {
      <<-YAML.strip_heredoc
        development:
          adapter: sqlite
          database: db/sample.db
        production:
          adapter: mysql2
          encoding: utf8
          database: blog
          username: root
      YAML
    }

    context 'in development env' do
      let(:env) { 'development' }
      it {
        expect(subject['adapter']).to eq "sqlite"
        expect(subject['database']).to eq "db/sample.db"
        expect(subject['username']).to be_nil
      }
    end

    context 'in production env' do
      let(:env) { 'production' }
      it {
        expect(subject['adapter']).to eq "mysql2"
        expect(subject['encoding']).to eq "utf8"
        expect(subject['database']).to eq "blog"
        expect(subject['username']).to eq "root"
      }
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
ridgepole-0.5.3.beta spec/cli/config_spec.rb
ridgepole-0.5.2 spec/cli/config_spec.rb
ridgepole-0.5.2.beta6 spec/cli/config_spec.rb
ridgepole-0.5.2.beta5 spec/cli/config_spec.rb
ridgepole-0.5.2.beta4 spec/cli/config_spec.rb
ridgepole-0.5.2.beta3 spec/cli/config_spec.rb
ridgepole-0.5.2.beta2 spec/cli/config_spec.rb
ridgepole-0.5.2.beta spec/cli/config_spec.rb
ridgepole-0.5.1 spec/cli/config_spec.rb
ridgepole-0.5.1.beta3 spec/cli/config_spec.rb
ridgepole-0.5.1.beta2 spec/cli/config_spec.rb
ridgepole-0.5.1.beta spec/cli/config_spec.rb
ridgepole-0.5.0 spec/cli/config_spec.rb
ridgepole-0.5.0.beta spec/cli/config_spec.rb
ridgepole-0.4.12 spec/cli/config_spec.rb
ridgepole-0.4.11.beta spec/cli/config_spec.rb
ridgepole-0.4.10 spec/cli/config_spec.rb
ridgepole-0.4.10.beta spec/cli/config_spec.rb
ridgepole-0.4.9 spec/cli/config_spec.rb
ridgepole-0.4.8 spec/cli/config_spec.rb