{"record":{"id":"40b263a0055b2a49","repo":"teamcapybara/capybara","slug":"the-have-none-of-selectors-matcher-does-not-suppor","errorCode":null,"errorMessage":"The have_none_of_selectors matcher does not support use with not_to/should_not","messagePattern":"The have_none_of_selectors matcher does not support use with not_to/should_not","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/capybara/rspec/matchers/have_selector.rb","lineNumber":52,"sourceCode":"      class HaveAllSelectors < WrappedElementMatcher\n        def element_matches?(el)\n          el.assert_all_of_selectors(*@args, **session_query_options, &@filter_block)\n        end\n\n        def does_not_match?(_actual)\n          raise ArgumentError, 'The have_all_selectors matcher does not support use with not_to/should_not'\n        end\n\n        def description = 'have all selectors'\n      end\n\n      class HaveNoSelectors < WrappedElementMatcher\n        def element_matches?(el)\n          el.assert_none_of_selectors(*@args, **session_query_options, &@filter_block)\n        end\n\n        def does_not_match?(_actual)\n          raise ArgumentError, 'The have_none_of_selectors matcher does not support use with not_to/should_not'\n        end\n\n        def description = 'have no selectors'\n      end\n\n      class HaveAnySelectors < WrappedElementMatcher\n        def element_matches?(el)\n          el.assert_any_of_selectors(*@args, **session_query_options, &@filter_block)\n        end\n\n        def does_not_match?(el)\n          el.assert_none_of_selectors(*@args, **session_query_options, &@filter_block)\n        end\n\n        def description = 'have any selectors'\n      end\n    end\n  end","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/teamcapybara/capybara/blob/15b5fdb76e972e9623d5af2123ed3755594f9732/lib/capybara/rspec/matchers/have_selector.rb#L34-L70","documentation":"HaveNoSelectors#does_not_match? raises ArgumentError because negating have_none_of_selectors is ambiguous: 'it is not the case that none are present' collapses to 'some unknown subset exists', which RSpec cannot report meaningfully. The positive form calls assert_none_of_selectors and fails naming any selector that is present.","triggerScenarios":"expect(page).not_to have_none_of_selectors('.a', '.b'); should_not have_none_of_selectors(:xpath, '//tr') - the negated call path hits does_not_match? and raises.","commonSituations":"Auto-generated negations from spec templates or shared contexts; refactoring 'should not display these elements' specs by simply adding not_to; one-liners where the author meant 'at least one present' but reached for not_to have_none_of_selectors.","solutions":["Use the positive form for 'nothing here': expect(page).to have_none_of_selectors('.a', '.b').","If you meant 'at least one is present', assert the specific selector positively: expect(page).to have_selector('.a').","Split the compound expectation into one expectation per selector so each is individually meaningful.","Remove mechanically-generated not_to wrappers introduced by shared examples or cop autocorrection."],"exampleFix":"# before\nexpect(page).not_to have_none_of_selectors('.a', '.b')\n\n# after\nexpect(page).to have_selector('.a').or have_selector('.b')","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use to with have_none_of_selectors for exhaustive absence; use individual have_selector expectations for partial presence.","Lint for 'not_to have_none_of_selectors' in CI the same way as other negated aggregate matchers."],"tags":["ruby","capybara","rspec","matchers"],"backgroundTag":"matcher-negation-unsupported","analyzedSha":"15b5fdb76e972e9623d5af2123ed3755594f9732","analyzedAt":"2026-08-21T16:53:45.588Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}