This project is archived and is in readonly mode.
Tests which use assert_select fail in 2.3.0 RC1 when upgrading an app
-
DHH
- Assigned user set to josh
- Milestone cleared.
-
josh
- 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
- 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
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
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:5This 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
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}:Hashmoney (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
- 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
It appears that the Money gem may be overstepping some rails calls thus causing this issue.
-
Niels Meersschaert
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
- 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
Had the same issue, updating the Money gem to 2.0.0 fixed it.
-
Niels Meersschaert
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.