LoginSignup
1
1

More than 5 years have passed since last update.

ファイル名が特定のパターンにマッチする spec を実行するスクリプト

Posted at

ほぼ find | grep $@ | xargs rspec してるだけ。簡単だけど便利。

#!/bin/sh
specs=$(find spec -type f -name "*_spec.rb" | grep $@)
if [ $? -ne 0 ]
then
  echo "spec not found"
  exit 1
fi
echo $specs
rspec $specs

fspec という名前でバスの通ったとこに置いてる。

$ fspec user
spec/controllers/users_controller_spec.rb spec/models/user_spec.rb spec/routing/user_routing_spec.rb spec/views/users/edit.html.haml_spec.rb spec/views1/users/index.html.haml_spec.rb spec/views1/users/new.html.haml_spec.rb spec/views1/users/show.html.haml_spec.rb
.....

引数はそのまま grep に渡るので -E つければ拡張正規表現も使える。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1