k01ken’s b10g

He110 W0r1d!

Railsでテストする方法

■テストスクリプトを用いる

test/models/member_test.rbコメントアウトを外して、
ruby bin/rake db:migrate RAILS_ENV=test
というコマンドを実行。テーブルが加えられるのデータベースは、テスト用になる。
ruby bin/rake test test/models/member_test.rb
というコマンドを実行するとエラーが発生。
f:id:k01ken:20180116030944p:plain
Gemfile内の、

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'

  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'
end

group :development do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'

  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'
end

に変更した。