I'm upgrading a 4.1.8
app. It has a bunch of controller tests. After the upgrade to 4.2
, every test fails with:
61) Error:
StripeEventsControllerTest#test_handles_known_class:
NoMethodError: undefined method `clear' for nil:NilClass
test/controllers/stripe_events_controller_test.rb:14:in `block in <class:StripeEventsControllerTest>'
Digging in to Rails, it appears that it's due to this line: https://github.com/rails/rails/blob/master/actionpack/lib/action_controller/test_case.rb#L70
It flows like this:
https://github.com/rails/rails/blob/master/actionpack/lib/action_controller/test_case.rb#L506 https://github.com/rails/rails/blob/master/actionpack/lib/action_controller/test_case.rb#L64
Some debugging before the request is made in the test:
[1] pry(#<MarketingControllerTest>)> RENDER_TEMPLATE_INSTANCE_VARIABLES.each { |i| puts i }
partials
templates
layouts
[3] pry(#<MarketingControllerTest>)> RENDER_TEMPLATE_INSTANCE_VARIABLES.each { |i| puts instance_variable_get("@_#{i}").nil? }
true
true
true
true
It's like the setup block isn't being called:
def setup_subscriptions
RENDER_TEMPLATE_INSTANCE_VARIABLES.each do |instance_variable|
instance_variable_set("@_#{instance_variable}", Hash.new(0))
end