Ruby 1.8.6,Rails 2.2.2,OS X Tiger
我的测试::单元测试开始返回下面的错误。相关的行似乎是:
`load_missing_constant':
Expected /Users/ethan/project/mtc/webcalendars/app/models/calendar.rb
to define Calendar (LoadError)
提到的文件,calendar.rb
看起来很好。我找不到任何错误。我尝试删除Calendar模型的单元和功能测试文件,但这对错误没有影响。
在浏览器中,应用程序似乎正常运行。
任何见解?任何人都可以建议一种方法来隔离问题吗?
更长的摘录:
$ 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!
答案 0 :(得分:1)
探, 我见过这一次的唯一一次是我在一个文件中定义了多个类。我自己不使用test:unit太多了,但是你可能在定义Calendar之前定义了另一个类吗?
希望有所帮助。