Sha256: e55cfd913efc60bceeeb448333b719ffefeac9392a4acd21c0984882b149815a

Contents?: true

Size: 1.6 KB

Versions: 15

Compression:

Stored size: 1.6 KB

Contents

require 'spec_helper'
require 'hiera/scope'

describe Hiera::Scope do
  describe "#initialize" do
    it "should store the supplied puppet scope" do
      real = {}
      scope = Hiera::Scope.new(real)
      scope.real.should == real
    end
  end

  describe "#[]" do
    it "should treat '' as nil" do
      real = mock
      real.expects(:lookupvar).with("foo").returns("")

      scope = Hiera::Scope.new(real)
      scope["foo"].should == nil
    end

    it "sould return found data" do
      real = mock
      real.expects(:lookupvar).with("foo").returns("bar")

      scope = Hiera::Scope.new(real)
      scope["foo"].should == "bar"
    end

    it "should get calling_class and calling_module from puppet scope" do
      real = mock
      resource = mock
      resource.expects(:name).returns("Foo::Bar").twice

      real.expects(:resource).returns(resource).twice

      scope = Hiera::Scope.new(real)
      scope["calling_class"].should == "foo::bar"
      scope["calling_module"].should == "foo"
    end
  end

  describe "#include?" do
    it "should correctly report missing data" do
      real = mock
      real.expects(:lookupvar).with("foo").returns("")

      scope = Hiera::Scope.new(real)
      scope.include?("foo").should == false
    end

    it "should always return true for calling_class and calling_module" do
      real = mock
      real.expects(:lookupvar).with("calling_class").never
      real.expects(:lookupvar).with("calling_module").never

      scope = Hiera::Scope.new(real)
      scope.include?("calling_class").should == true
      scope.include?("calling_module").should == true
    end
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
librarian-puppet-0.9.9 vendor/gems/ruby/1.9.1/gems/puppet-3.1.0/spec/unit/hiera/scope_spec.rb
puppet-3.1.1 spec/unit/hiera/scope_spec.rb
librarian-puppet-0.9.8 vendor/gems/ruby/1.9.1/gems/puppet-3.1.0/spec/unit/hiera/scope_spec.rb
puppet-3.1.0 spec/unit/hiera/scope_spec.rb
puppet-3.1.0.rc2 spec/unit/hiera/scope_spec.rb
puppet-3.1.0.rc1 spec/unit/hiera/scope_spec.rb
puppet-3.0.2 spec/unit/hiera/scope_spec.rb
puppet-3.0.2.rc3 spec/unit/hiera/scope_spec.rb
puppet-3.0.2.rc2 spec/unit/hiera/scope_spec.rb
puppet-3.0.2.rc1 spec/unit/hiera/scope_spec.rb
puppet-3.0.1 spec/unit/hiera/scope_spec.rb
puppet-3.0.1.rc1 spec/unit/hiera/scope_spec.rb
puppet-3.0.0 spec/unit/hiera/scope_spec.rb
puppet-3.0.0.rc8 spec/unit/hiera/scope_spec.rb
puppet-3.0.0.rc7 spec/unit/hiera/scope_spec.rb