Sha256: 01fd2022b871c486ab2b82c9e824379bc2918edf90374a383ea1907a907e2950

Contents?: true

Size: 475 Bytes

Versions: 17

Compression:

Stored size: 475 Bytes

Contents

require 'nokogiri'

module NokogiriMatchers
  class HtmlMatchers
    def initialize(tag)
      @tag = tag.to_s
    end
    def matches?(document)
      @document = Nokogiri::HTML.fragment document
      !@document.search(@tag).nil?
    end

    def failure_message
      "expected to find #{@tag} within #{@document.to_s} but was not found"
    end
  end

  def have_tag(expect)
    HtmlMatchers.new(expect)
  end
end

RSpec.configure do |c|
  c.include NokogiriMatchers
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
awestruct-0.6.7 spec/support/nokogiri_matchers.rb
awestruct-0.6.6 spec/support/nokogiri_matchers.rb
awestruct-0.6.5 spec/support/nokogiri_matchers.rb
awestruct-0.6.4 spec/support/nokogiri_matchers.rb
awestruct-0.6.3 spec/support/nokogiri_matchers.rb
awestruct-0.6.2 spec/support/nokogiri_matchers.rb
awestruct-0.6.1 spec/support/nokogiri_matchers.rb
awestruct-0.6.0 spec/support/nokogiri_matchers.rb
awestruct-0.6.0.RC1 spec/support/nokogiri_matchers.rb
awestruct-0.6.0.alpha4 spec/support/nokogiri_matchers.rb
awestruct-0.6.0.alpha3 spec/support/nokogiri_matchers.rb
awestruct-0.6.0.alpha1 spec/support/nokogiri_matchers.rb
awestruct-0.5.7 spec/support/nokogiri_matchers.rb
awestruct-0.5.7.RC2 spec/support/nokogiri_matchers.rb
awestruct-0.5.7.RC1 spec/support/nokogiri_matchers.rb
awestruct-0.5.6 spec/support/nokogiri_matchers.rb
awestruct-0.5.6.beta9 spec/support/nokogiri_matchers.rb