draper icon indicating copy to clipboard operation
draper copied to clipboard

Decorator can not access controller helper in test

Open swelther opened this issue 7 years ago • 1 comments

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?

swelther avatar Jul 06 '17 09:07 swelther

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.

codebycliff avatar Jul 18 '17 13:07 codebycliff