This project is archived and is in readonly mode.

#1462 ✓resolved
Craig Davey

Autoload HTML::Node and Friends

Reported by Craig Davey | November 24th, 2008 @ 09:41 PM

assert_select depends on HTML::Node and but it’s not automatically loaded. This patch resolves that.

Comments and changes to this ticket

  • josh

    josh November 24th, 2008 @ 09:50 PM

    • Tag changed from patch to autoload, patch
    • Milestone cleared.
    • State changed from “new” to “open”
    • Assigned user set to “josh”
  • Craig Davey

    Craig Davey November 25th, 2008 @ 10:35 AM

    • Title changed from “Autoload HTML::Node” to “Autoload HTML::Node and Friends”
  • Craig Davey

    Craig Davey November 25th, 2008 @ 10:40 AM

    When run individually (without rake) these html-scanner test cases all fail:

    actionpack/test/controller/html-scanner/cdata_node_test.rb actionpack/test/controller/html-scanner/node_test.rb actionpack/test/controller/html-scanner/tag_node_test.rb actionpack/test/controller/html-scanner/text_node_test.rb actionpack/test/controller/html-scanner/tokenizer_test.rb actionpack/test/controller/html-scanner/sanitizer_test.rb

    They fail becuase we expect HTML (defined in html-scanner.rb) to provide classes that cannot be loaded automatically. Currently, HTML only registers HTML::Document and four sanitizer classes for autoloading. Helpers like assert_select expect HTML to provide HTML::Node and HTML::Selector automatically but these classes are currently only available if HTML::Document has already been loaded.

    Often, HTML::Document has already been loaded so its easy to miss these bugs. The test cases in question pass if you use rake because other test cases will reference HTML::Document first which requires all the other classes explicitely.

    The inaccessible classes in HTML that are tested and used by Rails are: HTML::CDATA, HTML::Node, HTML::Tag, HTML::Text, HTML::Tokenizer. The attached patch makes all these classes consistently accessible and satisfies all the broken test cases. The changes consisted of moving some classes into their own files and registering each for autoloading.

  • Repository

    Repository November 25th, 2008 @ 04:06 PM

    • State changed from “open” to “resolved”

    (from [f8558798d404f3373517a85fe9e3e8d519c8f3d9]) Ensure all HTML:: constants are available to autoload [#1462 state:resolved]

    Signed-off-by: Joshua Peek

Create your profile

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

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>

People watching this ticket

Referenced by