Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Improve speed a lot by migrating only once instead of once per spec file

  • Loading branch information...
commit d989a2b9f56a4b6c58418ab4355b5b3bc812d212 1 parent 2da8511
Joseph HALTER authored
Showing with 11 additions and 13 deletions.
  1. +11 −13 spec/spec_helper.rb
View
24 spec/spec_helper.rb
@@ -28,16 +28,19 @@ def undefine_models
@defined_models = []
end
+# drop all tables and migrate on start
+db = Sequel::Model.db
+db.tables.each do |table_name|
+ db.drop_table table_name
+end
+Sequel::Migrator.apply(db, File.join(File.dirname(__FILE__), "migrations"))
+
Spec::Runner.configure do |config|
config.include(RspecSequel::Matchers)
-
- # drop all tables and migrate before first spec
- config.before(:all) do
- db = Sequel::Model.db
- db.tables.each do |table_name|
- db.drop_table table_name
- end
- Sequel::Migrator.apply(db, File.join(File.dirname(__FILE__), "migrations"))
+
+ # undefine models defined via define_model (if any)
+ config.after(:all) do
+ undefine_models
end
# truncate all tables between each spec
@@ -48,9 +51,4 @@ def undefine_models
end
end
- # undefine models defined via define_model
- config.after(:all) do
- undefine_models
- end
-
end
Please sign in to comment.
Something went wrong with that request. Please try again.