Class: AxeMatchers::ResultFormatter
- Inherits:
-
Object
- Object
- AxeMatchers::ResultFormatter
- Defined in:
- lib/decidim/dev/test/rspec_support/accessibility_examples.rb
Instance Method Summary collapse
- #format ⇒ Object
-
#initialize(result) ⇒ ResultFormatter
constructor
A new instance of ResultFormatter.
- #violation_messages ⇒ Object
Constructor Details
#initialize(result) ⇒ ResultFormatter
Returns a new instance of ResultFormatter.
16 17 18 19 |
# File 'lib/decidim/dev/test/rspec_support/accessibility_examples.rb', line 16 def initialize(result) @result = result @violations = result["violations"] end |
Instance Method Details
#format ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/decidim/dev/test/rspec_support/accessibility_examples.rb', line 21 def format <<~MESSAGE Found #{violations.count} accessibility #{violations.count == 1 ? "violation" : "violations"}: #{.join("\n")} MESSAGE end |
#violation_messages ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/decidim/dev/test/rspec_support/accessibility_examples.rb', line 30 def violations.each_with_index.map do |violation, index| nodes = violation["nodes"] [ "#{index + 1}) #{violation["id"]}: #{violation["help"]} (#{violation["impact"]})", indent_lines(violation["helpUrl"], 1), indent_lines("The following #{nodes.length} #{nodes.length == 1 ? "node" : "nodes"} violate this rule:", 1), "", indent_lines((nodes), 2), "" ] end.flatten end |