Class: Riot::Reporter
Direct Known Subclasses
Instance Attribute Summary collapse
-
#current_context ⇒ Object
Returns the value of attribute current_context.
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#failures ⇒ Object
Returns the value of attribute failures.
-
#passes ⇒ Object
Returns the value of attribute passes.
Instance Method Summary collapse
- #describe_context(context) ⇒ Object
-
#initialize ⇒ Reporter
constructor
A new instance of Reporter.
- #new(*args, &block) ⇒ Object
- #report(description, response) ⇒ Object
- #success? ⇒ Boolean
- #summarize(&block) ⇒ Object
Constructor Details
#initialize ⇒ Reporter
Returns a new instance of Reporter.
4 5 6 7 |
# File 'lib/riot/reporter.rb', line 4 def initialize @passes = @failures = @errors = 0 @current_context = "" end |
Instance Attribute Details
#current_context ⇒ Object
Returns the value of attribute current_context.
3 4 5 |
# File 'lib/riot/reporter.rb', line 3 def current_context @current_context end |
#errors ⇒ Object
Returns the value of attribute errors.
3 4 5 |
# File 'lib/riot/reporter.rb', line 3 def errors @errors end |
#failures ⇒ Object
Returns the value of attribute failures.
3 4 5 |
# File 'lib/riot/reporter.rb', line 3 def failures @failures end |
#passes ⇒ Object
Returns the value of attribute passes.
3 4 5 |
# File 'lib/riot/reporter.rb', line 3 def passes @passes end |
Instance Method Details
#describe_context(context) ⇒ Object
17 |
# File 'lib/riot/reporter.rb', line 17 def describe_context(context); @current_context = context; end |
#new(*args, &block) ⇒ Object
34 35 36 |
# File 'lib/riot/reporter.rb', line 34 def new(*args, &block) self end |
#report(description, response) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/riot/reporter.rb', line 19 def report(description, response) code, result = *response case code when :pass then @passes += 1 pass(description, result) when :fail then @failures += 1 fail(description, result) when :error then @errors += 1 error(description, result) end end |
#success? ⇒ Boolean
9 |
# File 'lib/riot/reporter.rb', line 9 def success?; (@failures + @errors) == 0; end |
#summarize(&block) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/riot/reporter.rb', line 10 def summarize(&block) started = Time.now yield ensure results(Time.now - started) end |