Sha256: 39d8c7333e493a446ef2969bbf942f006ea323b22a0d3771f2fefd3b70f20708

Contents?: true

Size: 1.85 KB

Versions: 19

Compression:

Stored size: 1.85 KB

Contents

#!/usr/bin/env ruby

require File.dirname(__FILE__) + '/../../spec_helper'

require 'puppet/provider/confiner'

describe Puppet::Provider::Confiner do
  before do
    @object = Object.new
    @object.extend(Puppet::Provider::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::Provider::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

19 entries across 19 versions & 1 rubygems

Version Path
puppet-2.6.18 spec/unit/provider/confiner_spec.rb
puppet-2.6.17 spec/unit/provider/confiner_spec.rb
puppet-2.6.16 spec/unit/provider/confiner_spec.rb
puppet-2.6.15 spec/unit/provider/confiner_spec.rb
puppet-2.6.14 spec/unit/provider/confiner_spec.rb
puppet-2.6.13 spec/unit/provider/confiner_spec.rb
puppet-2.6.12 spec/unit/provider/confiner_spec.rb
puppet-2.6.11 spec/unit/provider/confiner_spec.rb
puppet-2.6.10 spec/unit/provider/confiner_spec.rb
puppet-2.6.9 spec/unit/provider/confiner_spec.rb
puppet-2.6.8 spec/unit/provider/confiner_spec.rb
puppet-2.6.7 spec/unit/provider/confiner_spec.rb
puppet-2.6.6 spec/unit/provider/confiner_spec.rb
puppet-2.6.5 spec/unit/provider/confiner_spec.rb
puppet-2.6.4 spec/unit/provider/confiner_spec.rb
puppet-2.6.3 spec/unit/provider/confiner_spec.rb
puppet-2.6.2 spec/unit/provider/confiner_spec.rb
puppet-2.6.1 spec/unit/provider/confiner_spec.rb
puppet-2.6.0 spec/unit/provider/confiner_spec.rb