不久前我构建了一个 gem,没有包含任何测试(我感到羞耻)。从那以后,我试图通过包含 minitest 来解决这个问题,但我被卡在了大门外,出现以下错误:
不知道如何构建任务“默认”
这是我的Rakefile
require 'rake/testtask'
Rake::TestTask.new do |t|
t.test_files = FileList['test/*_test.rb']
end
和虚拟文件test/unit_test.rb
require 'minitest/autorun'
class TestPackage < MiniTest::Unit::TestCase
def test
assert_equal 10, Array.new(10).size
end
end
如果我更改 Rakefile 以包含task :default => 'minitest'
错误消息更改为Don't know how to build task 'minitest'
rake --trace
似乎只是引导我回到处理任务调用的 Rake gem 部分。我看不到任何线索:
~/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/rake/task_manager.rb:49:in `[]'
~/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/rake/application.rb:115:in `invoke_task'
~/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/rake/application.rb:94:in `block (2 levels) in top_level'
~/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/rake/application.rb:94:in `each'
~/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/rake/application.rb:94:in `block in top_level'
~/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/rake/application.rb:133:in `standard_exception_handling'
~/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/rake/application.rb:88:in `top_level'
~/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/rake/application.rb:66:in `block in run'
~/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/rake/application.rb:133:in `standard_exception_handling'
~/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/rake/application.rb:63:in `run'
~/.rbenv/versions/1.9.3-p286/bin/rake:32:in `<main>'