Skip to content

Instantly share code, notes, and snippets.

@ikennaokpala
Forked from gnepud/test_helper.rb
Created May 9, 2012 16:17
Show Gist options
  • Save ikennaokpala/2646110 to your computer and use it in GitHub Desktop.
Save ikennaokpala/2646110 to your computer and use it in GitHub Desktop.
MiniTest::Spec with Rails 3.2 setup
group :test do
gem 'minitest'
gem 'capybara'
gem 'turn'
end
rails new phonebook -T
rails g scaffold contact first_name last_name email_address phone_number:integer
rake db:migrate
ruby -Itest test/models/contact_test.rb
rake db:test:prepare
rake
rake TESTOPTS='--seed=53594
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require 'minitest/autorun'
require 'minitest/pride'
require 'capybara/rails'
class MiniTest::Spec
include ActiveSupport::Testing::SetupAndTeardown
include ActiveRecord::TestFixtures
include Rack::Test::Methods
alias :method_name :__name__ if defined? :__name__
self.fixture_path = File.join( Rails.root, 'test', 'factories' )
end
class ControllerSpec < MiniTest::Spec
include Rails.application.routes.url_helpers
include ActionController::TestCase::Behavior
include Rack::Test::Methods
class << self
alias :context :describe
end
before do
@routes = Rails.application.routes
end
register_spec_type( /Controller$/, self)
end
class IntegrationSpec < MiniTest::Spec
include Rails.application.routes.url_helpers
include Capybara::DSL
before do
@routes = Rails.application.routes
end
register_spec_type( /Integration$/, self)
end
class HelperTest < MiniTest::Spec
include ActiveSupport::Testing::SetupAndTeardown
include ActionView::TestCase::Behavior
register_spec_type(/Helper$/, self)
end
Turn.config.format = :outline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment