Class: Assert::Runner

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Runner

Returns a new instance of Runner.



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

def initialize(config)
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



7
8
9
# File 'lib/assert/runner.rb', line 7

def config
  @config
end

Instance Method Details

#run(suite, view) ⇒ Object

Raises:

  • (ArgumentError)


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/assert/runner.rb', line 13

def run(suite, view)
  raise ArgumentError if !suite.kind_of?(Suite)
  view.fire(:on_start)

  begin
    suite.setup

    suite.start_time = Time.now
    tests_to_run(suite).each do |test|
      view.fire(:before_test, test)
      test.run{ |result| view.fire(:on_result, result) }
      view.fire(:after_test, test)
    end
    suite.end_time = Time.now

    suite.teardown
  rescue Interrupt => err
    view.fire(:on_interrupt, err)
    raise(err)
  end

  view.fire(:on_finish)
  suite.count(:failed) + suite.count(:errored)
end