# JRuby and tests

**URL:** <https://www.ruby-forum.com/t/jruby-and-tests/106314>\
**Category:** Rails\
**Created:** [June 8, 2007, 12:45pm UTC](https://www.ruby-forum.com/t/jruby-and-tests/106314 "2007-06-08T12:45:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![stevel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/4491bb/32.png) [@stevel](https://www.ruby-forum.com/u/stevel)\
**Post date:** [June 8, 2007, 12:45pm UTC](https://www.ruby-forum.com/t/jruby-and-tests/106314/1 "2007-06-08T12:45:58Z")

</div>

Using JRuby / ActiveRecord-JDBC / PostgreSQL 8.1 I get

jruby --command rake test  
(in /Users/stevel/Publisher)  
rake aborted!  
Task not supported by ‘jdbc’

Is it really the case that testing is not yet supported by  
ActiveRecord-JDBC or am I missing something obvious?

---

<div class="post-metadata">

**Author:** ![stevel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/4491bb/32.png) [@stevel](https://www.ruby-forum.com/u/stevel)\
**Post date:** [June 11, 2007, 7:28pm UTC](https://www.ruby-forum.com/t/jruby-and-tests/106314/2 "2007-06-11T19:28:57Z")

</div>

On 6/8/07, stevel [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Using JRuby / ActiveRecord-JDBC / PostgreSQL 8.1 I get
> 
> jruby --command rake test  
> (in /Users/stevel/Publisher)  
> rake aborted!  
> Task not supported by ‘jdbc’
> 
> Is it really the case that testing is not yet supported by  
> ActiveRecord-JDBC or am I missing something obvious?

Actually, yeah, what you are seeing is the artifact of the big hack  
that is db:test:clone\_structure.

If you are using migrations, you can use them to create your test  
database instead, and that will likely work much better with AR-JDBC.  
Put the following snippet in a “jdbc.rake” file in your lib/tasks  
directory and away you go. Let me know if this works for you.

See also [http://www.nabble.com/forum/ViewPost.jtp?post=9474383&framed=y](http://www.nabble.com/forum/ViewPost.jtp?post=9474383&framed=y)  
for more background.

/Nick  
— begin rake snippet

## Build the test database using migrations rather than dumping the

schema and loading fixtures

# Here we clear out prereqs and actions for the db:test:prepare task

so that it can be redefined  
Rake::Task[“db:test:prepare”].send :instance\_variable\_set,  
“@prerequisites”, FileList[]  
Rake::Task[“db:test:prepare”].send :instance\_variable\_set, “@actions”,  
[]

namespace :db do  
namespace :test do  
task :prepare =\> %w(environment db:test:migrate\_schema)

desc ‘Use the migrations to create the test database’  
task :migrate\_schema =\> ‘db:test:purge’ do |t|  
ActiveRecord::Base.establish\_connection(ActiveRecord::Base.configurations[‘test’])  
ActiveRecord::Schema.verbose = t.application.options.trace  
ActiveRecord::Migrator.migrate(“db/migrate/”)  
end  
end  
end  
— end rake snippet
