Class: AxeCucumber::Step

Inherits:
Object
  • Object
show all
Defined in:
lib/axe-cucumber.rb

Constant Summary collapse

REGEX_CAPTURE_NEGATE =

Extracting regex into variable to allow for easier consumption elsewhere

require initial phrasing, with ‘not’ to negate the matcher

"(?-x:the page should( not)? be axe clean)"
REGEX_CAPTURE_INCLUSION =

optionally specify which subtree to check, via CSS selector

'(?-x:;? within "(.*?)")?'
REGEX_CAPTURE_EXCLUSION =

optionally specify subtrees to be excluded, via CSS selector

'(?-x:;?(?: but)? excluding "(.*?)")?'
REGEX_CAPTURE_TAGS =

optionally specify ruleset via list of comma-separated tags

"(?-x:;? according to: (.*?))?"
REGEX_CAPTURE_RUN_ONLY_RUN_RULES =

optionally specify rules to check as comma-separated list of rule ids in addition to default ruleset or explicit ruleset specified above via tags if the ‘only’ keyword is supplied, then only the listed rules are checked, not additionally

"(?-x:;?(?: and)? checking( only)?: (.*?))?"
REGEX_CAPTURE_SKIP_RULES =

optionally specify rules to skip as comma-separated list of rule ids

"(?-x:;?(?: but)? skipping: (.*?))?"
REGEX_CAPTURE_OPTIONS =

optionally specify custom options to pass directly to axe-core as a yaml-parsed hash or json string

"(?-x:;? with options: (.*?))?"
REGEX =
/^#{REGEX_CAPTURE_NEGATE}#{REGEX_CAPTURE_INCLUSION}#{REGEX_CAPTURE_EXCLUSION}#{REGEX_CAPTURE_TAGS}#{REGEX_CAPTURE_RUN_ONLY_RUN_RULES}#{REGEX_CAPTURE_SKIP_RULES}#{REGEX_CAPTURE_OPTIONS}$/x

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(page) ⇒ Step

Returns a new instance of Step.



41
42
43
# File 'lib/axe-cucumber.rb', line 41

def initialize(page)
  @page = page
end

Class Method Details

.create_for(world) ⇒ Object



37
38
39
# File 'lib/axe-cucumber.rb', line 37

def self.create_for(world)
  new(Axe::FindsPage.in(world).page)
end

Instance Method Details

#assert_accessibility(negate = false, inclusion = "", exclusion = "", tags = "", run_only = false, run_rules = "", skip_rules = "", options = nil) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/axe-cucumber.rb', line 45

def assert_accessibility(
  negate = false,
  inclusion = "",
  exclusion = "",
  tags = "",
  run_only = false,
  run_rules = "",
  skip_rules = "",
  options = nil
)
  is_axe_clean = Axe::Matchers::BeAxeClean.new.tap do |a|
    a.within(*selector(inclusion))
    a.excluding(*selector(exclusion))
    a.according_to(*split(tags))
    a.checking(*split(run_rules)) unless run_only
    a.checking_only(*split(run_rules)) if run_only
    a.skipping(*split(skip_rules))
    a.with_options to_hash(options)
  end

  Axe::AccessibilityExpectation.create(negate).assert @page, is_axe_clean
end