Class: BladeRunner::TestResults
- Inherits:
-
Object
- Object
- BladeRunner::TestResults
- Defined in:
- lib/blade_runner/test_results.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#failures ⇒ Object
readonly
Returns the value of attribute failures.
-
#lines ⇒ Object
readonly
Returns the value of attribute lines.
-
#passes ⇒ Object
readonly
Returns the value of attribute passes.
-
#session_id ⇒ Object
readonly
Returns the value of attribute session_id.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(session_id) ⇒ TestResults
constructor
A new instance of TestResults.
- #process_test_result(details) ⇒ Object
- #reset ⇒ Object
- #to_s ⇒ Object
- #total ⇒ Object
Constructor Details
#initialize(session_id) ⇒ TestResults
Returns a new instance of TestResults.
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/blade_runner/test_results.rb', line 4 def initialize(session_id) @session_id = session_id reset BR.subscribe("/tests") do |details| if details["session_id"] == session_id process_test_result(details) end end end |
Instance Attribute Details
#failures ⇒ Object (readonly)
Returns the value of attribute failures.
2 3 4 |
# File 'lib/blade_runner/test_results.rb', line 2 def failures @failures end |
#lines ⇒ Object (readonly)
Returns the value of attribute lines.
2 3 4 |
# File 'lib/blade_runner/test_results.rb', line 2 def lines @lines end |
#passes ⇒ Object (readonly)
Returns the value of attribute passes.
2 3 4 |
# File 'lib/blade_runner/test_results.rb', line 2 def passes @passes end |
#session_id ⇒ Object (readonly)
Returns the value of attribute session_id.
2 3 4 |
# File 'lib/blade_runner/test_results.rb', line 2 def session_id @session_id end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
2 3 4 |
# File 'lib/blade_runner/test_results.rb', line 2 def status @status end |
Instance Method Details
#process_test_result(details) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/blade_runner/test_results.rb', line 24 def process_test_result(details) publication = {} case details["event"] when "begin" reset @status = "running" @total = details["total"] @lines << publication[:line] = "1..#{@total}" when "result" pass = details["result"] args = details.values_at("name", "message") if pass line = Pass.new(*args).to_s @passes << line else line = Failure.new(*args).to_s @failures << line @status = "failing" end @lines << line publication.merge!(line: line, pass: pass) when "end" @status = failures.any? ? "failed" : "finished" @completed = true end publication.merge!(status: status, session_id: session_id, completed: @completed) BR.publish("/results", publication) end |
#reset ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/blade_runner/test_results.rb', line 15 def reset @lines = [] @passes = [] @failures = [] @completed = false @status = "pending" @total = nil end |
#to_s ⇒ Object
65 66 67 |
# File 'lib/blade_runner/test_results.rb', line 65 def to_s lines.join("\n") + "\n" end |
#total ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/blade_runner/test_results.rb', line 57 def total if @total @total elsif @completed passes.size + failures.size end end |