前提
Railsアプリケーション自体は
rails new App -T
でTest::Unitをスキップして作成して、代わりにrspec
とfactory-girl
を入れた状態を想定。
Gemfile
gem 'rspec-rails'
gem 'factory_girl_rails'
railsのバージョンは3.2でも4.0系列でも試している。
使用コマンド
$ rails g scaffold ModelName user:references name description:text amount:integer weight:float active:boolean born_on:date deleted_at:datetime --skip-assets --skip-helper --skip-stylesheets --skip-view-specs --skip-controller-specs --skip-routing-specs --skip-request-specs
jbuilderがいらない場合は以下も
--skip-jbuilder
方針
- Model, View, Controller, Routeは追加
- Javascript, CSS用のファイルは無駄に作らない
- Helperも大抵いらないので作らない
- テストに関してはModelのテストだけを作ってもらう
controller-specsに関してはskipしなくてもいいかと思うけど、他のテストは本当に必要なときに自分で作ったんでいいと思う。・・・実際。
結果
rails3.2
invoke active_record
create db/migrate/20131225083227_create_model_names.rb
create app/models/model_name.rb
invoke rspec
create spec/models/model_name_spec.rb
invoke factory_girl
create spec/factories/model_names.rb
invoke resource_route
route resources :model_names
invoke scaffold_controller
create app/controllers/model_names_controller.rb
invoke erb
create app/views/model_names
create app/views/model_names/index.html.erb
create app/views/model_names/edit.html.erb
create app/views/model_names/show.html.erb
create app/views/model_names/new.html.erb
create app/views/model_names/_form.html.erb
invoke rspec
invoke rspec
invoke scss
rails4.0
invoke active_record
create db/migrate/20131225082800_create_model_names.rb
create app/models/model_name.rb
invoke rspec
create spec/models/model_name_spec.rb
invoke factory_girl
create spec/factories/model_names.rb
invoke resource_route
route resources :model_names
invoke scaffold_controller
create app/controllers/model_names_controller.rb
invoke erb
create app/views/model_names
create app/views/model_names/index.html.erb
create app/views/model_names/edit.html.erb
create app/views/model_names/show.html.erb
create app/views/model_names/new.html.erb
create app/views/model_names/_form.html.erb
invoke rspec
invoke rspec
invoke jbuilder
create app/views/model_names/index.json.jbuilder
create app/views/model_names/show.json.jbuilder