我刚安装了电子邮件规范,可以根据readme中的说明使用rspec。现在,当我尝试运行测试时(即使没有在我的规范中使用email-spec的方法),我收到此错误:
$ rspec spec
Neither Pony nor ActionMailer appear to be loaded so email-spec is requiring ActionMailer.
WARN: Unresolved specs during Gem::Specification.reset:
launchy (~> 2.1)
builder (~> 3.1)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
/Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/bundler-1.7.4/lib/bundler/runtime.rb:34:in `block in setup': You have already activated minitest 5.4.0, but your Gemfile requires minitest 4.7.5. Prepending `bundle exec` to your command may solve this. (Gem::LoadError)
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/bundler-1.7.4/lib/bundler/runtime.rb:19:in `setup'
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/bundler-1.7.4/lib/bundler.rb:121:in `setup'
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/bundler-1.7.4/lib/bundler/setup.rb:7:in `<top (required)>'
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:128:in `require'
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:128:in `rescue in require'
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:39:in `require'
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in `block in require'
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:232:in `load_dependency'
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in `require'
from /Users/jpalmieri/workspace/blocitoff/config/boot.rb:4:in `<top (required)>'
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:121:in `require'
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:121:in `require'
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in `block in require'
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:232:in `load_dependency'
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in `require'
from /Users/jpalmieri/workspace/blocitoff/config/application.rb:1:in `<top (required)>'
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:121:in `require'
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:121:in `require'
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in `block in require'
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:232:in `load_dependency'
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in `require'
from /Users/jpalmieri/workspace/blocitoff/config/environment.rb:2:in `<top (required)>'
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:121:in `require'
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:121:in `require'
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in `block in require'
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:232:in `load_dependency'
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in `require'
from /Users/jpalmieri/workspace/blocitoff/spec/rails_helper.rb:4:in `<top (required)>'
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:121:in `require'
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:121:in `require'
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in `block in require'
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:232:in `load_dependency'
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in `require'
from /Users/jpalmieri/workspace/blocitoff/spec/features/mark_todo_complete_spec.rb:1:in `<top (required)>'
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:241:in `load'
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:241:in `block in load'
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:232:in `load_dependency'
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:241:in `load'
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `block in load_spec_files'
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `each'
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `load_spec_files'
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:96:in `setup'
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:84:in `run'
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:69:in `run'
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:37:in `invoke'
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-3.1.7/exe/rspec:4:in `<top (required)>'
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/bin/rspec:23:in `load'
from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/bin/rspec:23:in `<main>'
预先bundle exec
会使测试运行正常(我仍然会收到Neither Pony nor ActionMailer appear to be loaded so email-spec is requiring ActionMailer
通知,但我想这是一个不同帖子的话题。)
这是我的Gemfile。我没有明确地调用minitest,所以我假设它是email_spec和其他东西的依赖。
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.10'
gem 'devise'
gem 'figaro', '1.0'
gem 'bootstrap-sass', '~> 3.3.1'
gem 'timecop'
gem 'pundit'
group :development, :test do
gem 'rspec-rails'
gem 'capybara'
end
# Use sqlite3 as the database for Active Record
group :production do
gem 'pg'
gem 'rails_12factor'
end
group :development do
gem 'sqlite3'
end
group :test do
gem 'factory_girl_rails', '~> 4.0'
gem 'database_cleaner'
gem 'email_spec'
end
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.2'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
我尝试通过向gem 'minitest', '~> 4.7.5'
组添加:test
来解决冲突,但仍然会遇到相同的错误。
group :test do
gem 'factory_girl_rails', '~> 4.0'
gem 'database_cleaner'
gem 'email_spec'
gem 'minitest', '~> 4.7.5'
end
我的问题是:
1)我以前从未提前bundle exec
。我应该尝试解决冲突而不是预先bundle exec
吗?
2)如果问题1为“是”,我将如何进行此操作?
答案 0 :(得分:1)
这是因为Gem在其依赖项中指定了较旧版本的MiniTest,并且您的系统上安装了较新版本。
使用bundle exec
是正确的方法。请参阅以下内容:
运行可执行文件时,总是使用bundle exec [command]。从捆绑器文档引用:在某些情况下,如果可执行文件恰好安装在您的系统中并且没有引入任何与您的捆绑包冲突的gem,则运行不带bundle exec的可执行文件可能会起作用。然而,这是不可靠的,并且是相当痛苦的根源。
http://yehudakatz.com/2011/05/30/gem-versioning-and-bundler-doing-it-right/