rubocop-rspec icon indicating copy to clipboard operation
rubocop-rspec copied to clipboard

Cop Idea: use fixture_path

Open mockdeep opened this issue 9 years ago • 2 comments

We've got a lot of places in our codebase where people do:

# bad
Rails.root.join('spec', 'fixtures', 'something.pdf')

It would be great to have a cop to enforce using RSpec.configuration.fixture_path:

# good
File.join(fixture_path, 'something.pdf')

mockdeep avatar Dec 10 '16 19:12 mockdeep

Sounds reasonable to me. I personally wont use this so I won't implement it but I'd accept a PR for this.

backus avatar Dec 11 '16 00:12 backus

This one seems better to suggest using file_fixture now. https://relishapp.com/rspec/rspec-rails/v/3-5/docs/file-fixture

And I think this one would be better named RSpec/Rails/FileFixture.

ydah avatar Dec 16 '22 15:12 ydah