Sha256: 169381266f87f219118399981c5113116c0a84a92a9bfcfe051d4c71b06f6b2e

Contents?: true

Size: 1.78 KB

Versions: 63

Compression:

Stored size: 1.78 KB

Contents

#! /usr/bin/env ruby
require 'spec_helper'

require 'puppet/confiner'

describe Puppet::Confiner do
  before do
    @object = Object.new
    @object.extend(Puppet::Confiner)
  end

  it "should have a method for defining confines" do
    @object.should respond_to(:confine)
  end

  it "should have a method for returning its confine collection" do
    @object.should respond_to(:confine_collection)
  end

  it "should have a method for testing suitability" do
    @object.should respond_to(:suitable?)
  end

  it "should delegate its confine method to its confine collection" do
    coll = mock 'collection'
    @object.stubs(:confine_collection).returns coll
    coll.expects(:confine).with(:foo => :bar, :bee => :baz)
    @object.confine(:foo => :bar, :bee => :baz)
  end

  it "should create a new confine collection if one does not exist" do
    Puppet::ConfineCollection.expects(:new).with("mylabel").returns "mycoll"
    @object.expects(:to_s).returns "mylabel"
    @object.confine_collection.should == "mycoll"
  end

  it "should reuse the confine collection" do
    @object.confine_collection.should equal(@object.confine_collection)
  end

  describe "when testing suitability" do
    before do
      @coll = mock 'collection'
      @object.stubs(:confine_collection).returns @coll
    end

    it "should return true if the confine collection is valid" do
      @coll.expects(:valid?).returns true
      @object.should be_suitable
    end

    it "should return false if the confine collection is invalid" do
      @coll.expects(:valid?).returns false
      @object.should_not be_suitable
    end

    it "should return the summary of the confine collection if a long result is asked for" do
      @coll.expects(:summary).returns "myresult"
      @object.suitable?(false).should == "myresult"
    end
  end
end

Version data entries

63 entries across 63 versions & 1 rubygems

Version Path
puppet-3.8.7 spec/unit/confiner_spec.rb
puppet-3.8.7-x86-mingw32 spec/unit/confiner_spec.rb
puppet-3.8.7-x64-mingw32 spec/unit/confiner_spec.rb
puppet-3.8.6 spec/unit/confiner_spec.rb
puppet-3.8.6-x86-mingw32 spec/unit/confiner_spec.rb
puppet-3.8.6-x64-mingw32 spec/unit/confiner_spec.rb
puppet-3.8.5 spec/unit/confiner_spec.rb
puppet-3.8.5-x86-mingw32 spec/unit/confiner_spec.rb
puppet-3.8.5-x64-mingw32 spec/unit/confiner_spec.rb
puppet-3.8.4 spec/unit/confiner_spec.rb
puppet-3.8.4-x86-mingw32 spec/unit/confiner_spec.rb
puppet-3.8.4-x64-mingw32 spec/unit/confiner_spec.rb
puppet-3.8.3 spec/unit/confiner_spec.rb
puppet-3.8.3-x86-mingw32 spec/unit/confiner_spec.rb
puppet-3.8.3-x64-mingw32 spec/unit/confiner_spec.rb
puppet-3.8.2 spec/unit/confiner_spec.rb
puppet-3.8.2-x86-mingw32 spec/unit/confiner_spec.rb
puppet-3.8.2-x64-mingw32 spec/unit/confiner_spec.rb
puppet-3.8.1 spec/unit/confiner_spec.rb
puppet-3.8.1-x86-mingw32 spec/unit/confiner_spec.rb