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
8 @options, @config = new_option
9 MSpecOptions.stub!(:new).and_return(@options)
12 @script.stub!(:config).and_return(@config)
15 it "enables the config option" do
16 @options.should_receive(:add_config)
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"]
25 it "enables the name option" do
26 @options.should_receive(:add_name)
30 it "enables the dry run option" do
31 @options.should_receive(:add_pretend)
35 it "enables the interrupt single specs option" do
36 @options.should_receive(:add_interrupt)
40 it "enables the formatter options" do
41 @options.should_receive(:add_formatters)
45 it "enables the verbose option" do
46 @options.should_receive(:add_verbose)
50 it "enables the action options" do
51 @options.should_receive(:add_actions)
55 it "enables the action filter options" do
56 @options.should_receive(:add_action_filters)
60 it "enables the version option" do
61 @options.should_receive(:add_version)
65 it "enables the help option" do
66 @options.should_receive(:add_help)
71 describe MSpecCI, "#run" do
75 @filter = mock("TagFilter")
76 TagFilter.stub!(:new).and_return(@filter)
77 @filter.stub!(:register)
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"] }
88 @script.stub!(:config).and_return(@config)
92 it "registers the tags patterns" do
93 @config[:tags_patterns] = [/spec/, "tags"]
94 MSpec.should_receive(:register_tags_patterns).with([/spec/, "tags"])
98 it "registers the files to process" do
99 MSpec.should_receive(:register_files).with(["one", "two"])
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)
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)
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)
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)
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)
138 it "processes the files" do
139 MSpec.should_receive(:process)
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)