Updated MSpec source to 1c3ee1c8.
[rbx.git] / mspec / spec / commands / mspec_ci_spec.rb
blob57ccdacb4789659b5918cc1a355624e9f1e3f246
1 require File.dirname(__FILE__) + '/../spec_helper'
2 require 'mspec/runner/mspec'
3 require 'mspec/runner/filters/tag'
4 require 'mspec/commands/mspec-ci'
6 describe MSpecCI, "#options" do
7   before :each do
8     @options, @config = new_option
9     MSpecOptions.stub!(:new).and_return(@options)
11     @script = MSpecCI.new
12     @script.stub!(:config).and_return(@config)
13   end
15   it "enables the config option" do
16     @options.should_receive(:add_config)
17     @script.options
18   end
20   it "provides a custom action (block) to the config option" do
21     @script.should_receive(:load).with("cfg.mspec")
22     @script.options ["-B", "cfg.mspec"]
23   end
25   it "enables the name option" do
26     @options.should_receive(:add_name)
27     @script.options
28   end
30   it "enables the dry run option" do
31     @options.should_receive(:add_pretend)
32     @script.options
33   end
35   it "enables the interrupt single specs option" do
36     @options.should_receive(:add_interrupt)
37     @script.options
38   end
40   it "enables the formatter options" do
41     @options.should_receive(:add_formatters)
42     @script.options
43   end
45   it "enables the verbose option" do
46     @options.should_receive(:add_verbose)
47     @script.options
48   end
50   it "enables the action options" do
51     @options.should_receive(:add_actions)
52     @script.options
53   end
55   it "enables the action filter options" do
56     @options.should_receive(:add_action_filters)
57     @script.options
58   end
60   it "enables the version option" do
61     @options.should_receive(:add_version)
62     @script.options
63   end
65   it "enables the help option" do
66     @options.should_receive(:add_help)
67     @script.options
68   end
69 end
71 describe MSpecCI, "#run" do
72   before :each do
73     MSpec.stub!(:process)
75     @filter = mock("TagFilter")
76     TagFilter.stub!(:new).and_return(@filter)
77     @filter.stub!(:register)
79     stat = mock("stat")
80     stat.stub!(:file?).and_return(true)
81     stat.stub!(:directory?).and_return(false)
82     File.stub!(:expand_path)
83     File.stub!(:stat).and_return(stat)
85     @config = { :ci_files => ["one", "two"] }
86     @script = MSpecCI.new
87     @script.stub!(:exit)
88     @script.stub!(:config).and_return(@config)
89     @script.options
90   end
92   it "registers the tags patterns" do
93     @config[:tags_patterns] = [/spec/, "tags"]
94     MSpec.should_receive(:register_tags_patterns).with([/spec/, "tags"])
95     @script.run
96   end
98   it "registers the files to process" do
99     MSpec.should_receive(:register_files).with(["one", "two"])
100     @script.run
101   end
103   it "registers a tag filter for 'fails'" do
104     filter = mock("fails filter")
105     TagFilter.should_receive(:new).with(:exclude, 'fails').and_return(filter)
106     filter.should_receive(:register)
107     @script.run
108   end
110   it "registers a tag filter for 'unstable'" do
111     filter = mock("unstable filter")
112     TagFilter.should_receive(:new).with(:exclude, 'unstable').and_return(filter)
113     filter.should_receive(:register)
114     @script.run
115   end
117   it "registers a tag filter for 'incomplete'" do
118     filter = mock("incomplete filter")
119     TagFilter.should_receive(:new).with(:exclude, 'incomplete').and_return(filter)
120     filter.should_receive(:register)
121     @script.run
122   end
124   it "registers a tag filter for 'critical'" do
125     filter = mock("critical filter")
126     TagFilter.should_receive(:new).with(:exclude, 'critical').and_return(filter)
127     filter.should_receive(:register)
128     @script.run
129   end
131   it "registers a tag filter for 'unsupported'" do
132     filter = mock("unsupported filter")
133     TagFilter.should_receive(:new).with(:exclude, 'unsupported').and_return(filter)
134     filter.should_receive(:register)
135     @script.run
136   end
138   it "processes the files" do
139     MSpec.should_receive(:process)
140     @script.run
141   end
143   it "exits with the exit code registered with MSpec" do
144     MSpec.stub!(:exit_code).and_return(7)
145     @script.should_receive(:exit).with(7)
146     @script.run
147   end