Class: Speq::Report
- Inherits:
-
Object
- Object
- Speq::Report
- Defined in:
- lib/speq/report.rb
Instance Method Summary collapse
-
#initialize(units) ⇒ Report
constructor
A new instance of Report.
- #print_report ⇒ Object
Constructor Details
#initialize(units) ⇒ Report
Returns a new instance of Report.
4 5 6 |
# File 'lib/speq/report.rb', line 4 def initialize(units) @units = units end |
Instance Method Details
#print_report ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/speq/report.rb', line 8 def print_report report_string = '' @units.each do |unit| if unit.passed? outcome = 'PASSED: ' color = :green else outcome = 'FAILED: ' color = :red end method = "calling '#{unit.message}' " arguments = unit.arguments ? "with arguments: '#{unit.arguments}'" : '' receiver = unit.receiver == Object ? '' : "on: #{unit.receiver} " report_string << [outcome, method, arguments, receiver, "\n"].join.colorize(color) end puts report_string end |