Class: SpecsFor::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/specs_for/runner.rb

Overview

Runner parses CLI arguments, discovers spec files, and executes RSpec.

Constant Summary collapse

DEFAULT_OPTIONS =
{
  verbose:  false,
  dry_run:  false,
  rspec_options: [],
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv = ARGV) ⇒ Runner

Returns a new instance of Runner.



17
18
19
20
21
# File 'lib/specs_for/runner.rb', line 17

def initialize(argv = ARGV)
  @argv    = argv.dup
  @options = DEFAULT_OPTIONS.dup
  @files   = []
end

Instance Attribute Details

#filesObject (readonly)

Returns the value of attribute files.



9
10
11
# File 'lib/specs_for/runner.rb', line 9

def files
  @files
end

#optionsObject (readonly)

Returns the value of attribute options.



9
10
11
# File 'lib/specs_for/runner.rb', line 9

def options
  @options
end

Instance Method Details

#runObject

Entry-point: parse args, find specs, run rspec. Returns the exit status (Integer).



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/specs_for/runner.rb', line 25

def run
  parse_options
  resolve_files
  spec_files = find_spec_files

  if spec_files.empty?
    warn "specs-for: no spec files found"
    return 1
  end

  execute_rspec(spec_files)
end