Testing Views that use Devise with RSpec

前端 未结 2 1434
暗喜
暗喜 2020-12-09 16:20

I am trying to get a previously passing rspec \"view spec\" to pass after adding Devise\'s user_signed_in? method to the view template in question. The template

2条回答
  •  难免孤独
    2020-12-09 16:52

    The error you're receiving is because you need to include the devise test helpers

    Generally you'll add this (and you might already have) to spec/support/devise.rb

    RSpec.configure do |config|
      config.include Devise::TestHelpers, :type => :controller
    end
    

    But since you're creating a view spec, you'll want something like this:

    RSpec.configure do |config|
      config.include Devise::TestHelpers, :type => :controller
      config.include Devise::TestHelpers, :type => :view
    end
    

提交回复
热议问题