~ubuntu-branches/ubuntu/oneiric/puppet/oneiric-security

« back to all changes in this revision

Viewing changes to spec/unit/provider/confine/true.rb

  • Committer: Bazaar Package Importer
  • Author(s): Micah Anderson
  • Date: 2008-07-26 15:43:45 UTC
  • mto: (3.1.1 lenny) (1.3.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: james.westby@ubuntu.com-20080726154345-1fmgo76b4l72ulvc
ImportĀ upstreamĀ versionĀ 0.24.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env ruby
 
2
 
 
3
require File.dirname(__FILE__) + '/../../../spec_helper'
 
4
 
 
5
require 'puppet/provider/confine/true'
 
6
 
 
7
describe Puppet::Provider::Confine::True do
 
8
    it "should be named :true" do
 
9
        Puppet::Provider::Confine::True.name.should == :true
 
10
    end
 
11
 
 
12
    it "should require a value" do
 
13
        lambda { Puppet::Provider::Confine::True.new() }.should raise_error(ArgumentError)
 
14
    end
 
15
 
 
16
    describe "when testing values" do
 
17
        before { @confine = Puppet::Provider::Confine::True.new("foo") }
 
18
 
 
19
        it "should use the 'pass?' method to test validity" do
 
20
            @confine.expects(:pass?).with("foo")
 
21
            @confine.valid?
 
22
        end
 
23
 
 
24
        it "should return true if the value is not false" do
 
25
            @confine.pass?("else").should be_true
 
26
        end
 
27
 
 
28
        it "should return false if the value is false" do
 
29
            @confine.pass?(nil).should be_false
 
30
        end
 
31
 
 
32
        it "should produce the message that a value is false" do
 
33
            @confine.message("eh").should be_include("false")
 
34
        end
 
35
    end
 
36
 
 
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
 
41
    end
 
42
 
 
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
 
47
 
 
48
        Puppet::Provider::Confine::True.summarize([c1, c2, c3]).should == 6
 
49
    end
 
50
end