Sha256: 9fe5d4c44abbe34ceadf199208a67e99cb934704b87306abc37402a3e74f3c6f

Contents?: true

Size: 957 Bytes

Versions: 7

Compression:

Stored size: 957 Bytes

Contents

# frozen_string_literal: true

module Katalyst
  module Kpop
    module Matchers
      # @api private
      class CapybaraMatcher < Base
        attr_reader :matched

        def matches?(actual)
          super
        rescue ::Capybara::ElementNotFound
          nil
        end

        def match(expected, actual)
          actual.find(expected)
        end

        def description
          "match #{expected}"
        end

        def describe_expected
          expected.inspect
        end

        def describe_actual
          response = actual.native.children.to_html.gsub(/\s+/, " ")
          response = "#{response[0..120]}..." if response.length > 120
          response.inspect
        end

        def failure_message
          "expected #{describe_expected} but received #{describe_actual} instead"
        end

        def failure_message_when_negated
          "expected not to find #{expected}"
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
katalyst-kpop-3.2.6 lib/katalyst/kpop/matchers/capybara_matcher.rb
katalyst-kpop-3.2.5 lib/katalyst/kpop/matchers/capybara_matcher.rb
katalyst-kpop-3.2.4 lib/katalyst/kpop/matchers/capybara_matcher.rb
katalyst-kpop-3.2.3 lib/katalyst/kpop/matchers/capybara_matcher.rb
katalyst-kpop-3.2.2 lib/katalyst/kpop/matchers/capybara_matcher.rb
katalyst-kpop-3.2.1 lib/katalyst/kpop/matchers/capybara_matcher.rb
katalyst-kpop-3.2.0 lib/katalyst/kpop/matchers/capybara_matcher.rb