Sha256: 21344ff35113c9b653895fa573e9d20d2379278d6c11ce0c28c4b3ba76608fad

Contents?: true

Size: 1.02 KB

Versions: 18

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

module Capybara
  # @api private
  module Queries
    class StyleQuery < BaseQuery
      def initialize(expected_styles, session_options:, **options)
        @expected_styles = expected_styles.each_with_object({}) { |(style, value), str_keys| str_keys[style.to_s] = value }
        @options = options
        @actual_styles = {}
        super(@options)
        self.session_options = session_options

        assert_valid_keys
      end

      def resolves_for?(node)
        @node = node
        @actual_styles = node.style(*@expected_styles.keys)
        @expected_styles.all? do |style, value|
          if value.is_a? Regexp
            @actual_styles[style] =~ value
          else
            @actual_styles[style] == value
          end
        end
      end

      def failure_message
        +"Expected node to have styles #{@expected_styles.inspect}. " \
         "Actual styles were #{@actual_styles.inspect}"
      end

    private

      def valid_keys
        %i[wait]
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
tdiary-5.0.11 vendor/bundle/gems/capybara-3.6.0/lib/capybara/queries/style_query.rb
capybara-3.10.1 lib/capybara/queries/style_query.rb
capybara-3.10.0 lib/capybara/queries/style_query.rb
capybara-3.9.0 lib/capybara/queries/style_query.rb
capybara-3.8.2 lib/capybara/queries/style_query.rb
capybara-3.8.1 lib/capybara/queries/style_query.rb
capybara-3.8.0 lib/capybara/queries/style_query.rb
capybara-3.7.2 lib/capybara/queries/style_query.rb
capybara-3.7.1 lib/capybara/queries/style_query.rb
capybara-3.7.0 lib/capybara/queries/style_query.rb
capybara-3.6.0 lib/capybara/queries/style_query.rb
capybara-3.5.1 lib/capybara/queries/style_query.rb
capybara-3.5.0 lib/capybara/queries/style_query.rb
capybara-3.4.2 lib/capybara/queries/style_query.rb
capybara-3.4.1 lib/capybara/queries/style_query.rb
capybara-3.4.0 lib/capybara/queries/style_query.rb
capybara-3.3.1 lib/capybara/queries/style_query.rb
capybara-3.3.0 lib/capybara/queries/style_query.rb