spec/spec_helper.rb in fuzzily-0.2.1 vs spec/spec_helper.rb in fuzzily-0.2.2
- old
+ new
@@ -21,15 +21,29 @@
end
RSpec.configure do |config|
config.before(:each) do
# Setup test database
- ActiveRecord::Base.establish_connection(
- :adapter => 'sqlite3',
- :database => Database.to_s
- )
+ if ENV['FUZZILY_USE_PG']
+ ActiveRecord::Base.establish_connection(
+ :adapter => 'postgresql',
+ :database => 'fuzzily_test',
+ :host => 'localhost',
+ :username => 'postgres'
+ )
+
+ ActiveRecord::Base.connection.execute 'DROP TABLE IF EXISTS trigrams;'
+ ActiveRecord::Base.connection.execute 'DROP TABLE IF EXISTS stuffs;'
+ ActiveRecord::Base.connection.execute 'DROP TABLE IF EXISTS foobars;'
+ else
+ ActiveRecord::Base.establish_connection(
+ :adapter => 'sqlite3',
+ :database => Database.to_s
+ )
+ end
+
def prepare_trigrams_table
silence_stream(STDOUT) do
Class.new(ActiveRecord::Migration).extend(Fuzzily::Migration).up
end
end
@@ -41,8 +55,10 @@
end
end
config.after(:each) do
- Database.delete if Database.exist?
+ unless ENV['FUZZILY_USE_PG']
+ Database.delete if Database.exist?
+ end
end
end
\ No newline at end of file