Skip to content

Instantly share code, notes, and snippets.

@elle
Created November 19, 2013 10:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elle/7543289 to your computer and use it in GitHub Desktop.
Save elle/7543289 to your computer and use it in GitHub Desktop.
test_helper.rb
ENV['RAILS_ENV'] = 'test'
require File.expand_path('../dummy/config/environment.rb', __FILE__)
require 'rails/test_help'
require 'minitest/autorun'
require 'minitest/spec'
require 'minitest/mock'
require 'capybara/rails'
require 'valid_attribute'
require 'debugger'
# check: http://rubydoc.info/gems/minitest-reporters/0.4.0/file/README.md
require 'minitest/reporters'
MiniTest::Reporters.use! MiniTest::Reporters::SpecReporter.new
Rails.backtrace_cleaner.remove_silencers!
# Load support files
Dir['#{File.dirname(__FILE__)}/support/**/*.rb'].each { |f| require f }
require 'database_cleaner'
DatabaseCleaner.strategy = :truncation
class MiniTest::Spec
include FactoryGirl::Syntax::Methods
# minitest-matchers. so we can use: have_valid()
include ValidAttribute::Method
before(:each) do
DatabaseCleaner.start
end
after(:each) { DatabaseCleaner.clean }
def show(object, label=nil)
ap "#{label}:" if label
ap object
end
class << self
alias context describe
end
end
class FeatureTest < MiniTest::Spec
include Rails.application.routes.url_helpers # to get url_helpers working
include Capybara::DSL # to get capybara working
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment