spec/lib/hiera_spec.rb in hieracles-0.0.6 vs spec/lib/hiera_spec.rb in hieracles-0.1.0

- old
+ new

@@ -5,20 +5,22 @@ describe '.new' do context 'hiera file not found' do let(:options) { { + config: 'spec/files/config.yml', basepath: 'spec/files', hierafile: 'hiera_no.yaml' } } it 'raises an error' do expect { Hieracles::Hiera.new }.to raise_error(IOError) end end context 'hiera file found' do let(:options) { { + config: 'spec/files/config.yml', basepath: 'spec/files', hierafile: 'hiera.yaml' } } let(:expected){ File.expand_path(File.join(options[:basepath], options[:hierafile])) @@ -30,29 +32,31 @@ end end end - describe '.datadir' do + describe '.datapath' do context 'hiera file do not have a yaml backend' do let(:options) { { + config: 'spec/files/config.yml', basepath: 'spec/files', hierafile: 'hiera_no_yamlbackend.yaml' } } let(:hiera) { Hieracles::Hiera.new } it 'raises an error' do - expect { hiera.datadir }.to raise_error(TypeError) + expect { hiera.datapath }.to raise_error(TypeError) end end context 'hiera file has a yaml backend but dir not found' do let(:options) { { + config: 'spec/files/config.yml', basepath: 'spec/files', hierafile: 'hiera_yamlbackend_notfound.yaml' } } let(:hiera) { Hieracles::Hiera.new } it 'raises an error' do - expect { hiera.datadir }.to raise_error(IOError) + expect { hiera.datapath }.to raise_error(IOError) end end context 'hiera file has a yaml backend' do let(:options) { { @@ -62,19 +66,34 @@ } } let(:hiera) { Hieracles::Hiera.new } let(:expected) { File.expand_path(File.join(Hieracles::Config.basepath, 'params')) } it 'returns params path' do - expect(hiera.datadir).to eq expected + expect(hiera.datapath).to eq expected end end end + describe '.datadir' do + let(:options) { + { + config: 'spec/files/config.yml', + hierafile: 'hiera.yaml', + basepath: 'spec/files' + } + } + let(:hiera) { Hieracles::Hiera.new } + it { expect(hiera.datadir).to eq 'params/' } + end + context "with proper params" do - let(:options) { { - basepath: 'spec/files', - hierafile: 'hiera.yaml' - } } + let(:options) { + { + config: 'spec/files/config.yml', + basepath: 'spec/files', + hierafile: 'hiera.yaml' + } + } let(:hiera) { Hieracles::Hiera.new } describe '.hierarchy' do let(:expected) { [ 'nodes/%{fqdn}',