Sha256: 7c184660d48c46c9d1e48054387b49c577a87837954ab9ec5ec7b2094f14ffbe
Contents?: true
Size: 624 Bytes
Versions: 28
Compression:
Stored size: 624 Bytes
Contents
require 'nokogiri' module TagMatcher extend RSpec::Matchers::DSL matcher :have_tag do |selector| match do |subject| matches = doc(subject).search(selector) if @inner_text matches = matches.select { |element| element.inner_text == @inner_text } end matches.any? end chain :with_inner_text do |inner_text| @inner_text = inner_text end private def body(subject) if subject.respond_to?(:body) subject.body else subject.to_s end end def doc(subject) @doc ||= Nokogiri::HTML(body(subject)) end end end
Version data entries
28 entries across 28 versions & 4 rubygems