3 $:.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
6 require 'mspec/utils/options'
7 require 'mspec/utils/script'
10 class MSpecCI < MSpecScript
11 def options(argv=ARGV)
12 options = MSpecOptions.new config, "ci", "", 28, " "
14 options.separator " Ask yourself:"
15 options.separator " 1. How to run the specs?"
16 options.separator " 2. How to display the output?"
17 options.separator " 3. What action to perform?"
18 options.separator " 4. When to perform it?"
20 options.separator "\n How to run the specs"
21 options.add_config { |f| load f }
26 options.separator "\n How to display their output"
27 options.add_formatters
30 options.separator "\n What action to perform"
33 options.separator "\n When to perform it"
34 options.add_action_filters
36 options.separator "\n Help!"
40 options.separator "\n How might this work in the real world?"
41 options.separator "\n 1. To simply run the known good specs"
42 options.separator "\n $ mspec ci"
43 options.separator "\n 2. To run a subset of the known good specs"
44 options.separator "\n $ mspec ci path/to/specs"
45 options.separator "\n 3. To start the debugger before the spec matching 'this crashes'"
46 options.separator "\n $ mspec ci --spec-debug -S 'this crashes'"
49 @patterns = options.parse argv
50 @patterns = config[:ci_files] if @patterns.empty?
55 @patterns.each do |item|
56 stat = File.stat(File.expand_path(item))
57 files << item if stat.file?
58 files.concat(Dir[item+"/**/*_spec.rb"].sort) if stat.directory?
61 MSpec.register_tags_patterns config[:tags_patterns]
62 MSpec.register_files files
63 TagFilter.new(:exclude, "fails").register
64 TagFilter.new(:exclude, "critical").register
65 TagFilter.new(:exclude, "unstable").register
66 TagFilter.new(:exclude, "incomplete").register
67 TagFilter.new(:exclude, "unsupported").register