Sha256: a86d619a2dfab0c582f618f425867fa8082bc9256958683f9ef719eeeca02267

Contents?: true

Size: 1018 Bytes

Versions: 2

Compression:

Stored size: 1018 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'


RSpec.configure do |config|
  config.before(:suite) do
    TopHat.setup
  end

  config.after(:each) do
    TopHat.reset
  end
end

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.7.1 spec/spec_helper.rb
tophat-1.7.0 spec/spec_helper.rb