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

#initialize(*args) ⇒ Base

Returns a new instance of Base.



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

def initialize(*args)
  @test_count = 0
end

Instance Attribute Details

#runnerObject (readonly)

Returns the value of attribute runner.



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

def runner
  @runner
end

#test_countObject (readonly)

Returns the value of attribute test_count.



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

def test_count
  @test_count
end

Instance Method Details

#character_status_of(test) ⇒ Object



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

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

#context_finished(context) ⇒ Object



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

def context_finished(context)
end

#context_started(context) ⇒ Object



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

def context_started(context)
end

#failure_messagesObject



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

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

#finishedObject



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

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

#show_resultsObject



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

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

#started(runner) ⇒ Object



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

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

#test_finished(test) ⇒ Object



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

def test_finished(test)
end

#test_started(test) ⇒ Object



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

def test_started(test)
  @test_count += 1
end

#test_summaryObject



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

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