1

我刚刚根据自述文件中的说明安装了 email-spec 以与 rspec 一起使用。现在,当我尝试运行测试(即使没有在我的规范中使用电子邮件规范的方法)时,我收到此错误:

$ 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“是”,我将如何去做?

4

1 回答 1

1

发生这种情况是因为 Gem 在其依赖项中指定了旧版本的 MiniTest,而您的系统上安装了新版本。

使用bundle exec是正确的方法。请参阅以下内容:

运行可执行文件时,始终使用 bundle exec [command]。引用 bundler 文档:在某些情况下,运行没有 bundle exec 的可执行文件可能会起作用,如果可执行文件恰好安装在您的系统中并且没有拉入任何与您的 bundle 冲突的 gem。然而,这是不可靠的并且是相当大的痛苦的来源。

http://yehudakatz.com/2011/05/30/gem-versioning-and-bundler-doing-it-right/

于 2015-03-21T16:12:26.237 回答