Permalink
Browse files

Add database cleaners and move specs into their own support file

  • Loading branch information...
1 parent 27b05b6 commit 830fdecacadb0c26e2103fd15b77c1ee255a815b @jordanbyron jordanbyron committed Mar 21, 2012
Showing with 38 additions and 24 deletions.
  1. +1 −0 Gemfile
  2. +2 −0 Gemfile.lock
  3. +1 −23 test/support/integration.rb
  4. +32 −0 test/support/spec.rb
  5. +2 −1 test/test_helper.rb
View
@@ -29,6 +29,7 @@ group 'test' do
gem 'factory_girl_rails'
gem 'colorific'
gem 'test_notifier'
+ gem 'database_cleaner'
end
group :production do
View
@@ -64,6 +64,7 @@ GEM
sass (~> 3.1)
compass-rails (1.0.0.rc.3)
compass (~> 0.12.rc.0)
+ database_cleaner (0.7.1)
erubis (2.7.0)
exception_notification (2.5.2)
actionmailer (>= 3.0.4)
@@ -182,6 +183,7 @@ DEPENDENCIES
coffee-rails (~> 3.2.1)
colorific
compass-rails
+ database_cleaner
draper!
exception_notification
factory_girl_rails
@@ -9,26 +9,4 @@ def sign_in(person)
page.body.must_include("Welcome to Liskov")
end
end
-
- class IntegrationSpec < MiniTest::Spec
- include Rails.application.routes.url_helpers
- include Capybara::DSL
- include Integration
-
- after { Capybara.reset_sessions! }
- end
-
- class ControllerSpec < MiniTest::Spec
- include Rails.application.routes.url_helpers
- include ActiveSupport::Testing::SetupAndTeardown
-
- alias :method_name :__name__ if defined? :__name__
-
- include ActionController::TestCase::Behavior
-
- before { @routes = Rails.application.routes }
- end
-end
-
-MiniTest::Spec.register_spec_type(/Integration$/, Support::IntegrationSpec)
-MiniTest::Spec.register_spec_type(/Controller$/, Support::ControllerSpec)
+end
View
@@ -0,0 +1,32 @@
+require "support/integration"
+
+module Support
+ class IntegrationSpec < MiniTest::Spec
+ include Rails.application.routes.url_helpers
+ include Capybara::DSL
+ include Integration
+
+ before do
+ DatabaseCleaner.start
+ end
+
+ after do
+ Capybara.reset_sessions!
+ DatabaseCleaner.clean
+ end
+ end
+
+ class ControllerSpec < MiniTest::Spec
+ include Rails.application.routes.url_helpers
+ include ActiveSupport::Testing::SetupAndTeardown
+
+ alias :method_name :__name__ if defined? :__name__
+
+ include ActionController::TestCase::Behavior
+
+ before { @routes = Rails.application.routes }
+ end
+
+ MiniTest::Spec.register_spec_type(/Integration$/i, Support::IntegrationSpec)
+ MiniTest::Spec.register_spec_type(/Controller$/i, Support::ControllerSpec)
+end
View
@@ -3,9 +3,10 @@
require 'rails/test_help'
require "capybara/rails"
require "minitest/spec"
-require "support/integration"
+require "support/spec"
Clubhouse::Client.test_mode = true
+DatabaseCleaner.strategy = :truncation
def build_person(person, course = nil)
PersonDecorator.new(FactoryGirl.build(person, course: course))

0 comments on commit 830fdec

Please sign in to comment.