spec/lib/config_spec.rb in hieracles-0.1.7 vs spec/lib/config_spec.rb in hieracles-0.2.0

- old
+ new

@@ -2,40 +2,64 @@ describe Hieracles::Config do describe '.load' do context 'with an existing file' do let(:options) do - { config: 'spec/files/config.yml', basepath: 'spec/files' } + { + config: 'spec/files/config.yml', + basepath: 'spec/files' + } end + let(:expected) do + { + classpath: File.expand_path('spec/files/farm_modules/%s.pp'), + modulepath: File.expand_path('spec/files/modules'), + hierafile: File.expand_path('spec/files/hiera.yaml') + } + end before { Hieracles::Config.load options } it 'initialize config values' do - expect(Hieracles::Config.classpath).to eq 'farm_modules/%s.pp' - expect(Hieracles::Config.modulepath).to eq 'modules' - expect(Hieracles::Config.hierafile).to eq 'hiera.yaml' + expect(Hieracles::Config.classpath).to eq expected[:classpath] + expect(Hieracles::Config.modulepath).to eq expected[:modulepath] + expect(Hieracles::Config.hierafile).to eq expected[:hierafile] expect(Hieracles::Config.format).to eq 'Console' end end context 'with additional parameters' do let(:hierapath) { 'hiera.yaml' } let(:options) do - { config: 'spec/files/config.yml', basepath: 'spec/files', hierafile: hierapath } + { + config: 'spec/files/config.yml', + basepath: 'spec/files', + hierafile: hierapath + } end + let(:expected) do + { + classpath: File.expand_path('spec/files/farm_modules/%s.pp'), + modulepath: File.expand_path('spec/files/modules'), + hierafile: File.expand_path('spec/files/hiera.yaml') + } + end before { Hieracles::Config.load options } it 'initialize config values' do - expect(Hieracles::Config.classpath).to eq 'farm_modules/%s.pp' - expect(Hieracles::Config.modulepath).to eq 'modules' - expect(Hieracles::Config.hierafile).to eq hierapath + expect(Hieracles::Config.classpath).to eq expected[:classpath] + expect(Hieracles::Config.modulepath).to eq expected[:modulepath] + expect(Hieracles::Config.hierafile).to eq expected[:hierafile] expect(Hieracles::Config.format).to eq 'Console' end end context 'without an existing config file' do let(:options) do - { config: 'spec/files/config_no.yml' } + { + basepath: 'spec/files', + config: 'spec/files/config_no.yml' + } end before do FileUtils.rm(options[:config]) if File.exist? options[:config] Hieracles::Config.load options end @@ -44,10 +68,10 @@ it 'creates a default config file' do expect(File.exist? options[:config]).to be true end it 'initialize config values' do - expect(Hieracles::Config.classpath).to eq 'manifests/classes/%s.pp' + expect(Hieracles::Config.classpath).to eq File.expand_path('spec/files/manifests/classes/%s.pp') end end end describe '.defaultconfig' do