[rspec-devel] rspec 0.9.2 broken for Rails users with Oracle.

john.x.andrews at jpmchase.com john.x.andrews at jpmchase.com
Fri May 4 10:27:35 EDT 2007


Upgrading to rspec 0.9.2 from 0.8.2 using Oracle database with 
ActiveRecord breaks due to the following:

oracle_adapter.rb:316
(owner, table_name) = @connection.describe(table_name)

@connection is an instance of OCI8AutoRecover which itself delegates the 
describe method to OCI8.

class OCI8AutoRecover < DelegateClass(OCI8)
  #...
  # no def describe method here
end

DelegateClass internally uses method_missing to call the delegate class' 
describe

class OCI8 #:nodoc:
  def describe(name)
    #...
  end
  #...
end

The problem is that rspec defines Kernel#describe, so method_missing never 
catches the call to delegate and it fails from rspec because there is 
obviously no block given.

My work around modifies 2 files. I'm sorry, I don't have diffs from the 
trunk, but I can get them if you need them. (the firewall at work blocks 
svn traffic!) The following diffs are from 1) my svn repos, and 2) 0.9.2 
rspec gem.
1)
Index: vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/kernel.rb
===================================================================
--- vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/kernel.rb 
(revision 1506)
+++ vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/kernel.rb 
(working copy)
@@ -1,8 +1,10 @@
 module Kernel
   alias_method :original_describe, :describe
   def describe(*args, &block)
-    args << {} unless Hash === args.last
-    args.last[:spec_path] = caller(0)[1]
+    if block_given?
+      args << {} unless Hash === args.last
+      args.last[:spec_path] = caller(0)[1]
+    end
     original_describe(*args, &block)
   end
 end

2) (sorry again, not a real diff)
change from:
  def describe(*args, &block)
    raise ArgumentError if args.empty?
    register_behaviour(Spec::DSL::BehaviourFactory.create(*args, &block))
  end
to:
  def describe(*args, &block)
    if block_given?
      raise ArgumentError if args.empty?
      register_behaviour(Spec::DSL::BehaviourFactory.create(*args, 
&block))
    else
      super *args
    end
  end

I don't know that this is necessarily the best way to fix the problem. I 
only know that my specs pass now. Please let me know if you see a better 
way to fix the issue. I am able to test against a fairly extensive set of 
specs on Oracle.

Regards,
John Andrews


-----------------------------------------
This communication is for informational purposes only. It is not
intended as an offer or solicitation for the purchase or sale of
any financial instrument or as an official confirmation of any
transaction. All market prices, data and other information are not
warranted as to completeness or accuracy and are subject to change
without notice. Any comments or statements made herein do not
necessarily reflect those of JPMorgan Chase & Co., its subsidiaries
and affiliates.

This transmission may contain information that is privileged,
confidential, legally privileged, and/or exempt from disclosure
under applicable law. If you are not the intended recipient, you
are hereby notified that any disclosure, copying, distribution, or
use of the information contained herein (including any reliance
thereon) is STRICTLY PROHIBITED. Although this transmission and any
attachments are believed to be free of any virus or other defect
that might affect any computer system into which it is received and
opened, it is the responsibility of the recipient to ensure that it
is virus free and no responsibility is accepted by JPMorgan Chase &
Co., its subsidiaries and affiliates, as applicable, for any loss
or damage arising in any way from its use. If you received this
transmission in error, please immediately contact the sender and
destroy the material in its entirety, whether in electronic or hard
copy format. Thank you.

Please refer to http://www.jpmorgan.com/pages/disclosures for
disclosures relating to UK legal entities.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-devel/attachments/20070504/de984f99/attachment-0001.html 


More information about the rspec-devel mailing list