Class: Kintama::Reporter::Base
- Inherits:
-
Object
- Object
- Kintama::Reporter::Base
- Defined in:
- lib/kintama/reporter.rb
Instance Attribute Summary collapse
-
#runner ⇒ Object
readonly
Returns the value of attribute runner.
Instance Method Summary collapse
- #character_status_of(test) ⇒ Object
- #context_finished(context) ⇒ Object
- #context_started(context) ⇒ Object
- #failure_messages ⇒ Object
- #finished ⇒ Object
-
#initialize ⇒ Base
constructor
A new instance of Base.
- #show_results ⇒ Object
- #started(runner) ⇒ Object
- #test_finished(test) ⇒ Object
- #test_started(test) ⇒ Object
- #test_summary ⇒ Object
Constructor Details
#initialize ⇒ Base
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
#runner ⇒ Object (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_messages ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/kintama/reporter.rb', line 59 def x = 0 runner.failures.map do |test| x += 1 "#{x}) #{test.full_name}:\n #{test.}" end end |
#finished ⇒ Object
44 45 46 |
# File 'lib/kintama/reporter.rb', line 44 def finished @duration = Time.now - @start end |
#show_results ⇒ Object
54 55 56 57 |
# File 'lib/kintama/reporter.rb', line 54 def show_results puts test_summary puts "\n" + .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_summary ⇒ Object
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 |