class RSpecHtmlMatchers::HaveTag
def matches? document, &block
def matches? document, &block @block = block if block document = document.html if defined?(Capybara::Session) && document.is_a?(Capybara::Session) case document when String @parent_scope = Nokogiri::HTML(document) @document = document else @parent_scope = document.current_scope @document = @parent_scope.to_html end @current_scope = begin @parent_scope.css(@tag) # on jruby this produce exception if css was not found: # undefined method `decorate' for nil:NilClass rescue NoMethodError Nokogiri::XML::NodeSet.new(Nokogiri::XML::Document.new) end if tag_presents? and text_right? and count_right? @block.call(self) if @block true else false end end