Class: Spec::Runner::Reporter

Inherits:
Object
  • Object
show all
Defined in:
lib/vendor/plugins/rspec/lib/spec/runner/reporter.rb

Direct Known Subclasses

FakeReporter

Defined Under Namespace

Classes: Failure

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Reporter

Returns a new instance of Reporter.



6
7
8
9
10
11
12
13
14
# File 'lib/vendor/plugins/rspec/lib/spec/runner/reporter.rb', line 6

def initialize(options)
  @options = options
  @options.reporter = self
  @failures = []
  @pending_count = 0
  @example_count = 0
  @start_time = nil
  @end_time = nil
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/vendor/plugins/rspec/lib/spec/runner/reporter.rb', line 4

def options
  @options
end

Instance Method Details

#dumpObject

Dumps the summary and returns the total number of failures



58
59
60
61
62
63
64
65
66
67
# File 'lib/vendor/plugins/rspec/lib/spec/runner/reporter.rb', line 58

def dump
  formatters.each{|f| f.start_dump}
  dump_pending
  dump_failures
  formatters.each do |f|
    f.dump_summary(duration, @example_count, @failures.length, @pending_count)
    f.close
  end
  @failures.length
end

#endObject



53
54
55
# File 'lib/vendor/plugins/rspec/lib/spec/runner/reporter.rb', line 53

def end
  @end_time = Time.new
end

#example_failed(example, error) ⇒ Object



39
40
41
42
43
44
45
46
# File 'lib/vendor/plugins/rspec/lib/spec/runner/reporter.rb', line 39

def example_failed(example, error)
  backtrace_tweaker.tweak_backtrace(error)
  failure = Failure.new(@example_group.description, example.description, error)
  @failures << failure
  formatters.each do |f|
    f.example_failed(example, @failures.length, failure)
  end
end

#example_finished(example, error = nil) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/vendor/plugins/rspec/lib/spec/runner/reporter.rb', line 27

def example_finished(example, error=nil)
  @example_count += 1
  
  if error.nil?
    example_passed(example)
  elsif Spec::Example::ExamplePendingError === error
    example_pending(example, example.location, error.message)
  else
    example_failed(example, error)
  end
end

#example_group_started(example_group) ⇒ Object



16
17
18
19
20
21
# File 'lib/vendor/plugins/rspec/lib/spec/runner/reporter.rb', line 16

def example_group_started(example_group)
  @example_group = example_group
  formatters.each do |f|
    f.example_group_started(example_group)
  end
end

#example_started(example) ⇒ Object



23
24
25
# File 'lib/vendor/plugins/rspec/lib/spec/runner/reporter.rb', line 23

def example_started(example)
  formatters.each{|f| f.example_started(example)}
end

#start(number_of_examples) ⇒ Object



48
49
50
51
# File 'lib/vendor/plugins/rspec/lib/spec/runner/reporter.rb', line 48

def start(number_of_examples)
  @start_time = Time.new
  formatters.each{|f| f.start(number_of_examples)}
end