I can't figure out the reason of this failing RSpec controller spec:
it 'renders the 404 page when the tenant is inactive' do
allow(MyService).to receive(:call).and_return(true)
post :some_route, params: my_params
expect(response).to render_template(file: "#{Rails.root}/public/404.html")
end
The test fails with:
Failure/Error: expect(response).to render_template(file: "#{Rails.root}/public/404.html", layout: false)
Expected [] to include "/Users/my_rails_app/public/404.html".
It works on Rails 5.2.4 version but fails on Rails 6.1.5.
I asserted the status code to be 404 and it was correct. The response does contain the content of my custom 404.html page.
The method that returns the custom 404 page is defined as follows:
def render_404_html
render file: "#{Rails.root}/public/404.html", layout: false, status: :not_found
end
Any ideas?