1.アプリケーション作成時にtestファイルを作らないようにする
rails new
する際、次のようなオプションを指定して実行します。
ターミナル
& rails new myApp -T
-Tオプション(または--skip-test-unit)をつけることで、test::unit
を組み込まない状態でrails new
ができます。
2.すでに作成したアプリケーションに対して適用する場合
application.rb
ファイルのclass Application < Rails::Application
内を次のように編集します。
application.rb
module Practice
class Application < Rails::Application
# ---------------追記部分--------------
config.generators do |g|
g.test_framework false
end
#----------------追記終了--------------
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
end
end
このように記述することでrails g model
などを実行した時、テストファイルを作成することがなくなります。
参考url
1.rails g コマンドでテストを作らないようにする方法
2.Rails ドキュメント railsコマンド(rails)
3.Railsのgenerateコマンドを俺好みに設定する
4.Ruby on Rails: Switch from test_unit to rspec
(g.test_frameworkの指定の仕方を参考にしました。)