Class: Spec::Runner::Reporter

Inherits:
Object
  • Object
show all
Defined in:
lib/gems/rspec-1.1.12/lib/spec/runner/reporter.rb

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
# File 'lib/gems/rspec-1.1.12/lib/spec/runner/reporter.rb', line 6

def initialize(options)
  @options = options
  @options.reporter = self
  clear
end

Instance Attribute Details

#example_groupsObject (readonly)

Returns the value of attribute example_groups.



4
5
6
# File 'lib/gems/rspec-1.1.12/lib/spec/runner/reporter.rb', line 4

def example_groups
  @example_groups
end

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/gems/rspec-1.1.12/lib/spec/runner/reporter.rb', line 4

def options
  @options
end

Instance Method Details

#add_example_group(example_group) ⇒ Object



12
13
14
15
16
17
# File 'lib/gems/rspec-1.1.12/lib/spec/runner/reporter.rb', line 12

def add_example_group(example_group)
  formatters.each do |f|
    f.add_example_group(example_group)
  end
  example_groups << example_group
end

#dumpObject

Dumps the summary and returns the total number of failures



56
57
58
59
60
61
62
63
64
65
# File 'lib/gems/rspec-1.1.12/lib/spec/runner/reporter.rb', line 56

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

#endObject



51
52
53
# File 'lib/gems/rspec-1.1.12/lib/spec/runner/reporter.rb', line 51

def end
  @end_time = Time.new
end

#example_finished(example, error = nil) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/gems/rspec-1.1.12/lib/spec/runner/reporter.rb', line 23

def example_finished(example, error=nil)
  @examples << example
  
  if error.nil?
    example_passed(example)
  elsif Spec::Example::ExamplePendingError === error
    example_pending(example, error.pending_caller, error.message)
  else
    example_failed(example, error)
  end
end

#example_started(example) ⇒ Object



19
20
21
# File 'lib/gems/rspec-1.1.12/lib/spec/runner/reporter.rb', line 19

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

#failure(example, error) ⇒ Object Also known as: example_failed



35
36
37
38
39
40
41
42
# File 'lib/gems/rspec-1.1.12/lib/spec/runner/reporter.rb', line 35

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

#start(number_of_examples) ⇒ Object



45
46
47
48
49
# File 'lib/gems/rspec-1.1.12/lib/spec/runner/reporter.rb', line 45

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