我正在尝试使用标准的Ruby文件布局。我有一些Spec文件,并尝试使用Minitest来运行这些测试。我明白我不应该使用' lib'当需要文件时,通常可以在使用' -I'提供Ruby库路径时附加文件。运行spec文件时,我得到一些最小的常量单位化错误。
rakefile看起来不错吗?
/Users/rag/.rvm/gems/ruby-2.1.5/gems/minitest-5.8.1/lib/minitest/parallel.rb:19:in `initialize': uninitialized constant Minitest::Parallel::Executor::Queue (NameError)
from /Users/rag/.rvm/gems/ruby-2.1.5/gems/minitest-5.8.1/lib/minitest.rb:23:in `new'
from /Users/rag/.rvm/gems/ruby-2.1.5/gems/minitest-5.8.1/lib/minitest.rb:23:in `<module:Minitest>'
from /Users/rag/.rvm/gems/ruby-2.1.5/gems/minitest-5.8.1/lib/minitest.rb:9:in `<top (required)>'
from /Users/rag/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/rag/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/rag/.rvm/gems/ruby-2.1.5/gems/minitest-5.8.1/lib/minitest/autorun.rb:8:in `<top (required)>'
from /Users/rag/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/rag/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from tests/test_jthread.rb:1:in `<main>'
spec文件:
cat tests/test_jthread.rb
require 'minitest/autorun'
require 'thread.rb'
describe JThread do
目录结构:
lib/thread.rb
bin/
tests/test_jthread.rb
Gemfile
jta.gemspec*
来自捆绑的宝石列表:
$ bundle list
Gems included by the bundle:
* ansi (1.5.0)
* builder (3.2.2)
* bundler (1.10.6)
* minitest (5.8.1)
* minitest-reporters (1.1.4)
* ruby-progressbar (1.7.5)
Rake文件
require 'rake/testtask'
Rake::TestTask.new do |task|
task.libs << %w(tests lib)
task.pattern = 'tests/test_*.rb'
end
desc "Run tests"
task :default => :test
答案 0 :(得分:1)
如果您有一个班级JThread
,它应位于lib/j_thread.rb
,同时将require 'thread.rb'
修复为require 'j_thread'
(无需.rb
后缀)。< / p>
如果你的rake任务不起作用,请尝试通过老式的方式运行测试来检查它:
ruby -Ilib:test tests/test_*.rb