Sha256: d9aed4da5d2e463d6207fc6309543bb7e276f00bcf9cfd1898cca06404038296

Contents?: true

Size: 1.73 KB

Versions: 11

Compression:

Stored size: 1.73 KB

Contents

# frozen_string_literal: true

require 'capybara/rspec/matchers/base'

module Capybara
  module RSpecMatchers
    module Matchers
      class HaveSelector < CountableWrappedElementMatcher
        def element_matches?(el)
          el.assert_selector(*@args, &@filter_block)
        end

        def element_does_not_match?(el)
          el.assert_no_selector(*@args, &@filter_block)
        end

        def description
          "have #{query.description}"
        end

        def query
          @query ||= Capybara::Queries::SelectorQuery.new(*session_query_args, &@filter_block)
        end
      end

      class HaveAllSelectors < WrappedElementMatcher
        def element_matches?(el)
          el.assert_all_of_selectors(*@args, &@filter_block)
        end

        def does_not_match?(_actual)
          raise ArgumentError, 'The have_all_selectors matcher does not support use with not_to/should_not'
        end

        def description
          'have all selectors'
        end
      end

      class HaveNoSelectors < WrappedElementMatcher
        def element_matches?(el)
          el.assert_none_of_selectors(*@args, &@filter_block)
        end

        def does_not_match?(_actual)
          raise ArgumentError, 'The have_none_of_selectors matcher does not support use with not_to/should_not'
        end

        def description
          'have no selectors'
        end
      end

      class HaveAnySelectors < WrappedElementMatcher
        def element_matches?(el)
          el.assert_any_of_selectors(*@args, &@filter_block)
        end

        def does_not_match?(_actual)
          el.assert_none_of_selectors(*@args, &@filter_block)
        end

        def description
          'have any selectors'
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 3 rubygems

Version Path
tdiary-5.1.2 vendor/bundle/ruby/2.6.0/gems/capybara-3.29.0/lib/capybara/rspec/matchers/have_selector.rb
tdiary-5.1.1 vendor/bundle/ruby/2.6.0/gems/capybara-3.29.0/lib/capybara/rspec/matchers/have_selector.rb
capybara-3.30.0 lib/capybara/rspec/matchers/have_selector.rb
tdiary-5.1.0 vendor/bundle/gems/capybara-3.29.0/lib/capybara/rspec/matchers/have_selector.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/capybara-3.29.0/lib/capybara/rspec/matchers/have_selector.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/capybara-3.29.0/lib/capybara/rspec/matchers/have_selector.rb
capybara-3.29.0 lib/capybara/rspec/matchers/have_selector.rb
capybara-3.28.0 lib/capybara/rspec/matchers/have_selector.rb
capybara-3.27.0 lib/capybara/rspec/matchers/have_selector.rb
capybara-3.26.0 lib/capybara/rspec/matchers/have_selector.rb
capybara-3.25.0 lib/capybara/rspec/matchers/have_selector.rb