Masatoshi Nishiguchi

Setting up Minitest in Rails

This is my memo on Setting up Minitest in Rails.

MiniTest reporters

It gets the default Rails tests to show red and green at the appropriate times.

  1. Include the minitest-reporters gem.
  2. Configure the test by adding these few lines to the test/test_helper.rb file.

Automated tests with Guard

  1. Include the guard gem in the Gemfile.
  2. Initialize it by running $ bundle exec guard init.
  3. Edit the resulting Guardfile so that Guard will run the right tests. [Example]

  4. Open a new terminal and run it at the command line as follows:
$ bundle exec guard # start
$ quit              # exit

Reference

Undoing things in Rails

This is my memo on Undoing things in Rails.

Undo generate

$ rails generate controller FooBars baz quux
$ rails destroy controller FooBars

$ rails generate model Foo bar:string baz:integer
$ rails destroy model Foo

$ rails generate scaffold Micropost content:text user:references
$ rails destroy scaffold Micropost

Undo migrate

$ [bundle exec] rake db:migrate
$ [bundle exec] rake db:rollback

# To go all the way back to the beginning, we can use
$ [bundle exec] rake db:migrate VERSION=0