How to stub ApplicationController method in request spec

前端 未结 6 1469
难免孤独
难免孤独 2020-12-12 18:16

I am needing to stub the response of a current_user method in an Rspec/capybara request spec. The method is defined in ApplicationController and is

6条回答
  •  长情又很酷
    2020-12-12 18:45

    None of the provided responses worked for me. As in @matt-fordam's original post, I have a request spec, not a controller spec. The test just renders the view without launching a controller.

    I resolved this by stubbing the method on the view as described in this other SO post

    view.stub(:current_user).and_return(etc)
    

提交回复
热议问题