3
require File.dirname(__FILE__) + '/../../../spec_helper'
5
require 'puppet/provider/confine/true'
7
describe Puppet::Provider::Confine::True do
8
it "should be named :true" do
9
Puppet::Provider::Confine::True.name.should == :true
12
it "should require a value" do
13
lambda { Puppet::Provider::Confine::True.new() }.should raise_error(ArgumentError)
16
describe "when testing values" do
17
before { @confine = Puppet::Provider::Confine::True.new("foo") }
19
it "should use the 'pass?' method to test validity" do
20
@confine.expects(:pass?).with("foo")
24
it "should return true if the value is not false" do
25
@confine.pass?("else").should be_true
28
it "should return false if the value is false" do
29
@confine.pass?(nil).should be_false
32
it "should produce the message that a value is false" do
33
@confine.message("eh").should be_include("false")
37
it "should produce the number of false values when asked for a summary" do
38
@confine = Puppet::Provider::Confine::True.new %w{one two three four}
39
@confine.expects(:pass?).times(4).returns(true).returns(false).returns(true).returns(false)
40
@confine.summary.should == 2
43
it "should summarize multiple instances by summing their summaries" do
44
c1 = mock '1', :summary => 1
45
c2 = mock '2', :summary => 2
46
c3 = mock '3', :summary => 3
48
Puppet::Provider::Confine::True.summarize([c1, c2, c3]).should == 6