draper
draper copied to clipboard
Decorator can not access controller helper in test
Today I noticed a weird behaviour during my request spec:
The controller defines a helper method which is called from the decorator. But during the test this helper is not available.
Please see this gist with a sample app that reproduces the problem, using Ruby 2.3.3:
https://gist.github.com/swelther/47c5ffb707ca1145ca87d1dfb8aa99fa
My real world app uses RSpec instead of Minitest, but the result is the same.
Shouldn't it be possible to access helpers defined in the controller? What can I do to fix this?
Thanks for reporting this issue. It looks like it has been around for a while. It appears to have to do with the ViewContext
not being cleared after each spec. I'll look into this and get back to you.