Sha256: 850074d41a49db6da7036624b519b6e4ce3ab786e23d6e104f9f9a68aab7bb0c

Contents?: true

Size: 1017 Bytes

Versions: 1

Compression:

Stored size: 1017 Bytes

Contents

module MiniTest::Assertions

  def assert_has_css(html, css)
    assert ::Nokogiri::HTML(html).css(css).length > 0,
      "Expected HTML to produce results for CSS selector `#{css}`"
  end

  def refute_has_css(html, css)
    refute ::Nokogiri::HTML(html).css(css).length > 0,
      "Expected HTML to produce no results for CSS selector `#{css}`"
  end

  def assert_has_xpath(html, xpath)
    assert ::Nokogiri::HTML(html).xpath(xpath).length > 0,
      "Expected HTML to produce results for XPath selector `#{xpath}`"
  end

  def refute_has_xpath(html, xpath)
    refute ::Nokogiri::HTML(html).xpath(xpath).length > 0,
      "Expected HTML to produce no results for XPath selector `#{xpath}`"
  end

end

module MiniTest::Expectations

  infect_an_assertion :assert_has_css,   :must_have_css,   :reverse
  infect_an_assertion :refute_has_css,   :wont_have_css,   :reverse

  infect_an_assertion :assert_has_xpath, :must_have_xpath, :reverse
  infect_an_assertion :refute_has_xpath, :wont_have_xpath, :reverse

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rack-nokogiri-0.1.0 spec/support/expectations.rb