#616 √ resolved
Ryan Lowe

Rails rake test run: Couldn't determine Group part type to instantiate

Reported by Ryan Lowe | June 26th, 2008 @ 09:58 PM | in 1.0 preview

rubinius 0.9.0 (ruby 1.8.6 compatible) (9a01c926d) (06/26/2008) [i686-apple-darwin9.2.2]

Rails version 2.1.0 in vendor/rails

The attached backtrace occurs while running: rbx rake test

on my Rails project, which I'm using to test Rubinius' support for Rails. It is available publicly at GitHub and includes its own vendor/rails:

http://github.com/ryanlowe/unfoo

The project contained a single functional test to see if functional tests were working. The test simply had the line: assert true.

The offending line in Rails 2.1.0 is in selector_assertions.rb line 599-600 and 613-621 refering to a regex stored in the constant RJS_PATTERN_EVERYTHING.

I have commented out the offending lines in vendor/rails to avoid the backtrace until the bug is fixed.

Comments and changes to this ticket

  • Ryan Lowe

    Ryan Lowe June 26th, 2008 @ 10:08 PM

    The block of code in selector_assertions.rb in Rails 2.1.0, starting at line 599:

              RJS_PATTERN_EVERYTHING = Regexp.new("#{RJS_STATEMENTS[:any]}\\(\"([^\"]*)\", #{RJS_PATTERN_HTML}\\)",
                                                  Regexp::MULTILINE)
              RJS_PATTERN_UNICODE_ESCAPED_CHAR = /\\u([0-9a-zA-Z]{4})/
            end
    
            # +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.
            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
    
  • Ryan Lowe

    Ryan Lowe June 26th, 2008 @ 10:13 PM

    Sorry, these lines just above it would be handy too.

    lines 594-598:

              RJS_STATEMENTS[:any] = Regexp.new("(#{RJS_STATEMENTS.values.join('|')})")
              RJS_STATEMENTS[:insert_html] = Regexp.new(RJS_INSERTIONS.collect do |insertion|
                Regexp.quote("new Insertion.#{insertion.to_s.camelize}")
              end.join('|'))
              RJS_PATTERN_HTML = /"((\\"|[^"])*)"/
    
  • Ryan Lowe

    Ryan Lowe June 26th, 2008 @ 10:18 PM

    Sigh... I forgot more missing constants. Here's the whole block, ignore the last comment:

            unless const_defined?(:RJS_STATEMENTS)
              RJS_STATEMENTS = {
                :replace              => /Element\.replace/,
                :replace_html         => /Element\.update/,
                :chained_replace      => /\.replace/,
                :chained_replace_html => /\.update/,
                :remove               => /Element\.remove/,
                :show                 => /Element\.show/,
                :hide                 => /Element\.hide/,
                :toggle                 => /Element\.toggle/
              }
              RJS_INSERTIONS = [:top, :bottom, :before, :after]
              RJS_INSERTIONS.each do |insertion|
                RJS_STATEMENTS["insert_#{insertion}".to_sym] = Regexp.new(Regexp.quote("new Insertion.#{insertion.to_s.camelize}"))
              end
              RJS_STATEMENTS[:any] = Regexp.new("(#{RJS_STATEMENTS.values.join('|')})")
              RJS_STATEMENTS[:insert_html] = Regexp.new(RJS_INSERTIONS.collect do |insertion|
                Regexp.quote("new Insertion.#{insertion.to_s.camelize}")
              end.join('|'))
              RJS_PATTERN_HTML = /"((\\"|[^"])*)"/
              RJS_PATTERN_EVERYTHING = Regexp.new("#{RJS_STATEMENTS[:any]}\\(\"([^\"]*)\", #{RJS_PATTERN_HTML}\\)",
                                                  Regexp::MULTILINE)
              RJS_PATTERN_UNICODE_ESCAPED_CHAR = /\\u([0-9a-zA-Z]{4})/
            end
    
  • Ryan Lowe

    Ryan Lowe June 26th, 2008 @ 10:21 PM

    I put "p RJS_PATTERN_EVERYTHING" at the end of that unless const_defined?(:RJS_STATEMENTS) block and ran it with MRI ruby 1.8.6 (2007-09-24 patchlevel 111) [universal-darwin9.0]

    When I ran script/console to load Rails it gave this output for the regex RJS_PATTERN_EVERYTHING:

    /(?-mix:((?-mix:new\ Insertion\.Before)|(?-mix:Element\.hide)|(?-mix:new\ Insertion\.Top)|(?-mix:new\ Insertion\.Bottom)|(?-mix:\.replace)|(?-mix:Element\.toggle)|(?-mix:Element\.update)|(?-mix:new\ Insertion\.After)|(?-mix:Element\.remove)|(?-mix:\.update)|(?-mix:Element\.replace)|(?-mix:Element\.show)))\("([^"]*)", (?-mix:"((\\"|[^"])*)")\)/m
    
  • Eric Hodel

    Eric Hodel June 27th, 2008 @ 12:00 AM

    • → Tag changed from “rails” to “bug rails regexp”

    /(?-ix:)/.to_s is the minimal reproduction

  • Eric Hodel

    Eric Hodel June 27th, 2008 @ 12:29 AM

    • → State changed from “new” to “resolved”
    • → Assigned user changed from “” to “Eric Hodel”

    Fixed.

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Attachments