spec/lib/node_spec.rb in hieracles-0.2.0 vs spec/lib/node_spec.rb in hieracles-0.2.1
- old
+ new
@@ -5,11 +5,12 @@
let(:options) {
{
config: 'spec/files/config.yml',
hierafile: 'hiera.yaml',
encpath: 'enc',
- basepath: 'spec/files'
+ basepath: 'spec/files',
+ usedb: false
}
}
context "when extra parameters are specified" do
describe '.new' do
@@ -191,19 +192,59 @@
it { expect(node.modules).to eq expected }
end
end
describe '.info' do
- let(:expected) { {
- classes: ['dev'],
- fqdn: 'server.example.com',
- datacenter: 'equinix',
- country: 'fr',
- farm: 'dev'
- } }
- it { expect(node.info).to eq expected }
+ context "without calling puppetd" do
+ let(:expected) { {
+ classes: ['dev'],
+ fqdn: 'server.example.com',
+ datacenter: 'equinix',
+ country: 'fr',
+ farm: 'dev'
+ } }
+ it { expect(node.info).to eq expected }
+ end
end
+ end
+ end
+ context "with calling puppetd" do
+ let(:options) {
+ {
+ config: 'spec/files/config_withdb.yml',
+ hierafile: 'hiera.yaml',
+ encpath: 'enc',
+ basepath: 'spec/files'
+ }
+ }
+ describe '.info' do
+ let(:expected) { {
+ classes: ['dev'],
+ fqdn: 'server.example.com',
+ datacenter: 'equinix',
+ country: 'fr',
+ farm: 'dev',
+ catalog_timestamp: '2015-12-01T23:09:41.540Z'
+ } }
+ let(:resp_info) {
+ Hieracles::Puppetdb::Response.new({ catalog_timestamp: '2015-12-01T23:09:41.540Z'}, 1)
+ }
+ let(:resp_facts) {
+ Hieracles::Puppetdb::Response.new([{ 'name' => 'datacenter', 'value' => 'tahiti' }], 1)
+ }
+ let(:node) { Hieracles::Node.new 'server.example.com', options }
+ before {
+ allow_any_instance_of(Hieracles::Puppetdb::Client).
+ to receive(:request).
+ with("nodes/server.example.com").
+ and_return(resp_info)
+ allow_any_instance_of(Hieracles::Puppetdb::Client).
+ to receive(:request).
+ with("nodes/server.example.com/facts").
+ and_return(resp_facts)
+ }
+ it { expect(node.info).to eq expected }
end
end
context "when parameters include double-column variables" do
let(:options) {