Class: Stormbreaker::AxeHelper

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

Class Method Summary collapse

Class Method Details

.assert_axeObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/stormbreaker/axe_helper.rb', line 6

def self.assert_axe
  @driver ||= Stormbreaker.configured_driver
  raise "Driver is not configured" unless @driver

  axe_matcher = Axe::Matchers::BeAxeClean.new
  axe_matcher.according_to configuration.rules
  axe_matcher.skipping configuration.skip

  # Always assert that driver's current page _is_ axe compliant
  RSpec::Expectations::PositiveExpectationHandler.handle_matcher(@driver, axe_matcher)
  call_stack = caller.grep(/selenium.*_spec\.rb/).first(5)
  # only get /path/to/spec:line_number from call stack
  call_stack.map! { |c| c.scan(%r{^[A-Za-z0-9/_-]*\.rb:\d*}) }

  violations = axe_matcher.audit([]).results.violations
  violations.each do |v|
    v.nodes.each do |node|
      manager.add_failure(called_by: call_stack, violation: v, node:)
    end
  end
end

.configurationObject



56
57
58
# File 'lib/stormbreaker/axe_helper.rb', line 56

def self.configuration
  Stormbreaker.configuration
end

.detailed_resultsObject



52
53
54
# File 'lib/stormbreaker/axe_helper.rb', line 52

def self.detailed_results
  manager.list_test_results
end

.example_passed?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/stormbreaker/axe_helper.rb', line 40

def self.example_passed?
  manager.test_passed?
end

.managerObject



28
29
30
# File 'lib/stormbreaker/axe_helper.rb', line 28

def self.manager
  @manager ||= AxeViolationManager.new
end

.post_test_cleanupObject



32
33
34
# File 'lib/stormbreaker/axe_helper.rb', line 32

def self.post_test_cleanup
  manager.clear_failures_from_test
end

.post_total_cleanupObject



36
37
38
# File 'lib/stormbreaker/axe_helper.rb', line 36

def self.post_total_cleanup
  manager.clear_failures_from_total
end

.suite_passed?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/stormbreaker/axe_helper.rb', line 44

def self.suite_passed?
  manager.total_passed?
end

.summarize_resultsObject



48
49
50
# File 'lib/stormbreaker/axe_helper.rb', line 48

def self.summarize_results
  manager.summarize_total_results_by_severity
end