Class: Matest::Runner

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Runner

Returns a new instance of Runner.



7
8
9
10
11
# File 'lib/matest/runner.rb', line 7

def initialize(options={})
  @example_groups = []
  @info           = {}
  @printer        = options[:printer] || SpecPrinter.new
end

Instance Attribute Details

#example_groupsObject (readonly)

Returns the value of attribute example_groups.



3
4
5
# File 'lib/matest/runner.rb', line 3

def example_groups
  @example_groups
end

#infoObject (readonly)

Returns the value of attribute info.



4
5
6
# File 'lib/matest/runner.rb', line 4

def info
  @info
end

#printerObject (readonly)

Returns the value of attribute printer.



5
6
7
# File 'lib/matest/runner.rb', line 5

def printer
  @printer
end

Class Method Details

.runnerObject



13
14
15
# File 'lib/matest/runner.rb', line 13

def self.runner
  @runner ||= new
end

Instance Method Details

#<<(example_group) ⇒ Object



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

def <<(example_group)
  example_group.printer = printer
  example_groups << example_group
end

#execute!Object



31
32
33
34
35
36
# File 'lib/matest/runner.rb', line 31

def execute!
  example_groups.each do |current_group|
    current_group.execute!
  end
  printer.print_messages(self)
end

#load_file(file) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/matest/runner.rb', line 22

def load_file(file)
  location = file.split(":")
  if location.count == 1
    require(file)
  else
    require_spec(*location)
  end
end