spec/support/database.rb in pg_search-2.3.6 vs spec/support/database.rb in pg_search-2.3.7
- old
+ new
@@ -8,14 +8,14 @@
require "pg"
ERROR_CLASS = PG::Error
end
begin
- connection_options = { adapter: 'postgresql', database: 'pg_search_test', min_messages: 'warning' }
+ connection_options = {adapter: "postgresql", database: "pg_search_test", min_messages: "warning"}
if ENV["CI"]
- connection_options[:username] = 'postgres'
- connection_options[:password] = 'postgres'
+ connection_options[:username] = "postgres"
+ connection_options[:password] = "postgres"
end
ActiveRecord::Base.establish_connection(connection_options)
connection = ActiveRecord::Base.connection
connection.execute("SELECT 1")
rescue ERROR_CLASS, ActiveRecord::NoDatabaseError => e
@@ -38,11 +38,11 @@
connection = ActiveRecord::Base.connection
extension = connection.execute "SELECT * FROM pg_catalog.pg_extension WHERE extname = '#{name}';"
return unless extension.none?
connection.execute "CREATE EXTENSION #{name};"
-rescue StandardError => e
+rescue => e
at_exit do
puts "-" * 80
puts "Please install the #{name} extension"
puts "-" * 80
end
@@ -50,20 +50,20 @@
end
def install_extension_if_missing(name, query, expected_result)
result = ActiveRecord::Base.connection.select_value(query)
raise "Unexpected output for #{query}: #{result.inspect}" unless result.casecmp(expected_result).zero?
-rescue StandardError
+rescue
install_extension(name)
end
install_extension_if_missing("pg_trgm", "SELECT 'abcdef' % 'cdef'", "t")
install_extension_if_missing("unaccent", "SELECT unaccent('foo')", "foo")
install_extension_if_missing("fuzzystrmatch", "SELECT dmetaphone('foo')", "f")
def load_sql(filename)
connection = ActiveRecord::Base.connection
- file_contents = File.read(File.join(File.dirname(__FILE__), '..', '..', 'sql', filename))
+ file_contents = File.read(File.join(File.dirname(__FILE__), "..", "..", "sql", filename))
connection.execute(file_contents)
end
load_sql("dmetaphone.sql")