spec/lib/hiera_spec.rb in hieracles-0.3.0 vs spec/lib/hiera_spec.rb in hieracles-0.3.1
- old
+ new
@@ -9,11 +9,11 @@
basepath: 'spec/files',
config: 'spec/files/config.yml',
hierafile: 'hiera_no.yaml'
} }
it 'raises an error' do
- expect { Hieracles::Config.load(options) }.to raise_error(IOError)
+ expect { Hieracles::Config.new(options) }.to raise_error(IOError)
end
end
context 'hiera file found' do
let(:options) { {
@@ -22,40 +22,39 @@
hierafile: 'hiera.yaml'
} }
let(:expected){
File.expand_path(File.join(options[:basepath], options[:hierafile]))
}
- let(:hiera) { Hieracles::Hiera.new }
- before { Hieracles::Config.load(options) }
+ let(:config) { Hieracles::Config.new options }
+ let(:hiera) { Hieracles::Hiera.new config }
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) }
+ let(:config) { Hieracles::Config.new options }
+ let(:hiera) { Hieracles::Hiera.new config }
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.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.datapath }.to raise_error(IOError)
end
end
context 'hiera file has a yaml backend' do
@@ -64,40 +63,39 @@
config: 'spec/files/config.yml',
hierafile: 'hiera.yaml',
basepath: 'spec/files'
}
}
- let(:hiera) { Hieracles::Hiera.new }
- let(:expected) { File.expand_path(File.join(Hieracles::Config.basepath, 'params')) }
+ let(:expected) { File.expand_path(File.join(config.basepath, 'params')) }
it 'returns params path' do
expect(hiera.datapath).to eq expected
end
end
end
describe '.datadir' do
- before { Hieracles::Config.load(options) }
let(:options) {
{
config: 'spec/files/config.yml',
hierafile: 'hiera.yaml',
basepath: 'spec/files'
}
}
- let(:hiera) { Hieracles::Hiera.new }
+ let(:config) { Hieracles::Config.new options }
+ let(:hiera) { Hieracles::Hiera.new config }
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'
}
}
- let(:hiera) { Hieracles::Hiera.new }
+ let(:config) { Hieracles::Config.new options }
+ let(:hiera) { Hieracles::Hiera.new config }
describe '.hierarchy' do
let(:expected) { [
'nodes/%{fqdn}',
'farm_datacenter/%{farm}_%{datacenter}',