How to call an app helper method from an RSpec test in Rails?

前端 未结 6 2140
太阳男子
太阳男子 2021-02-05 02:56

The title is self explanatory.

Everything I\'ve tried led to a \"undefined method\".

To clarify, I am not trying to test a helper method. I am trying to use a he

6条回答
  •  花落未央
    2021-02-05 03:33

    If you are trying to use a helper method on your view test, you can go with the following:

    before do
      view.extend MyHelper
    end
    

    It must be inside a describe block.

    It works for me on rails 3.2 and rspec 2.13

提交回复
热议问题