This project is archived and is in readonly mode.
Autoload HTML::Node and Friends
-
josh
- Tag changed from patch to autoload, patch
- Milestone cleared.
- State changed from new to open
- Assigned user set to josh
-
Craig Davey
- Title changed from Autoload HTML::Node to Autoload HTML::Node and Friends
-
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.
-
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...
