Sha256: 1eade4490eeb6a6a7c951af351ddb81447a0ccb6bf84d32829b7eb6c37cdb2b5
Contents?: true
Size: 1.57 KB
Versions: 6
Compression:
Stored size: 1.57 KB
Contents
require_relative 'spec_helper' require 'cliutils/messaging' require 'cliutils/configuration' require 'cliutils/configurator' describe CLIUtils::Configuration do include CLIUtils::Configuration let(:config_path_new) { File.expand_path('support/configuration2.yaml') } let(:config_path_existing) { File.expand_path('support/configuration.yaml') } let(:existing_data) { { my_app: { config_location: '/Users/bob/.my-app-config', log_level: 'WARN', version: '1.0.0' }, user_data: { username: 'bob', age: 45 } } } it 'raises an exception if not loaded properly' do m = 'Attempted to access `configuration` before executing `load_configuration`' expect { configuration }.to raise_error(RuntimeError, m) end it 'returns the same Configurator each time' do load_configuration(config_path_new) c1 = configuration c2 = configuration expect(c1).to eq(c2) end it 'initializies configuration from scratch' do load_configuration(config_path_new) expect(configuration.class).to eq(CLIUtils::Configurator) expect(configuration.config_path).to eq(config_path_new) expect(configuration.data).to eq({}) end it 'works with existing configuration data' do load_configuration(config_path_existing) expect(configuration.class).to eq(CLIUtils::Configurator) expect(configuration.config_path).to eq(config_path_existing) expect(configuration.data).to eq(existing_data) end end
Version data entries
6 entries across 6 versions & 1 rubygems