This project is archived and is in readonly mode.

#1890 ✓wontfix
Niels Meersschaert

Tests which use assert_select fail in 2.3.0 RC1 when upgrading an app

Reported by Niels Meersschaert | February 5th, 2009 @ 10:37 PM

If I have an assert_select in my test like assert_select "input#system_article_name[type='text']", I get the following stacktrace as an error when running the tests. This occurs both with autotest & with rake test

NameError: uninitialized constant HTML::Document

activesupport (2.3.0) lib/active_support/dependencies.rb:440:in `load_missing_constant'
activesupport (2.3.0) lib/active_support/dependencies.rb:80:in `const_missing'
actionpack (2.3.0) lib/action_controller/test_process.rb:484:in `html_document'
actionpack (2.3.0) lib/action_controller/assertions/selector_assertions.rb:614:in `response_from_page_or_rjs'
actionpack (2.3.0) lib/action_controller/assertions/selector_assertions.rb:213:in `assert_select'
/test/functional/system_articles_controller_test.rb:20:in `test_get_new'
activesupport (2.3.0) lib/active_support/testing/setup_and_teardown.rb:57:in `__send__'
activesupport (2.3.0) lib/active_support/testing/setup_and_teardown.rb:57:in `run'

Comments and changes to this ticket

  • DHH

    DHH February 6th, 2009 @ 01:41 PM

    • Assigned user set to “josh”
    • Milestone cleared.
  • josh

    josh February 7th, 2009 @ 05:30 AM

    • State changed from “new” to “wontfix”

    Make sure you are using ActionController::TestCase or ActionController::IntegrationTest.

    I thought this would be an autoload issue, but I tried with a fresh scaffold and assert_select works fine.

  • Niels Meersschaert

    Niels Meersschaert February 9th, 2009 @ 03:10 PM

    • Title changed from “Tests which use assert_select fail in 2.3.0 RC1” to “Tests which use assert_select fail in 2.3.0 RC1 when upgrading an app”

    The test in question, like all the rest in my project inherit from ActionController::TestCase. class SystemArticlesControllerTest < ActionController::TestCase. The stacktrace provided was just one. Every controller test in my app which uses assert_select fails with that error. This app did start out as a 1.x Rails app, so it has been upgraded over time. Is there something outside of the ActionController::TestCase which could explain the load order issue this exposes?

  • josh

    josh February 9th, 2009 @ 03:15 PM

    I doubled checked and it looks like HTML "should" be autoloading correctly. I'm really surprised that this happens with "rake", it would more commonly happen if you ran you test standalone.

    Can you try adding "require 'html/document'" to the top of your tests (this is not the correct solution). I'm just hoping that fixes it and we can confirm its an autoloading issue.

  • Niels Meersschaert

    Niels Meersschaert February 9th, 2009 @ 03:32 PM

    I think this is getting us closer.... now I get:

    /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in gem_original_require': no such file to load -- html/document (MissingSourceFile)

    from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
    from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.0/lib/active_support/dependencies.rb:158:in `require'
    from ./test/functional/system_articles_controller_test.rb:2
    from /Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake/rake_test_loader.rb:5:in `load'
    from /Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake/rake_test_loader.rb:5
    from /Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake/rake_test_loader.rb:5:in `each'
    from /Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake/rake_test_loader.rb:5
    
    

    This happens when I place the require just below the test_helper require as well as if I place it inside the class block.

    So perhaps the autoload can't locate the class properly based on the html/document reference?

  • Niels Meersschaert

    Niels Meersschaert February 9th, 2009 @ 05:39 PM

    I found another symptom which might be causing this. The first controller failure resulted in this stacktrace:

    test_changelog_do_not_exist(Admin::AboutControllerTest): NoMethodError: undefined method id2name' for {:instance_writer=>false}:Hash

    money (1.7.1) lib/support/cattr_accessor.rb:7:in `cattr_reader'
    money (1.7.1) lib/support/cattr_accessor.rb:5:in `each'
    money (1.7.1) lib/support/cattr_accessor.rb:5:in `cattr_reader'
    money (1.7.1) lib/support/cattr_accessor.rb:54:in `cattr_accessor'
    actionpack (2.3.0) lib/action_controller/vendor/html-scanner/html/sanitizer.rb:44
    activesupport (2.3.0) lib/active_support/dependencies.rb:158:in `require'
    actionpack (2.3.0) lib/action_controller/vendor/html-scanner/html/document.rb:4
    actionpack (2.3.0) lib/action_controller/test_process.rb:484:in `html_document'
    actionpack (2.3.0) lib/action_controller/assertions/selector_assertions.rb:614:in `response_from_page_or_rjs'
    actionpack (2.3.0) lib/action_controller/assertions/selector_assertions.rb:213:in `assert_select'
    /test/functional/admin/about_controller_test.rb:49:in `test_changelog_do_not_exist'
    activesupport (2.3.0) lib/active_support/testing/setup_and_teardown.rb:57:in `__send__'
    activesupport (2.3.0) lib/active_support/testing/setup_and_teardown.rb:57:in `run'
    
    

    Every controller after that failed with NameError: uninitialized constant HTML::Document

  • josh

    josh February 9th, 2009 @ 06:11 PM

    • State changed from “wontfix” to “open”

    Weirdness.

    Could you try creating a minimal rails app with this failure. It could be some quirkiness with your Rails app.

  • Niels Meersschaert

    Niels Meersschaert February 9th, 2009 @ 06:17 PM

    It appears that the Money gem may be overstepping some rails calls thus causing this issue.

  • Niels Meersschaert

    Niels Meersschaert February 9th, 2009 @ 06:53 PM

    I believe it was caused because my app uses ActiveMerchant as a plugin. As a result, I had a config.gem "money" requirement. When I removed that requirement, the cattr_accessor errors went away, as well as the HTML::Document issues. I believe it was a collision between the 2, as I couldn't replicate it in a fresh app.

    My apologies that this isn't purely a Rails issue. This does point to a potential conflict that only appears to have been introduced in 2.3.0, but as to whether that is a Money gem/Active Merchant issue or a Rails issue, I'll leave as an open question.

  • josh

    josh February 9th, 2009 @ 08:13 PM

    • State changed from “open” to “wontfix”

    You may want to try with the edge release of ActiveMerchant to see if the problem exists there.

    If it turns out to be something funky with our code, I'd be happy to apply a patch. I'd hate to see ActiveMerchant have to hack around a Rails issue.

  • rob

    rob February 9th, 2009 @ 11:01 PM

    Had the same issue, updating the Money gem to 2.0.0 fixed it.

  • Niels Meersschaert

    Niels Meersschaert February 11th, 2009 @ 05:12 PM

    Also using ActiveMerchant as a gem v1.4.1 eliminates the issue. It looks like the conflict is only between older versions of ActiveMerchant/Money & Rails 2.3.0. Updating both eliminates the conflict.

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="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Tags

Referenced by

Pages