Skip to content

Instantly share code, notes, and snippets.

@nacengineer
Forked from anonymous/Gemfile
Last active December 14, 2015 01:19
Show Gist options
  • Save nacengineer/5005318 to your computer and use it in GitHub Desktop.
Save nacengineer/5005318 to your computer and use it in GitHub Desktop.
MiniTest Baseline Config
# inside your < Rails::Application block
config.generators do |g|
g.fixture_replacement :factory_girl, dir: 'spec/factories'
g.template_engine :haml
g.test_framework :minitest, spec: true, fixture_replacement: :factory_girl
g.stylesheets false
g.javascripts false
g.helpers false
end
FactoryGirl.define do
factory :object do
end
end
group :development, :test do
gem 'sqlite3'
gem 'trinidad', :platform => :jruby
gem 'unicorn', :platform => :ruby
gem 'better_errors'
gem 'binding_of_caller'
gem 'awesome_print'
gem 'rake'
gem 'pry', :require => false
gem 'chef'
gem "honey_badger", :git => 'https://github.com/rsanheim/honey_badger.git'
end
group :test do
# Pretty printed test output
gem 'turn', :require => false
gem 'simplecov', :require => false
gem 'minitest'
gem 'forgery'
gem 'minitest-spec-rails'
gem 'guard'
gem 'guard-bundler'
gem 'guard-minitest'
gem 'guard-livereload'
gem 'guard-brakeman'
gem 'guard-coffeescript'
if RUBY_PLATFORM =~ /darwin/
gem 'rb-fsevent','~> 0.9.1'
elsif RUBY_PLATFORM =~ /linux/
gem 'rb-inotify'
end
gem 'factory_girl_rails'
end
# More info at https://github.com/guard/guard#readme
notification :tmux,
:display_message => true,
:timeout => 5, # in seconds
:default_message_format => '%s >> %s',
# the first %s will show the title, the second the message
# Alternately you can also configure *success_message_format*,
# *pending_message_format*, *failed_message_format*
:line_separator => ' > ', # since we are single line we need a separator
:color_location => 'status-left-bg' # to customize which tmux element will change color
brakeman_opts = {
:output_file => 'tmp/donkey.html',
:run_on_start => true,
:min_confidence => 3,
:chatty => true
}
group :frontend do
guard :coffeescript, :output => 'public/javascripts/compiled' do
watch(%r{^app/coffeescripts/.+\.coffee$})
end
guard :bundler do
watch('Gemfile')
end
guard :livereload do
watch(%r{^app/.+\.(erb|haml)})
watch(%r{^app/helpers/.+\.rb})
watch(%r{^public/.+\.(css|js|html)})
watch(%r{^config/locales/.+\.yml})
end
end
group :backend do
end
guard 'minitest' do
# with Minitest::Unit
watch(%r|^test/(.*)\/?test_(.*)\.rb|)
watch(%r|^lib/(.*)([^/]+)\.rb|) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
watch(%r|^test/test_helper\.rb|) { "test" }
watch('app/controllers/application_controller.rb') {"test/integration"}
# Rails 3.2
watch('config/routes.rb') {"test/integration"}
watch(%r|^test/.+_test\.rb|)
watch(%r|^app/controllers/(.*)\.rb|) {|m| "test/integration/#{m[1]}_test.rb" }
watch(%r|^app/helpers/(.*)\.rb|) {|m| "test/helpers/#{m[1]}_test.rb" }
watch(%r|^app/models/(.*)\_callback.rb|) {|m| "test/unit/#{m[1]}_test.rb" }
watch(%r|^app/models/(.*)\_validator.rb|) {|m| "test/unit/#{m[1]}_test.rb" }
watch(%r|^app/models/(.*)\.rb|) {|m| "test/unit/#{m[1]}_test.rb" }
watch(%r|^app/models/(.*)\.rb|) {|m| "test/integration/#{m[1]}_test.rb" }
watch(%r|lib/(.+)\.rb|) {|m| "test/lib/#{m[1]}_test.rb" }
# watch(%r|^app/views/(.*+/|) {|m| "test/unit/#{m[1]}_test.rb"}
# watch(%r|^app/views/(.+)/|) {|m| "test/unit/#{m[1]}_test.rb" }
end
guard 'brakeman', brakeman_opts do
watch(%r{^app/.+\.(erb|haml|rhtml|rb)$})
watch(%r{^config/.+\.rb$})
watch(%r{^lib/.+\.rb$})
watch('Gemfile')
end
# post install tasks
# rails g forgery
require 'test_helper'
describe "Check Reset Request Urls" do
class SampleIntegrationTest < ActionDispatch::IntegrationTest
before do
# do something here
end
it "must redirect root page" do
get :index
assert_response :success
end
end
end
require 'test_helper'
class SampleUnitTest < MiniTest::Spec
end
require 'simplecov'
SimpleCov.start 'rails'
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'minitest/autorun'
require 'minitest/spec'
# Uncomment if you want awesome colorful output
require "minitest/pride"
require 'rails'
require 'rails/test_help'
# Add `gem "minitest/rails/capybara"` to the test group of your Gemfile
# and uncomment the following if you want Capybara feature tests
# require "minitest/rails/capybara"
class MiniTest::Spec
include FactoryGirl::Syntax::Methods
end
# class MiniTest::Spec::Rails::Model
# end
# class MiniTest::Spec::Rails::Controller
# # Add methods to be used by controller specs here
# end
# class MiniTest::Spec::Rails::Helper
# # Add methods to be used by helper specs here
# end
# class MiniTest::Spec::Rails::Mailer
# # Add methods to be used by mailer specs here
# end
class MiniTest::Spec::Rails::Integration
include Rails.application.routes.url_helpers
# Add methods to be used by integration specs here
end
include Devise::TestHelpers
class DateTime
include Comparable
end
# use awesome print
require 'awesome_print'
module MiniTest::Assertions
def mu_pp(obj)
obj.awesome_inspect
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment