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

前端 未结 6 2000
太阳男子
太阳男子 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:07

    You just need to include the relevant helper module in your test to make the methods available:

    describe "foo" do
      include ActionView::Helpers
    
      it "does something with a helper method" do
        # use any helper methods here
    

    It's really as simple as that.

提交回复
热议问题