Last Updated: February 25, 2016
·
1.344K
· rylnd

Turnip Helper, Part 2

I wrote some helpers for turnip <a href='http://coderwall.com/p/senquw'>earlier</a>, but I expanded them to allow for multiple arguments.

It's not quite as pretty, but it works:

turnips() {
  args=(${@:-'*'})
  args=("${args[@]/#/-o -iname }")
  args="${args[@]/%/.feature}"
  args=${args/#-o /}

  eval "find ./spec/acceptance $args"
}

turnip() {
  files=$(turnips $@ | tr '\n' ' ')
  echo "rspec $files"
  rspec $files
}

Now, if you have the same directory structure as before:

└── spec
    └── acceptance
        ├── admin
        │   └── baz.feature
        ├── bar.feature
        └── foo.feature

Calling turnip foo baz will run

rspec ./spec/acceptance/foo.feature ./spec/acceptance/admin/baz.feature

Enjoy!