Class: Loupe::Reporter

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

Overview

Reporter

Class that handles reporting test results and progress.

Direct Known Subclasses

PagedReporter, PlainReporter

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Loupe::Reporter

Parameters:

  • options (Hash<Symbol, BasicObject>) (defaults to: {})


49
50
51
52
53
54
55
56
57
58
59
# File 'lib/loupe/reporter.rb', line 49

def initialize(options = {})
  @options = options
  @color = Color.new(options[:color])
  @options = options
  @test_count = 0
  @expectation_count = 0
  @success_count = 0
  @failure_count = 0
  @failures = []
  @start_time = Time.now
end

Instance Attribute Details

#expectation_countInteger (readonly)

Returns:

  • (Integer)


36
37
38
# File 'lib/loupe/reporter.rb', line 36

def expectation_count
  @expectation_count
end

#failure_countInteger (readonly)

Returns:

  • (Integer)


42
43
44
# File 'lib/loupe/reporter.rb', line 42

def failure_count
  @failure_count
end

#failuresArray<Loupe::Failure> (readonly)

Returns:



45
46
47
# File 'lib/loupe/reporter.rb', line 45

def failures
  @failures
end

#success_countInteger (readonly)

Returns:

  • (Integer)


39
40
41
# File 'lib/loupe/reporter.rb', line 39

def success_count
  @success_count
end

#test_countInteger (readonly)

Returns:

  • (Integer)


33
34
35
# File 'lib/loupe/reporter.rb', line 33

def test_count
  @test_count
end

Instance Method Details

#<<(other) ⇒ Loupe::Reporter

Parameters:

Returns:



87
88
89
90
91
92
93
94
# File 'lib/loupe/reporter.rb', line 87

def <<(other)
  @test_count += other.test_count
  @expectation_count += other.expectation_count
  @success_count += other.success_count
  @failure_count += other.failure_count
  @failures.concat(other.failures)
  self
end

#exit_statusInteger

Returns:

  • (Integer)


97
98
99
# File 'lib/loupe/reporter.rb', line 97

def exit_status
  @failure_count.zero? ? 0 : 1
end

#increment_expectation_countvoid

This method returns an undefined value.



67
68
69
# File 'lib/loupe/reporter.rb', line 67

def increment_expectation_count
  @expectation_count += 1
end

#increment_failure_count(test, message) ⇒ void

This method returns an undefined value.

Parameters:



79
80
81
82
83
# File 'lib/loupe/reporter.rb', line 79

def increment_failure_count(test, message)
  print(@color.p("F", :red))
  @failures << Failure.new(test, message)
  @failure_count += 1
end

#increment_success_countvoid

This method returns an undefined value.



72
73
74
75
# File 'lib/loupe/reporter.rb', line 72

def increment_success_count
  print(@color.p(".", :green))
  @success_count += 1
end

#increment_test_countvoid

This method returns an undefined value.



62
63
64
# File 'lib/loupe/reporter.rb', line 62

def increment_test_count
  @test_count += 1
end

This method returns an undefined value.

Raises:

  • (NotImplementedError)


102
103
104
# File 'lib/loupe/reporter.rb', line 102

def print_summary
  raise NotImplementedError, "Print must be implemented in the inheriting reporter class"
end