Class: SpecData

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

Class Method Summary collapse

Class Method Details

.add_spec_stats_to_suite_statsObject



58
59
60
61
62
# File 'lib/spec_data.rb', line 58

def self.add_spec_stats_to_suite_stats
  $verifications_total += $verification_passes
  $warnings_total += execution_warnings.length
  $errors_total += verification_errors.length
end

.clear_all_spec_statsObject



64
65
66
67
68
# File 'lib/spec_data.rb', line 64

def self.clear_all_spec_stats
  $verifications_total = 0
  $warnings_total = 0
  $errors_total = 0
end

.clear_spec_stateObject



15
16
17
18
19
20
21
# File 'lib/spec_data.rb', line 15

def self.clear_spec_state
  execution_warnings.clear
  verification_errors.clear
  $verification_passes = 0
  $fail_test_instantly = false
  $fail_test_at_end = false
end

.determine_spec_resultObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/spec_data.rb', line 30

def self.determine_spec_result
  if execution_warnings.empty?
    Log.info("[GRIDIUM::SpecData] No warnings detected during test run.")
  else
    Log.info("[GRIDIUM::SpecData]Warnings detected during test run: (#{execution_warnings.length} total).")
    msg = "Warning detected during test execution:"
    execution_warnings.each { |error_message| msg << "\n\t" + error_message }
  end

  if verification_errors.empty?
    Log.info("[GRIDIUM::SpecData]No errors detected during test run.")
  else
    Log.info("[GRIDIUM::SpecData]Errors detected during test run: (#{verification_errors.length} total).")
    msg = "TEST FAILURE: Errors detected during test execution:"
    verification_errors.each { |error_message| msg << "\n\t" + error_message }
  end

  if $fail_test_instantly
    Log.info("[GRIDIUM::SpecData]TEST FAILED - CRITICAL ERROR DETECTED")
    Kernel.fail("TEST FAILED - CRITICAL ERROR DETECTED\n")
  elsif $fail_test_at_end
    Log.info("[GRIDIUM::SpecData]TEST FAILED - VERIFICATION ERRORS DETECTED")
    Kernel.fail("TEST FAILED - VERIFICATION ERRORS DETECTED\n")
  else
    Log.info("[GRIDIUM::SpecData]TEST PASSED\n")
  end
end

.execution_warningsObject



78
79
80
# File 'lib/spec_data.rb', line 78

def self.execution_warnings
  @execution_warnings ||= Array.new
end

.load_spec_stateObject



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

def self.load_spec_state
  execution_warnings
  verification_errors
  $verification_passes = 0
  $fail_test_instantly = false
  $fail_test_at_end = false
end

.load_suite_stateObject



2
3
4
5
# File 'lib/spec_data.rb', line 2

def self.load_suite_state
  screenshots_message
  screenshots_captured
end

.reset_captured_screenshotsObject



23
24
25
26
27
28
# File 'lib/spec_data.rb', line 23

def self.reset_captured_screenshots
  screenshots_message.clear
  screenshots_captured.clear
  $screenshots_data = {}
  $fail_screenshot = nil
end

.screenshots_capturedObject



74
75
76
# File 'lib/spec_data.rb', line 74

def self.screenshots_captured
  @screenshots_captured ||= Array.new
end

.screenshots_messageObject



70
71
72
# File 'lib/spec_data.rb', line 70

def self.screenshots_message
  @screenshots_message ||= Array.new
end

.verification_errorsObject



82
83
84
# File 'lib/spec_data.rb', line 82

def self.verification_errors
  @verification_errors ||= Array.new
end