class Axe::Cucumber::Step

Constants

REGEX
REGEX_CAPTURE_EXCLUSION

optionally specify subtrees to be excluded, via CSS selector

REGEX_CAPTURE_INCLUSION

optionally specify which subtree to check, via CSS selector

REGEX_CAPTURE_NEGATE

Extracting regex into variable to allow for easier consumption elsewhere

require initial phrasing, with 'not' to negate the matcher

REGEX_CAPTURE_OPTIONS

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

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

REGEX_CAPTURE_SKIP_RULES

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

REGEX_CAPTURE_TAGS

optionally specify ruleset via list of comma-separated tags

Public Class Methods

create_for(world) click to toggle source
# File lib/axe/cucumber/step.rb, line 38
def self.create_for(world)
  new(FindsPage.in(world).page)
end
new(page) click to toggle source
# File lib/axe/cucumber/step.rb, line 42
def initialize(page)
  @page = page
end

Public Instance Methods

assert_accessibility(negate = false, inclusion = "", exclusion = "", tags = "", run_only = false, run_rules = "", skip_rules = "", options = nil) click to toggle source
# File lib/axe/cucumber/step.rb, line 46
def assert_accessibility(negate = false, inclusion = "", exclusion = "", tags = "", run_only = false, run_rules = "", skip_rules = "", options = nil)
  is_accessible = Axe::Matchers::BeAccessible.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_accessible
end

Private Instance Methods

selector(selector) click to toggle source
# File lib/axe/cucumber/step.rb, line 62
def selector(selector)
  split(selector)
end
split(string) click to toggle source
# File lib/axe/cucumber/step.rb, line 66
def split(string)
  String(string).split(/,\s*/)
end
to_hash(string) click to toggle source
# File lib/axe/cucumber/step.rb, line 70
def to_hash(string)
  (string && !string.empty?) ? YAML.load(String(string)) : {}
end