Rspec error while running jruby -S rake spec

Hello All,

I followed steps to install Rspec as in the link pasted below.

http://www.pmamediagroup.com/2009/04/tutorial-install-rspec-rails-factory-girl/

I have jRuby on Rails installed on my machine.Hence all commands need
to be run with jruby -S extension.
However when I run the jruby -S rake spec command,I get the following
error as shown below.


C:\Rspec Test>jruby -S rake spec --trace
(in C:/Rspec Test)
** Invoke spec (first_time)
** Invoke db:test:prepare (first_time)
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
db pool warmup starting… Mon Sep 12 18:05:23
+0530 2011

warmed
up…===========================================…

db pool warmup done… Mon Sep 12 18:05:23
+0530 2011

** Execute db:abort_if_pending_migrations
** Execute db:test:prepare
** Invoke db:test:load (first_time)
** Invoke db:test:purge (first_time)
** Invoke environment
** Execute db:test:purge
RspecTest already exists
** Execute db:test:load
** Invoke db:schema:load (first_time)
** Invoke environment
** Execute db:schema:load
rake aborted!
ActiveRecord::ActiveRecordError: ERROR: cannot drop table channels
because other
objects depend on it
Detail: constraint messages_channel_id_fk on table messages depends
on table c
hannels
constraint invitation_workflow_mapping_invitor on table
invitation_workflows dep
ends on table channels
constraint invitation_workflow_mapping_invited_whom_id on table
invitation_workf
lows depends on table channels
constraint invitation_workflow_mapping_invited_for_channel_id on table
invitatio
n_workflows depends on table channels
Hint: Use DROP … CASCADE to drop the dependent objects too.: DROP
TABLE “cha
nnels”
C:/Rspec Test/vendor/rails/activerecord/lib/active_record/
connection_adapters/ab
stract_adapter.rb:219:in log' c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/activerecord-jdbc-adapter-0.9.7- java/lib/a ctive_record/connection_adapters/jdbc_adapter.rb:582:in execute’
C:/Rspec Test/vendor/rails/activerecord/lib/active_record/
connection_adapters/ab
stract/schema_statements.rb:187:in drop_table' C:/Rspec Test/vendor/rails/activerecord/lib/active_record/ connection_adapters/ab stract/schema_statements.rb:107:in create_table’
C:/Rspec Test/vendor/rails/activerecord/lib/active_record/migration.rb:
352:in m ethod_missing' C:/Rspec Test/vendor/rails/activerecord/lib/active_record/migration.rb: 328:in s
ay_with_time’
c:/jruby-1.5.0/lib/ruby/1.8/benchmark.rb:293:in measure' C:/Rspec Test/vendor/rails/activerecord/lib/active_record/migration.rb: 328:in s
ay_with_time’
C:/Rspec Test/vendor/rails/activerecord/lib/active_record/migration.rb:
348:in m ethod_missing' C:/Rspec Test/db/schema.rb:139 C:/Rspec Test/vendor/rails/activerecord/lib/active_record/schema.rb: 43:in insta
nce_eval’
C:/Rspec Test/vendor/rails/activerecord/lib/active_record/schema.rb:
43:in defin e' C:/Rspec Test/db/schema.rb:12 C:/Rspec Test/db/schema.rb:269:in load’
C:/Rspec Test/vendor/rails/railties/lib/tasks/databases.rake:269
c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in
call' c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in execute’
c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in
each' c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in execute’
c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in
invoke_with _call_chain' c:/jruby-1.5.0/lib/ruby/1.8/monitor.rb:191:in mon_synchronize’
c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in
invoke_with _call_chain' c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in invoke’
C:/Rspec Test/vendor/rails/railties/lib/tasks/databases.rake:317
c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in
call' c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in execute’
c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in
each' c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in execute’
c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in
invoke_with _call_chain' c:/jruby-1.5.0/lib/ruby/1.8/monitor.rb:191:in mon_synchronize’
c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in
invoke_with _call_chain' c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in invoke’
C:/Rspec Test/vendor/rails/railties/lib/tasks/databases.rake:391
c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in
call' c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in execute’
c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in
each' c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in execute’
c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in
invoke_with _call_chain' c:/jruby-1.5.0/lib/ruby/1.8/monitor.rb:191:in mon_synchronize’
c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in
invoke_with _call_chain' c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:607:in invoke_prer
equisites’
c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in
each' c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in invoke_prer
equisites’
c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:596:in
invoke_with _call_chain' c:/jruby-1.5.0/lib/ruby/1.8/monitor.rb:191:in mon_synchronize’
c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in
invoke_with _call_chain' c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in invoke’
c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in
invoke_tas k' c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in top_level’

c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in
each' c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in top_level’

c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in
standard_e xception_handling' c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in top_level’

c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in
run' c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in standard_e
xception_handling’
c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in
run' C:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31 C:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:19:in load’
c:/jruby-1.5.0/bin/rake:19


What does the error indicate,I tried commenting all lines having
drop_database statement in them.
Another thing is that the database already has tables and by using the
tutorial I have just added another table for the bank-account.
Kindly let me know what exactly needs to be done in this case

Thanks & Regards
Chandrika

On Sep 12, 2011, at 2:44 PM, Chandu80 wrote:

** Invoke environment
** Execute db:test:purge
RspecTest already exists
** Execute db:test:load
** Invoke db:schema:load (first_time)
** Invoke environment
** Execute db:schema:load

When you run a spec suite, RSpec delegates to Rails to do the same work
it does before and after a test suite. One task it runs is
db:schema:load, which is defined in Rails. It asks the configured
database for a list of tables and then tries to drop and recreate them.
This ensures that any data from a previous run is removed, and the
schema for the test db matches that of the development db.

constraint invitation_workflow_mapping_invited_whom_id on table
invitation_workf
lows depends on table channels
constraint invitation_workflow_mapping_invited_for_channel_id on table
invitatio
n_workflows depends on table channels
Hint: Use DROP … CASCADE to drop the dependent objects too.: DROP
TABLE “cha
nnels”

What does the error indicate,I tried commenting all lines having
drop_database statement in them.
Another thing is that the database already has tables and by using the
tutorial I have just added another table for the bank-account.
Kindly let me know what exactly needs to be done in this case

The message tells you the underlying problem: there are database
constraints that are not allowing the tables to be deleted in the order
in which the rake task is trying to delete them. For whatever reason,
the active record adapter you are using is not invoking a cascading
delete. What adapter are you using? What database? Also, what other
db-related gems do you have in the app? Just type jruby -S bundle show.

Hi David,
So does that mean that I need to manually delete all other tables for
the rake command to run successfully?

Regards
Chandrika

Hi,
I am using the jdbc adapter because the application I am using is
being developed on Jruby on Rails.

Regards
Chandrika

On Sep 15, 2011, at 9:54 AM, Chandu80 wrote:

** Invoke db:abort_if_pending_migrations (first_time)

** Execute db:schema:load
on table c
Hint: Use DROP … CASCADE to drop the dependent objects too.: DROP

The message tells you the underlying problem: there are database constraints
that are not allowing the tables to be deleted in the order in which the rake task
is trying to delete them. For whatever reason, the active record adapter you are
using is not invoking a cascading delete. What adapter are you using? What
database? Also, what other db-related gems do you have in the app? Just type
jruby -S bundle show.

So does that mean that I need to manually delete all other tables for
the rake command to run successfully?

That needs to happen but the activerecord adapter you are using should
handle it implicitly for you. Which one are you using?