blob: da4faca4ecc1d9053e6aeaf5fbfb177f08803801 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
require File.dirname(__FILE__) + '/../spec_helper'
describe PuppetTest::RunnableTest do
before do
@runnable_test = Class.new.extend(PuppetTest::RunnableTest)
end
describe "#confine" do
subject { @runnable_test }
it "should accept a hash" do
subject.confine({}).should_not raise_error(ArgumentError)
end
it "should accept a message and a block" do
subject.confine(""){}.should_not raise_error(ArgumentError)
end
end
describe "#runnable?" do
describe "when the superclass is not runnable" do
before { @runnable_test.stubs(:superclass).returns(stub("unrunnable superclass", :runnable? => false)) }
subject { @runnable_test.runnable? }
it { should be_false }
end
describe "when a confine is false" do
before { @runnable_test.confine(:message => false) }
subject { @runnable_test.runnable? }
it { should be_false }
end
describe "when a confine has a block that returns false" do
before { @runnable_test.confine(:message){ false } }
subject { @runnable_test.runnable? }
it { should be_false }
end
describe "when a confine is true and no false confines" do
before { @runnable_test.confine(:message => true) }
subject { @runnable_test.runnable? }
it { should be_true }
end
describe "when a confine has block that returns true and no false confines" do
before { @runnable_test.confine(:message){ true } }
subject { @runnable_test.runnable? }
it { should be_true }
end
end
describe "#messages" do
describe "before runnable? is called" do
subject { @runnable_test.messages }
it { should == [] }
end
describe "when runnable? is called and returns false" do
before do
@runnable_test.confine(:message => false)
@runnable_test.runnable?
end
subject { @runnable_test.messages }
it "should include the failed confine's message" do
should include(:message)
end
end
describe "when runnable? is called whose block returns false" do
before do
@runnable_test.confine(:message){ false }
@runnable_test.runnable?
end
subject { @runnable_test.messages }
it "should include the failed confine's message" do
should include(:message)
end
end
end
end
|