Class: Teabag::Formatters::BaseFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/teabag/formatters/base_formatter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(suite_name = :default) ⇒ BaseFormatter

Returns a new instance of BaseFormatter.



14
15
16
17
18
19
20
21
# File 'lib/teabag/formatters/base_formatter.rb', line 14

def initialize(suite_name = :default)
  @suite_name = suite_name.to_s
  @total    = 0
  @passes   = []
  @pendings = []
  @failures = []
  @errors   = []
end

Instance Attribute Details

#errorsObject

Returns the value of attribute errors.



12
13
14
# File 'lib/teabag/formatters/base_formatter.rb', line 12

def errors
  @errors
end

#failuresObject

Returns the value of attribute failures.



12
13
14
# File 'lib/teabag/formatters/base_formatter.rb', line 12

def failures
  @failures
end

#passesObject

Returns the value of attribute passes.



12
13
14
# File 'lib/teabag/formatters/base_formatter.rb', line 12

def passes
  @passes
end

#pendingsObject

Returns the value of attribute pendings.



12
13
14
# File 'lib/teabag/formatters/base_formatter.rb', line 12

def pendings
  @pendings
end

#totalObject

Returns the value of attribute total.



12
13
14
# File 'lib/teabag/formatters/base_formatter.rb', line 12

def total
  @total
end

Instance Method Details

#exception(exception = {}) ⇒ Object

Exceptions come from startup errors in the server



42
43
44
# File 'lib/teabag/formatters/base_formatter.rb', line 42

def exception(exception = {})
  raise Teabag::RunnerException
end

#result(results) ⇒ Object

Raises:



34
35
36
37
38
39
# File 'lib/teabag/formatters/base_formatter.rb', line 34

def result(results)
  log_coverage(results["coverage"])
  return if failures.size == 0
  STDOUT.print("\n")
  raise Teabag::Failure if Teabag.configuration.fail_fast
end

#spec(result) ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/teabag/formatters/base_formatter.rb', line 23

def spec(result)
  @total += 1
  if result.passing?
    @passes << result
  elsif result.pending?
    @pendings << result
  else
    @failures << result
  end
end

#suppress_logs?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/teabag/formatters/base_formatter.rb', line 46

def suppress_logs?
  false
end