Ruby on Rails 3.1和Will_Paginate在运行RSpec时抛出错误

时间:2011-12-16 13:37:21

标签: ruby ruby-on-rails-3 rspec rspec-rails

我正在尝试设置rspec来测试我的Rails 3.1应用程序。我已将以下内容添加到我的gemfile中进行测试:

gem "rspec-rails", :group => [:test, :development]
group :test do
  # Pretty printed test output
  gem "factory_girl_rails"
  gem "capybara"
  gem "guard-rspec"
end

我也使用Will Paginate和一个在初始化程序中设置的自定义链接渲染器。 gem被添加到Gemfile:

gem 'will_paginate', '~> 3.0.2'

初始化文件夹中的初始化程序设置为

WillPaginate::ViewHelpers.pagination_options[:renderer] = 'PaginationListLinkRenderer'

pagination_list_link_renderer.rb文件放在lib文件夹中,rails设置为自动加载application.rb中的路径

config.autoload_paths += %W(#{config.root}/lib)

我的规范帮助文件如下:

ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'

# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}

RSpec.configure do |config|
  config.mock_with :rspec
  config.use_transactional_fixtures = true
end

运行规范时,出现以下错误:

/config/initializers/will_paginate.rb:1:in`':未初始化的常量WillPaginate :: ViewHelpers(NameError)

在实际的应用程序中工作真棒,而不是通过Rspec。关于我做错了什么的指示?

0 个答案:

没有答案