Skip to content

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

Open
@jasonkarns

Description

@jasonkarns

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?

😬

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions