所以我正在开发一个gem ...我输入了bundle,它安装了rspec 2.0.1,我确信你会理解,这在rspec 2.12.2这个时代是不可接受的
我会好的,除非我运行rake spec ...
% rake spec
/home/alg/.rvm/rubies/ruby-1.9.3-p374/bin/ruby -S bundle exec rspec "./spec/file_comparisons_spec.rb" "./spec/monitor_spec.rb" "./spec/pipboy_spec.rb"
/home/alg/Documents/Code/pipboy/spec/spec_helper.rb:8:in `block in <top (required)>': undefined method `treat_symbols_as_metadata_keys_with_true_values=' for #<RSpec::Core::Configuration:0x9c99a74> (NoMethodError)
from /home/alg/.rvm/gems/ruby-1.9.3-p374@pipboy/gems/rspec-core-2.0.1/lib/rspec/core.rb:67:in `configure'
from /home/alg/Documents/Code/pipboy/spec/spec_helper.rb:7:in `<top (required)>'
from /home/alg/Documents/Code/pipboy/spec/file_comparisons_spec.rb:1:in `require'
from /home/alg/Documents/Code/pipboy/spec/file_comparisons_spec.rb:1:in `<top (required)>'
from /home/alg/.rvm/gems/ruby-1.9.3-p374@pipboy/gems/rspec-core-2.0.1/lib/rspec/core/configuration.rb:306:in `load'
from /home/alg/.rvm/gems/ruby-1.9.3-p374@pipboy/gems/rspec-core-2.0.1/lib/rspec/core/configuration.rb:306:in `block in load_spec_files'
from /home/alg/.rvm/gems/ruby-1.9.3-p374@pipboy/gems/rspec-core-2.0.1/lib/rspec/core/configuration.rb:306:in `map'
from /home/alg/.rvm/gems/ruby-1.9.3-p374@pipboy/gems/rspec-core-2.0.1/lib/rspec/core/configuration.rb:306:in `load_spec_files'
from /home/alg/.rvm/gems/ruby-1.9.3-p374@pipboy/gems/rspec-core-2.0.1/lib/rspec/core/command_line.rb:18:in `run'
from /home/alg/.rvm/gems/ruby-1.9.3-p374@pipboy/gems/rspec-core-2.0.1/lib/rspec/core/runner.rb:55:in `run_in_process'
from /home/alg/.rvm/gems/ruby-1.9.3-p374@pipboy/gems/rspec-core-2.0.1/lib/rspec/core/runner.rb:46:in `run'
from /home/alg/.rvm/gems/ruby-1.9.3-p374@pipboy/gems/rspec-core-2.0.1/lib/rspec/core/runner.rb:10:in `block in autorun'
rake aborted!
ruby -S bundle exec rspec "./spec/file_comparisons_spec.rb" "./spec/monitor_spec.rb" "./spec/pipboy_spec.rb" failed
/home/alg/.rvm/gems/ruby-1.9.3-p374@pipboy/gems/rspec-core-2.0.1/lib/rspec/core/rake_task.rb:117:in `rescue in block (2 levels) in initialize'
/home/alg/.rvm/gems/ruby-1.9.3-p374@pipboy/gems/rspec-core-2.0.1/lib/rspec/core/rake_task.rb:113:in `block (2 levels) in initialize'
/home/alg/.rvm/gems/ruby-1.9.3-p374@pipboy/gems/rspec-core-2.0.1/lib/rspec/core/rake_task.rb:109:in `block in initialize'
/home/alg/.rvm/gems/ruby-1.9.3-p374@pipboy/bin/ruby_noexec_wrapper:14:in `eval'
/home/alg/.rvm/gems/ruby-1.9.3-p374@pipboy/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => spec
(See full trace by running task with --trace)
所以这里有一些我觉得很重要的内容,即使我发现它们没有任何问题:
=&GT; Rake文件
require "bundler/gem_tasks"
require 'rspec/core/rake_task'
require 'cucumber/rake/task'
RSpec::Core::RakeTask.new(:spec)
task :default => :spec
Cucumber::Rake::Task.new(:features) do |t|
t.cucumber_opts = "features --format progress"
end
=&GT;的Gemfile
source :rubygems
# Specify your gem's dependencies in pipboy.gemspec
gemspec
=&GT; gemspec
# -*- encoding: utf-8 -*-
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'pipboy/version'
Gem::Specification.new do |gem|
gem.files = `git ls-files`.split($/)
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
gem.require_paths = ["lib"]
gem.add_development_dependency 'rspec'
gem.add_development_dependency 'cucumber'
gem.add_development_dependency 'rake'
gem.add_development_dependency 'rdoc'
end
而且,没有Gemfile.lock,调用bundle的结果......
% bundle
Fetching gem metadata from http://rubygems.org/.........
Fetching gem metadata from http://rubygems.org/..
Using rake (10.0.3)
Using builder (3.1.4)
Using diff-lcs (1.2.0)
Using json (1.7.6)
Using gherkin (2.11.5)
Using cucumber (1.2.1)
Using pipboy (0.0.1) from source at /home/alg/Documents/Code/pipboy
Using rdoc (3.12)
Using rspec-core (2.0.1)
Using rspec-expectations (2.0.1)
Using rspec-mocks (2.0.1)
Using rspec (2.0.1)
Using bundler (1.2.3)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
=&GT;事后的Gemfile.lock
PATH
remote: .
specs:
pipboy (0.0.1)
GEM
remote: http://rubygems.org/
specs:
builder (3.1.4)
cucumber (1.2.1)
builder (>= 2.1.2)
diff-lcs (>= 1.1.3)
gherkin (~> 2.11.0)
json (>= 1.4.6)
diff-lcs (1.2.0)
gherkin (2.11.5)
json (>= 1.4.6)
json (1.7.6)
rake (10.0.3)
rdoc (3.12)
json (~> 1.4)
rspec (2.0.1)
rspec-core (~> 2.0.1)
rspec-expectations (~> 2.0.1)
rspec-mocks (~> 2.0.1)
rspec-core (2.0.1)
rspec-expectations (2.0.1)
diff-lcs (>= 1.1.2)
rspec-mocks (2.0.1)
rspec-core (~> 2.0.1)
rspec-expectations (~> 2.0.1)
PLATFORMS
ruby
DEPENDENCIES
cucumber
pipboy!
rake
rdoc
rspec
答案 0 :(得分:4)
看来,诀窍就是这样做。
gem.add_development_dependency 'rspec', '>= 2.12.0'
然后,我还是 - 不知道 - 为什么它下载了rspec 2.0.1而不是2.12.0 ......