Class: Kintama::Reporter::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/kintama/reporter.rb

Direct Known Subclasses

Inline, Verbose

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.



22
23
24
# File 'lib/kintama/reporter.rb', line 22

def initialize
  @test_count = 0
end

Instance Attribute Details

#runnerObject (readonly)

Returns the value of attribute runner.



20
21
22
# File 'lib/kintama/reporter.rb', line 20

def runner
  @runner
end

Instance Method Details

#character_status_of(test) ⇒ Object



67
68
69
70
71
72
73
74
75
# File 'lib/kintama/reporter.rb', line 67

def character_status_of(test)
  character = if test.pending?
    'P'
  elsif test.passed?
    '.'
  else
    'F'
  end
end

#context_finished(context) ⇒ Object



34
35
# File 'lib/kintama/reporter.rb', line 34

def context_finished(context)
end

#context_started(context) ⇒ Object



31
32
# File 'lib/kintama/reporter.rb', line 31

def context_started(context)
end

#failure_messagesObject



59
60
61
62
63
64
65
# File 'lib/kintama/reporter.rb', line 59

def failure_messages
  x = 0
  runner.failures.map do |test|
    x += 1
    "#{x}) #{test.full_name}:\n  #{test.failure_message}"
  end
end

#finishedObject



44
45
46
# File 'lib/kintama/reporter.rb', line 44

def finished
  @duration = Time.now - @start
end

#show_resultsObject



54
55
56
57
# File 'lib/kintama/reporter.rb', line 54

def show_results
  puts test_summary
  puts "\n" + failure_messages.join("\n\n") if runner.failures.any?
end

#started(runner) ⇒ Object



26
27
28
29
# File 'lib/kintama/reporter.rb', line 26

def started(runner)
  @runner = runner
  @start = Time.now
end

#test_finished(test) ⇒ Object



41
42
# File 'lib/kintama/reporter.rb', line 41

def test_finished(test)
end

#test_started(test) ⇒ Object



37
38
39
# File 'lib/kintama/reporter.rb', line 37

def test_started(test)
  @test_count += 1
end

#test_summaryObject



48
49
50
51
52
# File 'lib/kintama/reporter.rb', line 48

def test_summary
  output = ["#{@test_count} tests", "#{runner.failures.length} failures"]
  output << "#{runner.pending.length} pending" if runner.pending.any?
  output.join(", ") + " (#{format("%.4f", @duration)} seconds)"
end