Sha256: c7fd8b0ac1244f3570623eb83b32f06bc211b063d5dd3fb197d3ee0f65763001

Contents?: true

Size: 671 Bytes

Versions: 12

Compression:

Stored size: 671 Bytes

Contents

# frozen_string_literal: true

module RSpec
  module Support
    module Matchers
      module HTML
        def squish_html(str)
          str
            .gsub(/^[[:space:]]+/, "")
            .gsub(/>[[:space:]]+</m, "><")
            .strip
        end
      end
    end
  end
end

RSpec::Matchers.define :eq_html do |expected_html|
  include RSpec::Support::Matchers::HTML

  match do |actual_html|
    squish_html(actual_html) == squish_html(expected_html)
  end
end

RSpec::Matchers.define :include_html do |expected_html|
  include RSpec::Support::Matchers::HTML

  match do |actual_html|
    squish_html(actual_html).include?(squish_html(expected_html))
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
hanami-2.2.1 spec/support/matchers.rb
hanami-2.2.0 spec/support/matchers.rb
hanami-2.2.0.rc1 spec/support/matchers.rb
hanami-2.2.0.beta2 spec/support/matchers.rb
hanami-2.2.0.beta1 spec/support/matchers.rb
hanami-2.1.0 spec/support/matchers.rb
hanami-2.1.0.rc3 spec/support/matchers.rb
hanami-2.1.0.rc2 spec/support/matchers.rb
hanami-2.1.0.rc1 spec/support/matchers.rb
hanami-2.1.0.beta2.1 spec/support/matchers.rb
hanami-2.1.0.beta2 spec/support/matchers.rb
hanami-2.1.0.beta1 spec/support/matchers.rb