【问题标题】:Tests suddenly erroring out. Anyone seen this error?测试突然出错。有人看到这个错误吗?
【发布时间】:2009-03-06 01:20:09
【问题描述】:

Ruby 1.8.6、Rails 2.2.2、OS X Tiger

我的 Test::Unit 测试开始返回以下错误。相关行似乎是:

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

提到的文件,calendar.rb 看起来不错。我在其中找不到任何错误。我尝试删除日历模型的单元和功能测试文件,但这对错误没有影响。

在浏览器中,应用程序似乎运行正常。

有什么见解吗?谁能提出一种隔离问题的方法?

更长的摘录:

$ 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!

【问题讨论】:

  • 您可能需要向我们展示 /Users/ethan/project/mtc/webcalendars/app/models/calendar.rb 的内容

标签: ruby-on-rails ruby unit-testing testing


【解决方案1】:

伊桑, 我唯一一次看到这种情况是我在一个文件中定义了多个类。我自己并没有过多地使用 test:unit,但是您是否有可能在定义 Calendar 之前定义了另一个类?

希望对您有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-28
    相关资源
    最近更新 更多