LoginSignup
6
6

More than 5 years have passed since last update.

既存のrailsアプリケーションにcontrollerのrspecテストを追加する場合のひな形サッと作る奴

Posted at

既存のrailsアプリケーションにcontrollerのrspecテストを追加する場合のひな形サッと作る奴

# hugeコントローラ
rails g rspec:controller huge `rake routes | grep 'huge#' | sed -e 's/^.*huge#\([a-z0-9_]*\).*$/\1/g' | xargs`

作成したいコントローラ羅列して実行するコマンド一気に出力する奴
(Dir.chdirとかしてexecすればそのまま実行出来そう(そこまでやらなくても良いけど))

%w|
amagi
log/horaizun
shirobako
nanatsu_no/taizai
denkigai/no/honyasan
ino_battle
|.each do |controller|
  puts "rails g rspec:controller #{controller} `rake routes | grep '#{controller}#' | sed -e 's/^.*#{controller.gsub('/', '\/')}#\\([a-z0-9_]*\\).*$/\\1/g' | xargs`"
end

rails g rspec:controller huge
でひな形作れるんだけどアクション毎の行毎回書きたくない and 書きたくない

アクション名指定すれば作ってくれるんだけど
(indexアクション rails g rspec:controller huge index)

アクション毎回指定するの面倒くさい and 面倒くさい なのでコマンドでそのままやるやつ

6
6
2

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
6
6