当我尝试运行一些ruby单元测试时,我遇到了问题。
我在哈德森得到以下堆栈:
/home/cpcaserver5/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/ext/module.rb:36:in `const_missing': uninitialized constant Time::DATE_FORMATS (NameError)
from /home/cpcaserver5/.hudson/jobs/SVN/workspace/Hermodr/trunk/server/config/environment.rb:2:in `<top (required)>'
from /home/cpcaserver5/.hudson/jobs/SVN/workspace/Hermodr/trunk/server/test/test_helper.rb:2:in `require'
from /home/cpcaserver5/.hudson/jobs/SVN/workspace/Hermodr/trunk/server/test/test_helper.rb:2:in `<top (required)>'
from /home/cpcaserver5/.hudson/jobs/SVN/workspace/Hermodr/trunk/server/test/unit/group_test.rb:1:in `require'
from /home/cpcaserver5/.hudson/jobs/SVN/workspace/Hermodr/trunk/server/test/unit/group_test.rb:1:in `<top (required)>'
from /home/cpcaserver5/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:10:in `require'
from /home/cpcaserver5/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:10:in `block (2 levels) in <main>'
from /home/cpcaserver5/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:9:in `each'
from /home/cpcaserver5/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:9:in `block in <main>'
from /home/cpcaserver5/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:4:in `select'
from /home/cpcaserver5/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:4:in `<main>'
rake aborted!
Command failed with status (1): [/home/cpcaserver5/.rvm/rubies/ruby-1.9.2-p...]
答案 0 :(得分:0)
Rails支持多种日期格式,通常在initializers / time.rb中的初始化程序中声明 - 例如:
Date::DATE_FORMATS[:short_date] = "%b %d, %Y"
Date::DATE_FORMATS[:full_date] = "%A, %B %d, %Y"
Time::DATE_FORMATS[:short_slashed] = "%m/%d/%Y %I:%M %p"
Time::DATE_FORMATS[:short_date] = "%b %d, %Y"
这允许date.to_s(:short_date)格式化日期输出。但是,您的错误输出表明此文件尚未被读取,并且由于我没有看到任何指示堆栈跟踪中的rails的输出,我想知道是否已加载任何rails文件。