spec/support/database.rb in pg_search-1.0.4 vs spec/support/database.rb in pg_search-1.0.5

- old
+ new

@@ -36,30 +36,30 @@ if ENV["LOGGER"] require "logger" ActiveRecord::Base.logger = Logger.new(STDOUT) end -def install_extension_if_missing(name, query, expected_result) +def install_extension_if_missing(name, query, expected_result) # rubocop:disable Metrics/AbcSize connection = ActiveRecord::Base.connection postgresql_version = connection.send(:postgresql_version) result = connection.select_value(query) raise "Unexpected output for #{query}: #{result.inspect}" unless result.downcase == expected_result.downcase -rescue => e +rescue begin if postgresql_version >= 90100 ActiveRecord::Base.connection.execute "CREATE EXTENSION #{name};" else share_path = `pg_config --sharedir`.strip ActiveRecord::Base.connection.execute File.read(File.join(share_path, 'contrib', "#{name}.sql")) puts $!.message end - rescue => e2 + rescue => exception at_exit do puts "-" * 80 puts "Please install the #{name} contrib module" puts "-" * 80 end - raise e2 + raise exception end end install_extension_if_missing("pg_trgm", "SELECT 'abcdef' % 'cdef'", "t") unless postgresql_version < 90000