Class: Riot::Reporter

Inherits:
Object show all
Defined in:
lib/riot/reporter.rb

Direct Known Subclasses

IOReporter, SilentReporter

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeReporter

Returns a new instance of Reporter.



4
5
6
# File 'lib/riot/reporter.rb', line 4

def initialize
  @passes = @failures = @errors = 0
end

Instance Attribute Details

#errorsObject

Returns the value of attribute errors.



3
4
5
# File 'lib/riot/reporter.rb', line 3

def errors
  @errors
end

#failuresObject

Returns the value of attribute failures.



3
4
5
# File 'lib/riot/reporter.rb', line 3

def failures
  @failures
end

#passesObject

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(msg) ⇒ Object



15
# File 'lib/riot/reporter.rb', line 15

def describe_context(msg); end

#report(description, response) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/riot/reporter.rb', line 17

def report(description, response)
  code, result = *response
  case code
  when :pass then
    @passes += 1
    pass(description)
  when :fail then
    @failures += 1
    fail(description, result)
  when :error then
    @errors += 1
    error(description, result)
  end
end

#summarize(&block) ⇒ Object



8
9
10
11
12
13
# File 'lib/riot/reporter.rb', line 8

def summarize(&block)
  started = Time.now
  yield
ensure
  results(Time.now - started)
end