protected Method

SelectorAssertions.response_from_page_or_rjs

#assert_select and #css_select call this to obtain the content in the HTML page, or from all the RJS statements, depending on the type of response.

Source Code

# File action_controller/assertions/selector_assertions.rb, line 603
def response_from_page_or_rjs()
  content_type = @response.content_type

  if content_type && content_type =~ /text\/javascript/
    body = @response.body.dup
    root = HTML::Node.new(nil)

    while true
      next if body.sub!(RJS_PATTERN_EVERYTHING) do |match|
        html = unescape_rjs($3)
        matches = HTML::Document.new(html).root.children.select { |n| n.tag? }
        root.children.concat matches
        ""
      end
      break
    end

    root
  else
    html_document.root
  end
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.