Sha256: 4fe9379930a7146643f4bb656f2be22b630f8c4e03e20fbb2956a1de33bedba6

Contents?: true

Size: 486 Bytes

Versions: 12

Compression:

Stored size: 486 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_for_should
      "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

12 entries across 12 versions & 1 rubygems

Version Path
awestruct-0.5.6.beta8 spec/support/nokogiri_matchers.rb
awestruct-0.5.6.beta7 spec/support/nokogiri_matchers.rb
awestruct-0.5.6.beta6 spec/support/nokogiri_matchers.rb
awestruct-0.5.6.beta5 spec/support/nokogiri_matchers.rb
awestruct-0.5.6.beta4 spec/support/nokogiri_matchers.rb
awestruct-0.5.6.beta3 spec/support/nokogiri_matchers.rb
awestruct-0.5.6.beta2 spec/support/nokogiri_matchers.rb
awestruct-0.5.6.beta spec/support/nokogiri_matchers.rb
awestruct-0.5.5 spec/support/nokogiri_matchers.rb
awestruct-0.5.4.2 spec/support/nokogiri_matchers.rb
awestruct-0.5.4.1 spec/support/nokogiri_matchers.rb
awestruct-0.5.4 spec/support/nokogiri_matchers.rb