I am attempting to test a stand-alone script.  I wish to call the script
from inside the test framework, passing it a variety of command line
arguments, and verify the results.

The difficulty I have is that the testing framework I am using,
cucumber, holds db updates inside an incomplete db transaction.  It
thereby avoids the processing cost of an actual commit while easily
resetting the db for the next test by performing a rollback at the end
of the present test.

In this situation, opening a new instance of the script via the backtick
kernel method creates a new db connection.  Since this is a different
connection from that opened by the test framework, incomplete
transactions are invisible to it and so the script fails, because the
test data is not available.  What I would like to do is to execute the
script inside the existing Ruby instance and inherit the DB connection.
This I cannot figure out how to accomplish.  I thought that simply
"load"ing the script would suffice, but no.  In this case it evidently
neither opens its own connection nor inherits the existing one for I
receive this error at the load statement.

      PGError: not connected: ROLLBACK (ActiveRecord::StatementInvalid)
      
/usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract_adapter.rb:212:in
`log'

Does anyone have any ideas on how I can accomplish what I desire?
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to