    # File lib/action_controller/assertions/selector_assertions.rb, line 503
          def assert_select_encoded(element = nil, &block)
            case element
              when Array
                elements = element
              when HTML::Node
                elements = [element]
              when nil
                unless elements = @selected
                  raise ArgumentError, "First argument is optional, but must be called from a nested assert_select"
                end
              else
                raise ArgumentError, "Argument is optional, and may be node or array of nodes"
            end

            fix_content = lambda do |node|
              # Gets around a bug in the Rails 1.1 HTML parser.
              node.content.gsub(/<!\[CDATA\[(.*)(\]\]>)?/m) { CGI.escapeHTML($1) }
            end

            selected = elements.map do |element|
              text = element.children.select{ |c| not c.tag? }.map{ |c| fix_content[c] }.join
              root = HTML::Document.new(CGI.unescapeHTML("<encoded>#{text}</encoded>")).root
              css_select(root, "encoded:root", &block)[0]
            end

            begin
              old_selected, @selected = @selected, selected
              assert_select ":root", &block
            ensure
              @selected = old_selected
            end
          end