-
-
Save ikennaokpala/2646110 to your computer and use it in GitHub Desktop.
MiniTest::Spec with Rails 3.2 setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
group :test do | |
gem 'minitest' | |
gem 'capybara' | |
gem 'turn' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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