puppetlabs-stdlib/spec/unit/facter/util/puppet_settings_spec.rb
Ashley Penney d65d2354a7 Convert specs to RSpec 2.99.0 syntax with Transpec
This conversion is done by Transpec 2.2.1 with the following command:
    transpec spec/unit

* 53 conversions
    from: obj.should
      to: expect(obj).to

* 19 conversions
    from: == expected
      to: eq(expected)

* 5 conversions
    from: lambda { }.should
      to: expect { }.to

* 2 conversions
    from: be_true
      to: be_truthy

For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-06-04 14:37:45 -04:00

36 lines
1,001 B
Ruby
Executable file

#! /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