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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
require 'spec_helper'
require 'mspec/runner/mspec'
require 'mspec/runner/filters/tag'
require 'mspec/commands/mspec-ci'
describe MSpecCI, "#options" do
before :each do
@options, @config = new_option
MSpecOptions.stub(:new).and_return(@options)
@script = MSpecCI.new
@script.stub(:config).and_return(@config)
@script.stub(:files).and_return([])
end
it "enables the chdir option" do
@options.should_receive(:chdir)
@script.options
end
it "enables the prefix option" do
@options.should_receive(:prefix)
@script.options
end
it "enables the config option" do
@options.should_receive(:configure)
@script.options
end
it "provides a custom action (block) to the config option" do
@script.should_receive(:load).with("cfg.mspec")
@script.options ["-B", "cfg.mspec"]
end
it "enables the dry run option" do
@options.should_receive(:pretend)
@script.options
end
it "enables the unguarded option" do
@options.should_receive(:unguarded)
@script.options
end
it "enables the interrupt single specs option" do
@options.should_receive(:interrupt)
@script.options
end
it "enables the formatter options" do
@options.should_receive(:formatters)
@script.options
end
it "enables the verbose option" do
@options.should_receive(:verbose)
@script.options
end
it "enables the action options" do
@options.should_receive(:actions)
@script.options
end
it "enables the action filter options" do
@options.should_receive(:action_filters)
@script.options
end
it "enables the version option" do
@options.should_receive(:version)
@script.options
end
it "enables the help option" do
@options.should_receive(:help)
@script.options
end
it "calls #custom_options" do
@script.should_receive(:custom_options).with(@options)
@script.options
end
end
describe MSpecCI, "#run" do
before :each do
MSpec.stub(:process)
@filter = double("TagFilter")
TagFilter.stub(:new).and_return(@filter)
@filter.stub(:register)
@tags = ["fails", "critical", "unstable", "incomplete", "unsupported"]
@config = { :ci_files => ["one", "two"] }
@script = MSpecCI.new
@script.stub(:exit)
@script.stub(:config).and_return(@config)
@script.stub(:files).and_return(["one", "two"])
@script.options
end
it "registers the tags patterns" do
@config[:tags_patterns] = [/spec/, "tags"]
MSpec.should_receive(:register_tags_patterns).with([/spec/, "tags"])
@script.run
end
it "registers the files to process" do
MSpec.should_receive(:register_files).with(["one", "two"])
@script.run
end
it "registers a tag filter for 'fails', 'unstable', 'incomplete', 'critical', 'unsupported'" do
filter = double("fails filter")
TagFilter.should_receive(:new).with(:exclude, *@tags).and_return(filter)
filter.should_receive(:register)
@script.run
end
it "registers an additional exclude tag specified by :ci_xtags" do
@config[:ci_xtags] = "windows"
filter = double("fails filter")
TagFilter.should_receive(:new).with(:exclude, *(@tags + ["windows"])).and_return(filter)
filter.should_receive(:register)
@script.run
end
it "registers additional exclude tags specified by a :ci_xtags array" do
@config[:ci_xtags] = ["windows", "windoze"]
filter = double("fails filter")
TagFilter.should_receive(:new).with(:exclude,
*(@tags + ["windows", "windoze"])).and_return(filter)
filter.should_receive(:register)
@script.run
end
it "processes the files" do
MSpec.should_receive(:process)
@script.run
end
it "exits with the exit code registered with MSpec" do
MSpec.stub(:exit_code).and_return(7)
@script.should_receive(:exit).with(7)
@script.run
end
end
|