无法运行Rails测试

时间:2011-06-30 15:04:26

标签: ruby-on-rails testing

我已经回顾了与我的问题相关的问题,但我找不到解决方案。当我尝试在Rails 3.0.3应用程序中运行测试时,我收到此错误:

willmac:signalkit wbarrett$ rake test
(in /Users/wbarrett/Sites/signalkit)
LOADING CONFIG/ENVIRONMENT.RB
./test/unit/authentication_test.rb:3: uninitialized constant ActiveSupport (NameError)
    from /Users/wbarrett/.rvm/gems/ree-1.8.7-2011.03@global/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `load'
    from /Users/wbarrett/.rvm/gems/ree-1.8.7-2011.03@global/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5
    from /Users/wbarrett/.rvm/gems/ree-1.8.7-2011.03@global/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `each'
    from /Users/wbarrett/.rvm/gems/ree-1.8.7-2011.03@global/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5
./test/functional/authentications_controller_test.rb:3: uninitialized constant ActionController (NameError)
    from /Users/wbarrett/.rvm/gems/ree-1.8.7-2011.03@global/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `load'
    from /Users/wbarrett/.rvm/gems/ree-1.8.7-2011.03@global/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5
    from /Users/wbarrett/.rvm/gems/ree-1.8.7-2011.03@global/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `each'
    from /Users/wbarrett/.rvm/gems/ree-1.8.7-2011.03@global/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5
Errors running test:units, test:functionals!

如您所见,测试需要test_helper并且需要environment.rb(我将LOADING ..输出添加到environment.rb配置文件的顶部)

这是我的Gemfile:

来源'http://rubygems.org'

gem 'rails', '3.0.3'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'sqlite3-ruby', :require => 'sqlite3'
gem 'devise'
gem 'unicorn'
gem 'omniauth', :git => 'git://github.com/signalkit/omniauth.git', :branch => 'signalkit'
gem 'mongrel'
# gem 'tinder'
gem 'oauth2', :git => 'git://github.com/signalkit/oauth2.git', :branch => 'signalkit' #0.1.1 with modification for Basecamp
gem 'crack'
gem 'delayed_job'
gem "builder", "2.1.2"
gem "haml", "3.0.12"
gem "maruku", "0.6.0"
gem "RedCloth", "4.2.2"
gem "sinatra", "1.1.0", :require => "sinatra/base"
gem "monkeywrench"
gem "httparty"
gem "hoptoad_notifier"

group :test do
  gem "shoulda", "~> 2.11.3"
  gem "mocha", "~> 0.9.12"
  gem "webmock", "= 0.7.3"
  gem "test-unit"
end

这张照片出了什么问题?谢谢大家!

更新时间:6/30/2011 4:05 PM CST

无论出于何种原因,更改

中所有测试文件顶部的需求
require 'test_helper'

require File.dirname(__FILE__) + '/../test_helper'

解决了我的问题。 +25对任何人都可以告诉我为什么会这样,因为帮助者也正好以其他方式加载。

0 个答案:

没有答案