X-Git-Url: https://git.donarmstrong.com/?p=dsa-puppet.git;a=blobdiff_plain;f=3rdparty%2Fmodules%2Fstdlib%2Fspec%2Funit%2Ffacter%2Futil%2Fpuppet_settings_spec.rb;fp=3rdparty%2Fmodules%2Fstdlib%2Fspec%2Funit%2Ffacter%2Futil%2Fpuppet_settings_spec.rb;h=c06137d7e2a93c0a7176fd5d6720f1c2f9c0a700;hp=0000000000000000000000000000000000000000;hb=ad88f67c13ae0f1a08936dad643f1e3509ab5f40;hpb=23d29143ac40015ce61cf83a4067466f8f7d66dc diff --git a/3rdparty/modules/stdlib/spec/unit/facter/util/puppet_settings_spec.rb b/3rdparty/modules/stdlib/spec/unit/facter/util/puppet_settings_spec.rb new file mode 100755 index 00000000..c06137d7 --- /dev/null +++ b/3rdparty/modules/stdlib/spec/unit/facter/util/puppet_settings_spec.rb @@ -0,0 +1,36 @@ +#! /usr/bin/env ruby -S rspec +require 'spec_helper' +require 'facter/util/puppet_settings' + +describe Facter::Util::PuppetSettings do + + describe "#with_puppet" do + context "Without Puppet loaded" do + before(:each) do + Module.expects(:const_get).with("Puppet").raises(NameError) + end + + it 'should be nil' do + expect(subject.with_puppet { Puppet[:vardir] }).to be_nil + end + it 'should not yield to the block' do + Puppet.expects(:[]).never + expect(subject.with_puppet { Puppet[:vardir] }).to be_nil + end + end + context "With Puppet loaded" do + module Puppet; end + let(:vardir) { "/var/lib/puppet" } + + before :each do + Puppet.expects(:[]).with(:vardir).returns vardir + end + it 'should yield to the block' do + subject.with_puppet { Puppet[:vardir] } + end + it 'should return the nodes vardir' do + expect(subject.with_puppet { Puppet[:vardir] }).to eq vardir + end + end + end +end