Any idea why spec_server gets 'cannot remove Object' error?

I am sure better minds than mine can figure this out, but I am stumped.

When I run any spec using spec_server, a get 0 failures and the command
prompt returns without issue.

If I run the same spec again, I still get 0 failures, but it concludes
with the following error:

(druby://127.0.0.1:8989)
c:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:603:in
remove_const': Cannot remove Object::ClassMethods (NameError) from (druby://127.0.0.1:8989) c:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:603:inremove_constant’
from (druby://127.0.0.1:8989)
c:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:603:in
instance_eval' from (druby://127.0.0.1:8989) c:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:603:inremove_constant’
from (druby://127.0.0.1:8989)
c:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:450:in
remove_unloadable_constants!' from (druby://127.0.0.1:8989) c:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:450:ineach’
from (druby://127.0.0.1:8989)
c:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:450:in
remove_unloadable_constants!' from (druby://127.0.0.1:8989) c:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:236:inclear’
from (druby://127.0.0.1:8989)
c:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/dispatcher.rb:65:in
cleanup_application' from (druby://127.0.0.1:8989) c:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/rspec-rails-1.2.6/lib/spec/rails/spec_server.rb:106:inrun’
from
c:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/drb_command_line.rb:14:in
run' from c:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/option_parser.rb:193:inparse_drb’
from
c:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/option_parser.rb:130:in
order!' from c:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner.rb:51:inoptions’
from
c:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/command_line.rb:6:in
run' from c:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/bin/spec:4 from c:/InstantRails-2.0-win/ruby/bin/spec:19:inload’
from c:/InstantRails-2.0-win/ruby/bin/spec:19

running the spec a third time, most of my tests fail with the following
sample error:
TypeError in ‘School can add staff_members’
can’t dup NilClass

If I kill the spec_server, restart it, the cycle begins again.

Previously, spec server ran without issue, using individual

I am running:
rspec and rspec on rails 1.2.6
Rails 2.3.2
ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]
Windows Vista

Any thoughts would be greatly appreciated.

Tom

On Tue, Jun 23, 2009 at 4:12 AM, Tom H.[email protected] wrote:

remove_const': Cannot remove Object::ClassMethods (NameError) c:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:450:in from (druby://127.0.0.1:8989) parse_drb’
c:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/bin/spec:4

Previously, spec server ran without issue, using individual

Previously to what? What changed?

Also - just a heads up that spec_server is deprecated in 1.2.7 and
will be removed in 1.2.8. I prefer to avoid removing things in point
releases, but spec_server has been problematic (behaving very
differently for a lot of different environments and configurations),
and Tim H.'s new spork gem [1] serves the same purpose in a very
elegant way, so the migration path is simple.

gem install spork
cd path/to/project
spork bootstrap --rspec

edit spec/spec_helper.rb

You may have better luck if you migrate now.

Cheers,
David

[1] http://github.com/timcharper/spork

David - Thank you for responding.

Previously to what? What changed?

The only changes were some additional models/controllers and specs for
both, and I installed and used (in one of the models) open_ssl. My plan
it to revert until I find a point at which things start to work again,
unless someone has a better idea.

gem install spork
cd path/to/project
spork bootstrap --rspec

edit spec/spec_helper.rb

Alas, I develop on Windows. So no spork. As of yet.

Thanks for your advice.
Tom

Tom H. 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.

Tim H. wrote:

There is no voting love on the windows feature request:

http://github.com/timcharper/spork/issues
:slight_smile:

I tried to vote a +1, but get this after clicking the Comment button:

There was a problem serving the requested page.

Now you’re wondering, “what can I do about it!?!”. Well…

Have you heard of anyone that has rspec/spork/cucumber etc running under
cygwin, colinux, andLinux, or Ulteo Virtual Desktop. Do any of them
allow for fork?

There is no voting love on the windows feature request:

http://github.com/timcharper/spork/issues
:slight_smile: