Rails fixtures explorer.
Rails fixtures are hard work. There are different sides to that, but one particular thing is that it's not obvious what other fixtures reference the one you're looking at and what fixtures reference those ones referencing the one you're looking at. And so on.
This little gem to the rescue. It's a command line tool that shows reference tree for a given fixture. It plugs in to vim's quickfix and it shouldn't be too much work to hook it up with vscode, if anyone is up for it.
Demo
fixturex.mp4
Add this line to your application's Gemfile:
gem 'fixturex'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install fixturex
$ bundle exec fixturex test/fixtures/things.yml thing1
Here is one way to plug it into vim. Define a new command - let's call it Fixturex
- in your (project) vimrc:
command! -nargs=0 Fixturex :cexpr system('bundle exec fixturex '. expand('%') .' '.shellescape(expand('<cword>'))) | copen
From then on, if the cursor is on the fixture name in a fixture file, running :Fixturex
will populate the quickfix window with the reference tree.
After checking out the repo, run bin/setup
to install dependencies. Then, run bundle exec rspec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/featurist/fixturex.
The gem is available as open source under the terms of the MIT License.