因此,当我尝试运行以下文件时,我收到此错误。当我使用ruby -I Zombifier_test.rb运行它时,它会永远卡住并挂起。我如何使这项工作?
ruby Zombifier_test.rb
/home/.rubies/ruby-2.1.3/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- Zombifier (LoadError)
from /home/.rubies/ruby-2.1.3/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from Zombifier_test.rb:2:in `<main>'
Zombifier_test.rb文件的内容如下:
require 'test/unit'
require 'Zombifier'
class ZombifierTest< Test::Unit::TestCase
# Called before every test method runs. Can be used
# to set up fixture information.
def test_zombify_upcase
z=Zombifier.new("Hello World")
assert_equal "HELLO WORLD BRAINS",z.zombify,"They are not equal"
end
end
Zombifier.rb的内容如下:
class Zombifier
def initialize(str)
@str = str
end
def zombify
"#{@str} BRAINS"
end
end
tests目录的内容如下:
4096 Mar 9 14:28 ..
106 Mar 9 14:36 zombifier.rb
4096 Mar 9 14:38 .idea
4096 Mar 9 14:53 coverage
323 Mar 9 15:00 Zombifier_test.rb_bk
379 Mar 9 15:19 Zombifier_test.rb
4096 Mar 9 15:19 .
答案 0 :(得分:1)
在测试文件之上需要类似的东西(在需要之前):
$: << "../src" # path to zombifier.rb relative to zombifier_test.rb