views:

128

answers:

1

Ruby 1.8.6, Rails 2.2.2, OS X Tiger

My Test::Unit tests started returning the error below. The relevant line seems to be:

`load_missing_constant': 
  Expected /Users/ethan/project/mtc/webcalendars/app/models/calendar.rb 
  to define Calendar (LoadError)

The file mentioned, calendar.rb looks fine. I can't find any errors in it. I tried removing the unit and functional test files for the Calendar model, but that had no effect on the error.

In the browser the application seems to be functioning normally.

Any insights? Can anyone suggest a way to isolate the problem?

Longer excerpt:

$ rake test
(in /Users/ethan/project/mtc/webcalendars)
/usr/local/bin/ruby -Ilib:test "/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake/rake_test_loader.rb" 
  "test/unit/calendar_event_test.rb" "test/unit/calendar_test.rb" "test/unit/committee_test.rb" 
  "test/unit/event_test.rb" "test/unit/general_app_mailer_test.rb" "test/unit/location_test.rb" 
  "test/unit/persistent_login_test.rb" "test/unit/role_test.rb" "test/unit/user_role_test.rb" 
  "test/unit/user_test.rb" 
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:428:in 
  `load_missing_constant': Expected /Users/ethan/project/mtc/webcalendars/app/models/calendar.rb to define Calendar (LoadError)
    from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:77:in `const_missing'
    from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:89:in `const_missing'

[ ... ]

/usr/local/bin/ruby -Ilib:test "/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib
  /rake/rake_test_loader.rb"  
Errors running test:units and test:functionals!
+1  A: 

Ethan, The only time I've seen this is when I've defined multiple classes in one file. I don't use test:unit too much myself but is it possible that you've defined another class before defining Calendar?

Hope that helps.

robertpostill
Thanks. That was on the right track.
Ethan