Sha256: 1d7e2d3d4eb3c50716d88ba9ca50436f59e18353e77a3e8cf5b22fec9b69ba63

Contents?: true

Size: 1.42 KB

Versions: 2

Compression:

Stored size: 1.42 KB

Contents

require 'fileutils'
require 'helper'

describe TomatoHarvest::Config do

  describe '.load' do

    let(:global_options) do
      {
        project: 'Project',
        type:    'Ruby Development',
      }
    end

    before do
      path = TomatoHarvest::Config.config_path(TomatoHarvest::Config::GLOBAL_DIR)
      create_yaml_file(path, global_options)
    end

    it 'loads from the yaml config file' do
      expect(TomatoHarvest::Config.load).to eql(global_options)
    end

    context 'when there is a config file in the current dir' do

      it 'overrides global config' do
        options = {
          type:    'JS Development',
        }

        path = TomatoHarvest::Config.config_path(TomatoHarvest::Config::LOCAL_DIR)
        create_yaml_file(path, options)

        expected = global_options.merge(options)

        expect(TomatoHarvest::Config.load).to eql(expected)
      end

    end

    context 'when there is an old config file' do

      let(:old_config) do
        {
          domain: 'fake.domain.name'
        }
      end

      it 'loads it' do
        old_config_path = File.join(TomatoHarvest::Config::HOME_DIR, '.tomaconfig')
        expanded_path = File.expand_path(old_config_path)
        create_yaml_file(expanded_path, old_config)

        expected = old_config.merge(global_options)
        expect(TomatoHarvest::Config.load).to eql(expected)

        File.delete(old_config_path)
      end

    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tomatoharvest-0.1.1 spec/lib/tomatoharvest/config_spec.rb
tomatoharvest-0.1.0 spec/lib/tomatoharvest/config_spec.rb