Sha256: b36aa7e849435f51de86a5120de819335ce9e85c2bf3fd21da98e35212a6df1c

Contents?: true

Size: 885 Bytes

Versions: 2

Compression:

Stored size: 885 Bytes

Contents

require 'simplecov'
SimpleCov.start do
  add_group 'TopHat', 'lib/tophat'
  add_group 'Specs', 'spec'
end

require File.expand_path('../../lib/tophat', __FILE__)

require 'rspec'
require 'rails/all'

require 'action_controller/vendor/html-scanner'

module HTML
  class Node
    def ==(node)
      return false unless self.class == node.class && children.size == node.children.size

      equivalent = true

      children.size.times do |i|
        equivalent &&= children.include?(node.children[i])
      end

      equivalent
    end
  end
end

RSpec::Matchers.define :be_dom_equivalent_to do |expected|
  match do |actual|
    expected_dom = HTML::Document.new(expected).root
    actual_dom   = HTML::Document.new(actual).root

    expected_dom == actual_dom
  end

  failure_message_for_should do |actual|
    "expected #{actual} would be dom equivalent to #{expected}"
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tophat-1.3.1 spec/spec_helper.rb
tophat-1.3.0 spec/spec_helper.rb