Gemfile
group :development do
gem 'powder'
gem 'pry-rails'
gem 'better_errors'
gem 'binding_of_caller'
gem 'meta_request'
gem 'xray-rails'
gem 'letter_opener'
gem 'guard' # Use `guard init` to setup
gem 'rb-fsevent', require: false
gem 'guard-pow'
gem 'guard-minitest'
gem 'guard-livereload'
gem "rack-livereload" # Need to put `config.middleware.use Rack::LiveReload` in your config/environments/development.rb file
gem 'ruby_gntp'
end
group :development, :test do
gem "minitest-rails", github: 'blowmage/minitest-rails'
gem "factory_girl_rails", ">= 4.2.0"
gem 'ffaker'
# gem "email_spec"
end
Go through install instructions for each gem
-
rails generate mini_test:install
-
factory_girl_rails No additional install instructions
Usage: rails g factory_girl:model NameOfModel
- Make sure your test DB exists, there are several ways of preparing it, you want to make sure it's created and migrated to the latest.
You should only need to do one of these three:
rake db:test:prepare
rake db:test:load
RAILS_ENV=test rake db:migrate
-
Setup your User factory (use ffaker if desired)
-
Use TDD approach to write tests for your existing features
-
(Optional) Use TDD to write new features
** Test validations, callbacks, methods (don't worry about the after_create: :send_welcome_email)
- Repeat steps above for message test
test_helper:
ENV["RAILS_ENV"] = "test"
require File.expand_path("../../config/environment", __FILE__)
require "rails/test_help"
require "minitest/rails"
require "minitest/spec" # require this if you wan't spec syntax support
# To add Capybara feature tests add `gem "minitest-rails-capybara"`
# to the test group in the Gemfile and uncomment the following:
# require "minitest/rails/capybara"
# Uncomment for awesome colorful output
require "minitest/pride"
class ActiveSupport::TestCase
include FactoryGirl::Syntax::Methods
# Add more helper methods to be used by all tests here...
end