Я установил несколько новых гемов для тестирования и столкнулся с неинициализированной постоянной ошибкой ActionController::Dispatcher::MiddlewareStack. Я следовал инструкциям для gem rdocs — указал зависимость gem в моем файле environment.rb, а затем запустил rake gems:install и rake gems:unpack.
Я также скопировал свой файл environment.rb по одной строке за раз в другой проект, и я не получил ошибку. Мне было интересно, что еще может пойти не так.
Вот более длинная версия ошибки (сначала я столкнулся с ошибкой при запуске простого теста; то же самое происходит в консоли, когда я требую «active_support»):
$ ruby test/unit/user_test.rb
** has_many_polymorphs: rails environment detected
/Users/thaiyoshi/.gem/ruby/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:105:in `const_missing': uninitialized constant ActionController::Dispatcher::MiddlewareStack (NameError)
from /Users/thaiyoshi/.gem/ruby/1.8/gems/actionpack-2.3.2/lib/action_controller/dispatcher.rb:71
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /Users/thaiyoshi/.gem/ruby/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in `require'
from /Users/thaiyoshi/.gem/ruby/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:521:in `new_constants_in'
from /Users/thaiyoshi/.gem/ruby/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in `require'
from /Users/thaiyoshi/.gem/ruby/1.8/gems/has_many_polymorphs-2.13/lib/has_many_polymorphs/autoload.rb:2
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
... 8 levels...
from ./test/unit/../test_helper.rb:2:in `require'
from ./test/unit/../test_helper.rb:2
from test/unit/user_test.rb:1:in `require'
from test/unit/user_test.rb:1
Вот мой файл environment.rb (комментарии по умолчанию удалены):
RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION
# config.gem 'has_many_polymorphs', :version => "2.12"
# require ‘has_many_polymorphs‘
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
require 'has_many_polymorphs'
require 'active_support'
Rails::Initializer.run do |config|
config.time_zone = 'UTC'
config.gem "thoughtbot-factory_girl",
:lib => "factory_girl",
:source => "http://gems.github.com"
config.gem 'thoughtbot-shoulda',
:lib => false,
:source => 'http://gems.github.com'
end