rails/rails-controller-testing

Error with TemplateAssertions setup

bjallen opened this issue · 1 comments

Something in 69068e0 causes an error when used in a Rails engine.

I have a reduced example in this repo.

$ rake test

Error:
Example::ThingsControllerTest#test_GET_index:
NoMethodError: undefined method `each' for nil:NilClass

It's coming from a nil @_subscribers in the teardown_subscriptions method.

I don't understand the change well enough to know what the fix might be.

Looks like the error happens with just a normal empty rails app as well. The setup callbacks are run before the ActiveSupport.on_load(:action_controller) block gets lazy loaded, so the TemplateAssertions setup isn't registered in time which means that @_subscribers is never instantiated.

ruby 2.3.0
rails 5.0 beta2

rails new example
cd example
echo "gem 'rails-controller-testing', group: :test" >> Gemfile
bundle
rails g scaffold Thing
rails db:migrate
rake test