Sha256: d4f68f6256a3d7c2af83412515a4e13bd604d6b014ae096411279b80006a4fe2

Contents?: true

Size: 1.34 KB

Versions: 12

Compression:

Stored size: 1.34 KB

Contents

require 'spec_helper'

describe Storey::Utils do

  describe '.command_line_switches_from(hash)' do
    it 'should build command line switches from the hash' do
      hash = {some: 'key',
              pretty: 'cool'}
      expect(described_class.command_line_switches_from(hash)).
        to eq("--some=key --pretty=cool")
    end
  end

  describe '.db_command_line_switches_from(db_config)' do
    subject do
      described_class.db_command_line_switches_from(db_config, extra_config)
    end

    context 'db_config does not have :host' do
      let(:db_config) { {} }
      it { should_not include('--host=') }
    end

    context 'db_config has :host' do
      let(:db_config) { {host: 'localhost'} }
      it { should include('--host=localhost') }
    end

    let(:db_config) do
      {
        database: 'mydb',
        username: 'uname'
      }
    end

    let(:extra_config) do
      {
        extra: 'config',
        'without-arg' => nil
      }
    end

    it 'should set the database' do
      expect(subject).to include('--dbname=mydb')
    end

    it 'should set the username' do
      expect(subject).to include('--username=uname')
    end

    it 'should include extra config' do
      expect(subject).to include('--extra=config')
    end

    it 'should set flag arguments' do
      expect(subject).to match(/--without-arg$/)
    end
  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
storey-2.2.0 spec/storey/utils_spec.rb
storey-2.1.2 spec/storey/utils_spec.rb
storey-2.1.1 spec/storey/utils_spec.rb
storey-2.1.0 spec/storey/utils_spec.rb
storey-2.0.2 spec/storey/utils_spec.rb
storey-2.0.1 spec/storey/utils_spec.rb
storey-2.0.0 spec/storey/utils_spec.rb
storey-1.0.0 spec/storey/utils_spec.rb
storey-0.6.0 spec/storey/utils_spec.rb
storey-0.5.2 spec/storey/utils_spec.rb
storey-0.5.1 spec/storey/utils_spec.rb
storey-0.5.0 spec/storey/utils_spec.rb