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

- old
+ new

@@ -1,20 +1,20 @@ require 'spec_helper' describe Hieracles::Hiera do - before { Hieracles::Config.load(options) } describe '.new' do context 'hiera file not found' do - let(:options) { { + let(:options) { { + basepath: 'spec/files', 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) + expect { Hieracles::Config.load(options) }.to raise_error(IOError) end end context 'hiera file found' do let(:options) { { @@ -24,19 +24,21 @@ } } let(:expected){ File.expand_path(File.join(options[:basepath], options[:hierafile])) } let(:hiera) { Hieracles::Hiera.new } + before { Hieracles::Config.load(options) } it 'load the file' do expect(hiera.instance_variable_get :@loaded).to be_a Hash expect(hiera.instance_variable_get :@hierafile).to eq expected end end end describe '.datapath' do + before { Hieracles::Config.load(options) } 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' @@ -72,10 +74,11 @@ end end end describe '.datadir' do + before { Hieracles::Config.load(options) } let(:options) { { config: 'spec/files/config.yml', hierafile: 'hiera.yaml', basepath: 'spec/files' @@ -84,9 +87,10 @@ let(:hiera) { Hieracles::Hiera.new } it { expect(hiera.datadir).to eq 'params/' } end context "with proper params" do + before { Hieracles::Config.load(options) } let(:options) { { config: 'spec/files/config.yml', basepath: 'spec/files', hierafile: 'hiera.yaml'