Proposal: Make using #file_fixture less chaotic

Recently I’ve been working with some fixtures and this method exists in rails, however in my experimentation you cannot organize them into directories.

Basically you must have the fixture living in spec/fixtures/files/ (by default in rspec) and cannot nest the fixtures in for example spec/fixtures/files/parent/ for your children.json fixture.

To solve this problem, I think it makes sense to just provide the path from the file_fixture_path (spec/fixtures/files/) to the actual fixture location.

Simply change def file_fixture(fixture_name) to def file_fixture(path_from_fixture_path) and use the path provided to grab the desired fixture.

Bringing it all together, the invocation would perhaps look something like file_fixture('parent/children.json') versus having them all living in the default fixture location like so file_fixture('parent_children.json') which isn’t very tidy.

If there is interest I will struggle more with coming up with better argument names. Thanks for your time!

1 Like