spec/spec_helper.rb in comma-heaven-0.7.2 vs spec/spec_helper.rb in comma-heaven-0.7.3
- old
+ new
@@ -9,48 +9,53 @@
ENV['TZ'] = 'UTC'
Time.zone = 'Eastern Time (US & Canada)'
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
+# ActiveRecord::Base.establish_connection(:adapter => "mysql2", :database => "comma-heaven-test", :user => 'root', :password => '')
ActiveRecord::Base.configurations = true
+# ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.verbose = false
-ActiveRecord::Schema.define(:version => 1) do
- create_table :gardeners do |t|
- t.string :name
- t.string :surname
- t.datetime :birthdate
- end
-
- create_table :gardener_clones do |t|
- t.integer :gardener_id
- t.string :name
- t.string :surname
- end
-
- create_table :trees do |t|
- t.string :name
- t.integer :age
- t.integer :gardener_id
- end
-
- create_table :leafs do |t|
- t.integer :tree_id
- t.string :position
- t.float :size
- t.float :height_from_ground
- end
-
- create_table :cells do |t|
- t.integer :leaf_id
- t.float :weight
- t.float :lat
- t.float :lng
- end
-end
RSpec.configure do |config|
+ config.before(:all) do
+ ActiveRecord::Schema.define(:version => 1) do
+ create_table :gardeners do |t|
+ t.string :name
+ t.string :surname
+ t.datetime :birthdate
+ end
+
+ create_table :gardener_clones do |t|
+ t.integer :gardener_id
+ t.string :name
+ t.string :surname
+ end
+
+ create_table :trees do |t|
+ t.string :name
+ t.integer :age
+ t.integer :gardener_id
+ end
+
+ create_table :leafs do |t|
+ t.integer :tree_id
+ t.string :position
+ t.float :size
+ t.float :height_from_ground
+ end
+
+ create_table :cells do |t|
+ t.integer :leaf_id
+ t.float :weight
+ t.float :lat
+ t.float :lng
+ end
+ end
+ end
+
config.before(:each) do
class Gardener < ActiveRecord::Base
has_many :trees
has_many :leafs, :through => :trees
has_one :gardener_clone
@@ -87,7 +92,17 @@
config.after(:each) do
Object.send(:remove_const, :Gardener)
Object.send(:remove_const, :Tree)
Object.send(:remove_const, :Leaf)
Object.send(:remove_const, :Cell)
+ end
+
+ config.after(:all) do
+ ActiveRecord::Schema.define(:version => 2) do
+ drop_table :gardeners
+ drop_table :gardener_clones
+ drop_table :trees
+ drop_table :leafs
+ drop_table :cells
+ end
end
end