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
|
require File.dirname(__FILE__) + '/../../spec_helper'
require 'mspec/runner/mspec'
require 'mspec/runner/filters/match'
require 'mspec/runner/filters/tag'
describe TagFilter, "#load" do
before :each do
@match = double("match filter").as_null_object
@filter = TagFilter.new :include, "tag", "key"
@tag = SpecTag.new "tag(comment):description"
MSpec.stub(:read_tags).and_return([@tag])
MSpec.stub(:register)
end
it "loads tags from the tag file" do
MSpec.should_receive(:read_tags).with(["tag", "key"]).and_return([])
@filter.load
end
it "registers itself with MSpec for the :include action" do
filter = TagFilter.new(:include)
MSpec.should_receive(:register).with(:include, filter)
filter.load
end
it "registers itself with MSpec for the :exclude action" do
filter = TagFilter.new(:exclude)
MSpec.should_receive(:register).with(:exclude, filter)
filter.load
end
end
describe TagFilter, "#unload" do
before :each do
@filter = TagFilter.new :include, "tag", "key"
@tag = SpecTag.new "tag(comment):description"
MSpec.stub(:read_tags).and_return([@tag])
MSpec.stub(:register)
end
it "unregisters itself" do
@filter.load
MSpec.should_receive(:unregister).with(:include, @filter)
@filter.unload
end
end
describe TagFilter, "#register" do
before :each do
MSpec.stub(:register)
end
it "registers itself with MSpec for the :load, :unload actions" do
filter = TagFilter.new(nil)
MSpec.should_receive(:register).with(:load, filter)
MSpec.should_receive(:register).with(:unload, filter)
filter.register
end
end
describe TagFilter, "#unregister" do
before :each do
MSpec.stub(:unregister)
end
it "unregisters itself with MSpec for the :load, :unload actions" do
filter = TagFilter.new(nil)
MSpec.should_receive(:unregister).with(:load, filter)
MSpec.should_receive(:unregister).with(:unload, filter)
filter.unregister
end
end
describe TagFilter, "#===" do
before :each do
@filter = TagFilter.new nil, "tag", "key"
@tag = SpecTag.new "tag(comment):description"
MSpec.stub(:read_tags).and_return([@tag])
MSpec.stub(:register)
@filter.load
end
it "returns true if the argument matches any of the descriptions" do
@filter.===('description').should == true
end
it "returns false if the argument matches none of the descriptions" do
@filter.===('descriptionA').should == false
@filter.===('adescription').should == false
end
end
|