Rails - Rspec错误`configure':未初始化的常量CarrierWave :: Uploader(NameError)

时间:2016-07-05 08:36:58

标签: ruby-on-rails ruby rspec carrierwave

我正在尝试在Rails中运行我的Rspec测试

 bundle exec rspec

但是我得到了与载波的酉常数相关的以下错误

/home/bastien/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/carrierwave-0.10.0/lib/carrierwave.rb:14:in `configure': uninitialized constant CarrierWave::Uploader (NameError)
from /home/bastien/rails/coffee/lib/carrierwave/storage/fog.rb:1:in `<top (required)>'
from /home/bastien/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/carrierwave-0.10.0/lib/carrierwave/storage.rb:9:in `require'
from /home/bastien/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/carrierwave-0.10.0/lib/carrierwave/storage.rb:9:in `<top (required)>'
from /home/bastien/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/carrierwave-0.10.0/lib/carrierwave.rb:78:in `require'
from /home/bastien/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/carrierwave-0.10.0/lib/carrierwave.rb:78:in `<top (required)>'
from /home/bastien/rails/coffee/config/application.rb:4:in `require'
from /home/bastien/rails/coffee/config/application.rb:4:in `<top (required)>'
from /home/bastien/rails/coffee/config/environment.rb:2:in `require'
from /home/bastien/rails/coffee/config/environment.rb:2:in `<top (required)>'
from /home/bastien/rails/coffee/spec/rails_helper.rb:3:in `require'
from /home/bastien/rails/coffee/spec/rails_helper.rb:3:in `<top (required)>'
from /home/bastien/rails/coffee/spec/controllers/bad_terms_controller_spec.rb:1:in `require'
from /home/bastien/rails/coffee/spec/controllers/bad_terms_controller_spec.rb:1:in `<top (required)>'
from /home/bastien/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rspec-core-3.4.1/lib/rspec/core/configuration.rb:1361:in `load'
from /home/bastien/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rspec-core-3.4.1/lib/rspec/core/configuration.rb:1361:in `block in load_spec_files'
from /home/bastien/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rspec-core-3.4.1/lib/rspec/core/configuration.rb:1359:in `each'
from /home/bastien/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rspec-core-3.4.1/lib/rspec/core/configuration.rb:1359:in `load_spec_files'
from /home/bastien/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:102:in `setup'
from /home/bastien/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:88:in `run'
from /home/bastien/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:73:in `run'
from /home/bastien/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:41:in `invoke'
from /home/bastien/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rspec-core-3.4.1/exe/rspec:4:in `<top (required)>'
from /home/bastien/.rbenv/versions/2.2.2/bin/rspec:23:in `load'
from /home/bastien/.rbenv/versions/2.2.2/bin/rspec:23:in `<main>'

请注意,启动我的服务器没问题。尽管如此,我还是试图添加

require 'carrierwave'

在我的应用程序下的各个地方,包括

application.rb
environment.rb
spec/rails_helper.rb
spec/spec_helper.rb

但我仍然得到错误。请注意,在上传器模型的规范下没有创建测试文件。有没有人有其他选择建议?

编辑Gemfile

gem 'rails', '4.2.4'
gem 'bcrypt', '3.1.7'
gem 'bootstrap-sass', '3.2.0.0'
gem "will_paginate", "~> 3.0.4"
gem 'faker', '1.4.2'
gem 'bootstrap-will_paginate', '0.0.10'
gem 'prawn'
gem 'prawnto', '0.1.1'
gem 'prawnto_2', :require => 'prawnto'
gem 'prawn-table'
gem 'rufus-scheduler'
gem 'devise'
gem 'activeadmin', '~> 1.0.0.pre1'
gem 'wicked_pdf'
gem 'pdf-reader'
gem 'pry'
gem 'pry-remote'
gem 'pry-rails'
# Carrier Wave to upload file
gem 'carrierwave', '~> 0.9'
gem 'fog', "~> 1.35.0"
gem 'net-ssh'

group :development, :test do
gem 'web-console', '~> 2.0'
gem 'rspec','~> 3.0'
gem 'rspec-rails'
gem 'factory_girl_rails'
gem 'capybara'
gem 'database_cleaner'
gem 'shoulda-matchers'
gem 'spring'
end

group :production do
gem 'rails_12factor','0.0.2'
gem 'puma','2.11.1'
end

/ lib / carrierwave / storage

CarrierWave.configure do |config|
config.fog_credentials = {
provider:              'AWS',
aws_access_key_id:     'AKIAJUKRZIV4YECHMQ2Q',            
aws_secret_access_key: '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',
region:                'eu-central-1',
}
config.fog_directory  = 'coffee'
end

0 个答案:

没有答案