blob: 2dd8464e21cff0f266d9d87950b5296cc5c553fe (
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
|
require 'spec_helper'
module Booty
describe BlockSpecification do
let(:sut) { BlockSpecification.new { |item| item == true } }
context "when an item matches" do
it "should return true" do
sut.matches?(true).should be_true
end
end
context "when an item does not match" do
it "should return true" do
sut.matches?(false).should be_false
end
end
describe "or" do
context "when one item matches" do
it "should return true" do
sut.or(BlockSpecification.new {|x| x == false} ).matches?(false).should be_true
end
it "should return true" do
sut.or {|x| x == false} .matches?(false).should be_true
end
end
context "when the other item matches" do
it "should return true" do
sut.or(BlockSpecification.new {|x| x == false} ).matches?(true).should be_true
end
it "should return true" do
sut.or {|x| x == false} .matches?(true).should be_true
end
end
context "when neither item matches" do
it "should return false" do
sut.or(BlockSpecification.new {|x| x == true}).matches?(false).should be_false
end
it "should return false" do
sut.or {|x| x == true}.matches?(false).should be_false
end
end
end
describe "and" do
context "when one item matches" do
it "should return false" do
sut.and(BlockSpecification.new {|x| x == false} ).matches?(false).should be_false
end
it "should return false" do
sut.and {|x| x == false} .matches?(false).should be_false
end
end
context "when the other item matches" do
it "should return false" do
sut.and(BlockSpecification.new {|x| x == false} ).matches?(true).should be_false
end
it "should return false" do
sut.and {|x| x == false} .matches?(true).should be_false
end
end
context "when neither item matches" do
it "should return false" do
sut.and(BlockSpecification.new {|x| x == true}).matches?(false).should be_false
end
it "should return false" do
sut.and {|x| x == true}.matches?(false).should be_false
end
end
context "when both items match" do
it "should return true" do
sut.and(BlockSpecification.new {|x| x == true}).matches?(true).should be_true
end
it "should return true" do
sut.and {|x| x == true}.matches?(true).should be_true
end
end
end
describe "not" do
context "when an item matches" do
it "should return false" do
sut.not.matches?(true).should be_false
end
end
context "when an item does not match" do
it "should return true" do
sut.not.matches?(false).should be_true
end
end
end
end
end
|