加载错误机架/测试

时间:2012-04-29 03:26:53

标签: ruby

运行测试文件时出现以下错误。

$ruby test/test_gothonweb.rb
/Users/sony/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- rack/test (LoadError)
    from /Users/sony/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from test/test_gothonweb.rb:3:in `<main>'

测试文件的片段:

require_relative '../lib/gothonweb.rb'
require 'test/unit'
require 'rack/test'

ENV['RACK_ENV'] = 'test'

class GothonwebTest < Test::Unit::TestCase
    include Rack::Test::Methods

    def app
        Sinatra::Application
    end
end 

我认为gem已经安装并应该可用:

gem list

*** LOCAL GEMS ***

bundler (1.1.3)
rack (1.4.1)
rack-protection (1.2.0)
rake (0.9.2.2)
rubygems-bundler (0.9.0)
rvm (1.11.3.3)
sinatra (1.3.2)
tilt (1.3.3)

为什么你会想到这个错误?

2 个答案:

答案 0 :(得分:48)

rack-test是一个独立的宝石。将其包含在您的Gem文件中。

答案 1 :(得分:0)

此处有类似问题,并且gem uninstall rack-test然后捆绑安装解决了问题。

https://github.com/brynary/rack-test/issues/123