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
7
# File 'lib/riot/reporter.rb', line 4

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

Instance Attribute Details

#current_contextObject

Returns the value of attribute current_context.



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

def current_context
  @current_context
end

#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(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

Returns:

  • (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