Sha256: 9cc1e9f9613456d67c34c59d8b6665f3ab2cdfd75ec4b44d586f3aac132a11d0
Contents?: true
Size: 1.45 KB
Versions: 4
Compression:
Stored size: 1.45 KB
Contents
require 'spec_helper' describe Glman::ConfigManager do # subject { described_class.new } let(:config_file) { double('config_file') } let(:config) { nil } before(:each) do subject.stub(:config_file).and_return(config_file) File.stub(:exist?).and_return(true) YAML.stub(:load_file).and_return(config) end describe '#get' do describe 'returns empty hash' do it 'when config file missing' do File.stub(:exist?).and_return(false) subject.get.should eq({}) end it 'when raise error on configuration loading' do YAML.stub(:load_file).and_return('bad_data') subject.get.should eq({}) end end describe 'returns configuration as hash' do let(:config) {{ 'test' => 'works' }} it 'when present' do subject.get.should eq config end end end describe '#set' do it 'raise ConfigSetError when argument is not a hash kind' do -> { subject.set('bad_arg') }.should raise_error Glman::ConfigManager::SetConfigError end describe 'save' do let(:config) {{gitlab: {private_token: 'token', url:'test'}}} let(:new_setting) {{new_key: 'test_val'}} let(:updated_config) {config.merge(new_setting)} it 'updated configuration' do subject.should_receive(:get).and_return(config) subject.should_receive(:save_configuration).with(updated_config) subject.set(new_setting) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
glman-0.1.3 | spec/glman/config_manager_spec.rb |
glman-0.1.2 | spec/glman/config_manager_spec.rb |
glman-0.1.1 | spec/glman/config_manager_spec.rb |
glman-0.1.0 | spec/glman/config_manager_spec.rb |