Module: CapybaraAccessibilityAudit::AuditSystemTestExtensions
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/capybara_accessibility_audit/audit_system_test_extensions.rb
Constant Summary collapse
- MODAL_METHODS =
if defined?(Capybara::Session::MODAL_METHODS) Capybara::Session::MODAL_METHODS else %i[accept_alert accept_confirm accept_prompt dismiss_confirm dismiss_prompt] end
Instance Method Summary collapse
- #assert_no_accessibility_violations(**options) ⇒ Object
- #skip_accessibility_audits(&block) ⇒ Object
- #skip_accessibility_violations(value, &block) ⇒ Object
- #with_accessibility_audit_options(**options, &block) ⇒ Object
- #with_accessibility_audits(**options, &block) ⇒ Object
Instance Method Details
#assert_no_accessibility_violations(**options) ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/capybara_accessibility_audit/audit_system_test_extensions.rb', line 92 def assert_no_accessibility_violations(**) .assert_valid_keys( :according_to, :checking, :checking_only, :excluding, :skipping, :within ) .compact_blank! axe_matcher = Axe::Matchers::BeAxeClean.new axe_matcher = .inject(axe_matcher) { |matcher, option| matcher.public_send(*option) } assert axe_matcher.matches?(page), axe_matcher. end |
#skip_accessibility_audits(&block) ⇒ Object
74 75 76 77 78 79 80 81 |
# File 'lib/capybara_accessibility_audit/audit_system_test_extensions.rb', line 74 def skip_accessibility_audits(&block) accessibility_audit_enabled = self.accessibility_audit_enabled self.accessibility_audit_enabled = false block.call ensure self.accessibility_audit_enabled = accessibility_audit_enabled end |
#skip_accessibility_violations(value, &block) ⇒ Object
83 84 85 86 87 88 89 90 |
# File 'lib/capybara_accessibility_audit/audit_system_test_extensions.rb', line 83 def skip_accessibility_violations(value, &block) skipping = .skipping .skipping = Array(value) block.call ensure .skipping = skipping end |
#with_accessibility_audit_options(**options, &block) ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'lib/capybara_accessibility_audit/audit_system_test_extensions.rb', line 65 def (**, &block) = self. self. = .merge() block.call ensure self. = end |
#with_accessibility_audits(**options, &block) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/capybara_accessibility_audit/audit_system_test_extensions.rb', line 52 def with_accessibility_audits(**, &block) accessibility_audit_enabled = self.accessibility_audit_enabled self.accessibility_audit_enabled = true if .present? (**, &block) else block.call end ensure self.accessibility_audit_enabled = accessibility_audit_enabled end |