Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Autoload HTML::Node and Friends

#1462

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

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

State: resolved
Milestone: none
Assigned to: josh josh
Importance: none

Activity

  1. josh
    josh
    • Tag changed from patch to autoload, patch
    • Milestone cleared.
    • State changed from new to open
    • Assigned user set to josh

    November 24th, 2008 @ 09:50 PM

  2. Craig Davey
    Craig Davey
    • Title changed from Autoload HTML::Node to Autoload HTML::Node and Friends

    November 25th, 2008 @ 10:35 AM

  3. Craig Davey
    Craig Davey

    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.

    November 25th, 2008 @ 10:40 AM

  4. Repository
    Repository
    • State changed from open to resolved

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

    Signed-off-by: Joshua Peek josh@joshpeek.com http://github.com/rails/rails/co...

    November 25th, 2008 @ 04:06 PM