Class: RIESS::TestReporter

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

Defined Under Namespace

Classes: Result

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTestReporter

Returns a new instance of TestReporter.



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

def initialize
  @results = []
  @not_found = []
  @time_started = Time.now
  @immediate_feedback = false
end

Instance Attribute Details

#immediate_feedback=(value) ⇒ Object (writeonly)

Sets the attribute immediate_feedback

Parameters:

  • value

    the value to set the attribute immediate_feedback to.



6
7
8
# File 'lib/test_reporter.rb', line 6

def immediate_feedback=(value)
  @immediate_feedback = value
end

Instance Method Details

#executeObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/test_reporter.rb', line 26

def execute
  specifications = 0
  failures = 0
  @results.each{|result|
    if result.value
      specifications += 1
    else
      failures += 1
      print_failure_message(result)
    end
  } unless @results.empty?
  
  @not_found.each{|item|
    if !item
      failures += 1
    end
  } unless @not_found.empty?
  
  
  time_ended = Time.now
  elapsed_time = time_ended - @time_started
  print_results(elapsed_time,specifications,failures)
end

#locator_not_found(parameter) ⇒ Object



21
22
23
24
# File 'lib/test_reporter.rb', line 21

def locator_not_found(parameter)
  print_not_found_message(parameter) unless !@immediate_feedback
  @not_found << false
end

#record_results(name, expected, actual, value) ⇒ Object



15
16
17
18
19
# File 'lib/test_reporter.rb', line 15

def record_results(name,expected,actual,value)
  result = Result.new(name,expected,actual,value)
  print_immediate_feedback(result) unless !@immediate_feedback
  @results << result
end