[#112] Fix tests for jruby
This commit is contained in:
parent
18247a6c58
commit
35a38086e3
|
@ -66,7 +66,7 @@ module ChiliProject
|
||||||
version = ActiveRecord::Base.connection.select_value('SELECT version()')
|
version = ActiveRecord::Base.connection.select_value('SELECT version()')
|
||||||
raw ? version : version.match(/^PostgreSQL (\S+)/i)[1]
|
raw ? version : version.match(/^PostgreSQL (\S+)/i)[1]
|
||||||
when :sqlite
|
when :sqlite
|
||||||
if RUBY_ENGINE == 'jruby'
|
if Object.const_defined?('RUBY_ENGINE') && ::RUBY_ENGINE == 'jruby'
|
||||||
Jdbc::SQLite3::VERSION
|
Jdbc::SQLite3::VERSION
|
||||||
else
|
else
|
||||||
if SQLite3.const_defined? 'SQLITE_VERSION'
|
if SQLite3.const_defined? 'SQLITE_VERSION'
|
||||||
|
|
|
@ -36,7 +36,7 @@ class ChiliProject::DatabaseTest < ActiveSupport::TestCase
|
||||||
begin
|
begin
|
||||||
ChiliProject::Database.stubs(:adapter_name).returns "SQLite"
|
ChiliProject::Database.stubs(:adapter_name).returns "SQLite"
|
||||||
|
|
||||||
if RUBY_ENGINE == 'jruby'
|
if Object.const_defined?('RUBY_ENGINE') && ::RUBY_ENGINE == 'jruby'
|
||||||
# If we have the SQLite3 gem installed, save the old constant
|
# If we have the SQLite3 gem installed, save the old constant
|
||||||
if Object.const_defined?('Jdbc') && Jdbc::SQLite3.const_defined?('SQLite3')
|
if Object.const_defined?('Jdbc') && Jdbc::SQLite3.const_defined?('SQLite3')
|
||||||
sqlite3_version = Jdbc::SQLite3::VERSION
|
sqlite3_version = Jdbc::SQLite3::VERSION
|
||||||
|
@ -70,7 +70,7 @@ class ChiliProject::DatabaseTest < ActiveSupport::TestCase
|
||||||
assert_equal "1.2.3", ChiliProject::Database.version(true)
|
assert_equal "1.2.3", ChiliProject::Database.version(true)
|
||||||
ensure
|
ensure
|
||||||
# Clean up after us
|
# Clean up after us
|
||||||
if RUBY_ENGINE == 'jruby'
|
if Object.const_defined?('RUBY_ENGINE') && ::RUBY_ENGINE == 'jruby'
|
||||||
if created_module
|
if created_module
|
||||||
Jdbc.instance_eval{remove_const 'SQLite3' }
|
Jdbc.instance_eval{remove_const 'SQLite3' }
|
||||||
elsif sqlite3_version
|
elsif sqlite3_version
|
||||||
|
|
Loading…
Reference in New Issue