[rspec-users] any idea why spec_server gets 'cannot remove Object' error?

Tom Hoen lists at ruby-forum.com
Wed Jun 24 08:58:24 EDT 2009


Tom Hoen wrote:

In order to suss out what might be cause, i modified the remove_constant 
method in the LoadingModule class 
'\ruby\lib\ruby\gems\1.8\gems\activesupport-2.3.2\lib\active_support\dependencies.rb', 
adding in begin/rescue/end statements.

    def remove_constant(const) #:nodoc:
begin
      return false unless qualified_const_defined? const

      const = $1 if /\A::(.*)\Z/ =~ const.to_s
      names = const.to_s.split('::')
      if names.size == 1 # It's under Object
        parent = Object
      else
        parent = (names[0..-2] * '::').constantize
      end

      log "removing constant #{const}"
      parent.instance_eval { remove_const names.last }
      return true
rescue
      log 'error when removing constant #{const}'
end
    end


This seems to allow the spec_server to operate properly, but I honestly 
don't know what repercussions it may cause.
-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list