Class: MSpecRun

Inherits:
MSpecScript show all
Defined in:
lib/mspec/commands/mspec-run.rb

Instance Method Summary collapse

Methods inherited from MSpecScript

config, #config, #custom_options, #custom_register, #entries, #files, get, #load, #load_default, main, #register, set, #signals

Constructor Details

#initializeMSpecRun

Returns a new instance of MSpecRun.



11
12
13
14
15
# File 'lib/mspec/commands/mspec-run.rb', line 11

def initialize
  super

  config[:files] = []
end

Instance Method Details

#options(argv = ARGV) ⇒ Object



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
# File 'lib/mspec/commands/mspec-run.rb', line 17

def options(argv=ARGV)
  options = MSpecOptions.new "mspec run [options] (FILE|DIRECTORY|GLOB)+", 30, config

  options.doc " Ask yourself:"
  options.doc "  1. What specs to run?"
  options.doc "  2. How to modify the execution?"
  options.doc "  3. How to modify the guard behavior?"
  options.doc "  4. How to display the output?"
  options.doc "  5. What action to perform?"
  options.doc "  6. When to perform it?"

  options.doc "\n What specs to run"
  options.filters

  options.doc "\n How to modify the execution"
  options.chdir
  options.prefix
  options.configure { |f| load f }
  options.name
  options.randomize
  options.repeat
  options.pretend
  options.background
  options.interrupt

  options.doc "\n How to modify the guard behavior"
  options.unguarded
  options.verify

  options.doc "\n How to display their output"
  options.formatters
  options.verbose

  options.doc "\n What action to perform"
  options.actions

  options.doc "\n When to perform it"
  options.action_filters

  options.doc "\n Help!"
  options.debug
  options.version MSpec::VERSION
  options.help

  options.doc "\n Custom options"
  custom_options options

  options.doc "\n How might this work in the real world?"
  options.doc "\n   1. To simply run some specs"
  options.doc "\n     $ mspec path/to/the/specs"
  options.doc "     mspec path/to/the_file_spec.rb"
  options.doc "\n   2. To run specs tagged with 'fails'"
  options.doc "\n     $ mspec -g fails path/to/the_file_spec.rb"
  options.doc "\n   3. To start the debugger before the spec matching 'this crashes'"
  options.doc "\n     $ mspec --spec-debug -S 'this crashes' path/to/the_file_spec.rb"
  options.doc "\n   4. To run some specs matching 'this crashes'"
  options.doc "\n     $ mspec -e 'this crashes' path/to/the_file_spec.rb"

  options.doc ""

  patterns = options.parse argv
  patterns = config[:files] if patterns.empty?
  patterns = ["spec/"] if patterns.empty? and File.directory? "./spec"
  if patterns.empty?
    puts options
    puts "No files specified."
    exit 1
  end
  @files = files patterns
end

#runObject



88
89
90
91
92
93
94
95
96
# File 'lib/mspec/commands/mspec-run.rb', line 88

def run
  MSpec.register_mode :no_ruby_bug

  MSpec.register_tags_patterns config[:tags_patterns]
  MSpec.register_files @files

  MSpec.process
  exit MSpec.exit_code
end