我需要运行我的rake
测试两次才能测试我的Ruby gem的缓存系统。无论是运行测试之前,我需要清除我的应用程序的缓存与我如何运行我的耙测试两次?
require 'lib/gem_name'
Gem.cache.clear
然后,我只需要运行两次test
任务。我试过把上面的代码放在我的Rakefile
的顶部,并在我的rake任务中列出了两次测试文件,但由于没有正确加载路径,因此我收到了cannot require such file
错误。
我需要一种有效的方式来运行测试两次,而不是在IRB中运行缓存清空代码,然后在命令行上运行两次rake test
。
我Rakefile
看起来是这样的:
require 'rake/testtask'
Rake::TestTask.new do |t|
t.libs << 'test'
t.test_files = FileList['tests/test_*.rb']
t.loader = :testrb
end
desc 'Run gem tests'
task default: :test
这个shell脚本就足够了吗? 'ruby -e“需要'lib/gem_name'; Gem.cache.clear”;耙测试;耙测试;' –
这是一个很好的建议,但由于我使用Travis CI来测试我的构建,我宁愿只能运行'rake test'一次,而不必担心运行脚本。 – cobaltsoda
否则这就是我一直在寻找的确切功能,我只是喜欢它的Ruby形式。 – cobaltsoda