Sha256: ab27e4edae7a4c0133cfd19d3d644ba0e159bd70587b762daaecaf19c87e92cc

Contents?: true

Size: 681 Bytes

Versions: 9

Compression:

Stored size: 681 Bytes

Contents

# frozen_string_literal: true

require 'capybara/rspec/matchers/base'
require 'capybara/rspec/matchers/count_sugar'

module Capybara
  module RSpecMatchers
    module Matchers
      class HaveText < WrappedElementMatcher
        include CountSugar

        def element_matches?(el)
          el.assert_text(*@args)
        end

        def element_does_not_match?(el)
          el.assert_no_text(*@args)
        end

        def description
          "text #{format(text)}"
        end

        def format(content)
          content.inspect
        end

      private

        def text
          @args[0].is_a?(Symbol) ? @args[1] : @args[0]
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
capybara-3.24.0 lib/capybara/rspec/matchers/have_text.rb
capybara-3.23.0 lib/capybara/rspec/matchers/have_text.rb
capybara-3.22.0 lib/capybara/rspec/matchers/have_text.rb
capybara-3.21.0 lib/capybara/rspec/matchers/have_text.rb
capybara-3.20.2 lib/capybara/rspec/matchers/have_text.rb
capybara-3.20.1 lib/capybara/rspec/matchers/have_text.rb
capybara-3.20.0 lib/capybara/rspec/matchers/have_text.rb
capybara-3.19.1 lib/capybara/rspec/matchers/have_text.rb
capybara-3.19.0 lib/capybara/rspec/matchers/have_text.rb