Sha256: 63dea507f1a590dc0cf1d79b57737a182894c252817556e7ccbeb0ca84131cd0

Contents?: true

Size: 861 Bytes

Versions: 6

Compression:

Stored size: 861 Bytes

Contents

require "nokogiri"

def equal_to_dom(text)
  EqualToDom.new(text)
end


def include_dom(text)
  IncludeDom.new(text)
end

class IncludeDom
  def initialize(expectation)
    @expectation = Nokogiri::HTML::DocumentFragment.parse(expectation).to_s
  end

  def matches?(text)
    @matcher = Nokogiri::HTML::DocumentFragment.parse(text).to_s
    @matcher == @expectation
  end

  def failure_message
    "Expected dom \n#{@matcher.inspect}\n to include \n#{@expectation.inspect}\n, but it wasn't"
  end
end


class EqualToDom

  def initialize(expectation)
    @expectation = Nokogiri::HTML::DocumentFragment.parse(expectation).to_s
  end

  def matches?(text)
    @matcher = Nokogiri::HTML::DocumentFragment.parse(text).to_s
    @matcher == @expectation
  end

  def failure_message
    "Expected dom #{@matcher} to match #{@expectation}, but it wasn't"
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
datagrid-0.4.1 spec/support/equal_to_dom.rb
datagrid-0.4.0 spec/support/equal_to_dom.rb
datagrid-0.3.6 spec/support/equal_to_dom.rb
datagrid-0.3.5 spec/support/equal_to_dom.rb
datagrid-0.3.4 spec/support/equal_to_dom.rb
datagrid-0.3.3 spec/support/equal_to_dom.rb