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.
-
#test_count ⇒ Object
readonly
Returns the value of attribute test_count.
Instance Method Summary collapse
- #character_status_of(test) ⇒ Object
- #context_finished(context) ⇒ Object
- #context_started(context) ⇒ Object
- #failure_messages ⇒ Object
- #finished ⇒ Object
-
#initialize(*args) ⇒ 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(*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
#runner ⇒ Object (readonly)
Returns the value of attribute runner.
21 22 23 |
# File 'lib/kintama/reporter.rb', line 21 def runner @runner end |
#test_count ⇒ Object (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_messages ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/kintama/reporter.rb', line 60 def x = 0 runner.failures.map do |test| x += 1 "#{x}) #{test.full_name}:\n #{test.}" end end |
#finished ⇒ Object
45 46 47 |
# File 'lib/kintama/reporter.rb', line 45 def finished @duration = Time.now - @start end |
#show_results ⇒ Object
55 56 57 58 |
# File 'lib/kintama/reporter.rb', line 55 def show_results puts test_summary puts "\n" + .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_summary ⇒ Object
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 |