expect(response).to render_template(file: "#{Rails.root}/public/404.html")

52 views
Skip to first unread message

belgoros

unread,
May 24, 2022, 3:56:13 AM5/24/22
to rspec
I have a controller spec passing in Rails 5.2 but failing in Rails 6.1.5:

```
expect(response).to render_template(file: "#{Rails.root}/public/404.html")
```
What can be different between 2 Rails versions?

The error I get:

```

Failure/Error: expect(response).to render_template(file: "#{Rails.root}/public/404.html")

       Expected [] to include "/Users/XXX/my_rails_app/public/404.html".

```

Used spec-rails version: 4.0.2.

Any ideas?


belgoros

unread,
May 24, 2022, 5:01:13 AM5/24/22
to rspec
When I check the status of the response, it is correct in both, Rails 5.2 and 6.1.5 version - 404.

belgoros

unread,
May 24, 2022, 5:16:34 AM5/24/22
to rspec
The difference is also in the version of `rails-controller-testing` gem:
- 1.0.5 for Rails 6.1.5
- 1.0.4 for Rails 5.2.4

Jon Rowe

unread,
May 26, 2022, 5:19:30 AM5/26/22
to rs...@googlegroups.com
Hi

Have you tried upgrading rspec-rails to `5.1.2` thats where support for Rails 6.1 exists and there were some changes in this area.

Cheers
Jon
--
You received this message because you are subscribed to the Google Groups "rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rspec+un...@googlegroups.com.

belgoros

unread,
May 26, 2022, 5:29:54 AM5/26/22
to rspec
It seems like there was some discussions about the same issue:

and there is a PR waiting to be merged:
https://github.com/rails/rails-controller-testing/pull/76

belgoros

unread,
May 26, 2022, 5:44:03 AM5/26/22
to rspec
Upgrading to rspec-rails 5.1 fixed the issue. Thanks a lot!
Reply all
Reply to author
Forward
0 new messages