Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default file_fixture_path is relative but is absolute in rails itself #2682

Open
jasonkarns opened this issue Jun 8, 2023 · 0 comments
Open

Comments

@jasonkarns
Copy link
Contributor

What Ruby, Rails and RSpec versions are you using?

Ruby version: 3.1.3
Rails version: 7.0.5
RSpec version: 6.0.3

Observed behaviour

Attempting to fix read_fixture method (defined by https://github.com/rails/rails/blob/6be41aded8c067b2b4af3b05193e551f126fb0e3/actionmailer/lib/action_mailer/test_case.rb#L114) and I've discovered that rspec-rails default file_fixture_path is a simple relative string

Expected behaviour

Rails itself sets file_fixture_path in various places, but they all either use File.expand_path with __dir__ or join the string using Rails.root, both of which are absolute paths.

As file_fixture_path is configurable in rspec-rails, it's trivial for users to explicitly set the option to be absolute; however, it doesn't feel very conventional to override the default setting with essentially the same value (we're using the default spec/fixtures directory after all). We just expect the path to be absolute just as it is in rails.

(The need for it to be absolute is to ensure that other methods, like Mailers' read_fixture helper can use file_fixture_path without modification.)

Can you provide an example app?

😬

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant