How to import Rails helpers in to the functional tests

前端 未结 4 2011
谎友^
谎友^ 2021-01-19 16:48

Hi I recently inherited a project in which the former dev was not familiar with rails, and decided to put a lot of important logic into the view helpers.

cla         


        
4条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-19 17:23

    To be able to use Devise in your tests, you should add

    include Devise::TestHelpers
    

    to each ActionController::TestCase instance. Then in the setup method you do

    sign_in users(:one)
    

    instead of

    current_user = users(:one)
    

    All your functional tests should work fine, then.

提交回复
热议问题