我正在使用rails 5.1.1&红宝石2.3.1
当我执行rspec时,我得到以下错误
`require':无法加载此类文件 - paperclip / matchers(LoadError)
的Gemfile:
gem "rspec-rails", '>= 3.6.0'
gem 'shoulda-matchers', '~> 3.1'
gem 'shoulda-callback-matchers', '~> 1.1.1'
我在spec_helper.rb
中包含了以下内容require "paperclip/matchers"
config.include Paperclip::Shoulda::Matchers
似乎rspec没有从paperclip获取与rbenv gems文件夹相关的特定文件。
答案 0 :(得分:1)
我假设您的实际Gemfile有更多条目。如果不出意外,您可能在顶部/附近有一个gem服务器:
source 'https://rubygems.org'
回形针宝石似乎不是您列出的其他宝石的依赖项:
$ bundle show paperclip
Could not find gem 'paperclip' in any of the gem sources listed in your Gemfile.
所以你可能还想添加一行,如:
gem 'paperclip'
然后运行bundle install
和bundle show paperclip
。如果您仍然遇到问题,可能是您没有安装捆绑器来使用rbenv:
$ type bundle
bundle is hashed (/usr/local/bin/bundle)
$ gem install bundler
Fetching: bundler-1.15.1.gem (100%)
Successfully installed bundler-1.15.1
Parsing documentation for bundler-1.15.1
Installing ri documentation for bundler-1.15.1
Done installing documentation for bundler after 4 seconds
1 gem installed
$ rbenv rehash
$ type bundle
bundle is ~/.rbenv/shims/bundle