I use authlogic for my user authentication, and in my ApplicationController I have "current_user", "current_user_session", etc., defined and set as helper_methods.
I have a very simple view for my main index:
RSpec.describe "main/index.html.erb", :type => :view do
context "when not logged in" do
before do
allow(view).to receive(:current_user).and_return(nil)
end
it "has an h1" do
render
expect(rendered).to include('h1')
end
end
end
The problem is that if in my configuration "mocks.verify_partial_doubles = true", then this causes an impressively large error, since it resets the entire object, and then says below:
1) main/index.html.erb when not logged in has an h1
Failure/Error: allow(view).to receive(:current_user).and_return(nil)
@rendered_views={}>> does not implement: current_user
Of course, it is recommended that verify_partial_doubles be set to true, but this will fail. I pulled this straight from the documentation:
https://www.relishapp.com/rspec/rspec-rails/v/3-1/docs/view-specs/view-spec#passing-view-spec-that-stubs-a-helper-method
ApplicationHelper, . ApplicationController helper_method, :
helper_method :current_user, ...
def current_user
return @current_user if defined?(@current_user)
@current_user = current_user_session && current_user_session.record
end
, verify_partial_doubles, ?