1

我正在开发宝石。有一个名为 /spec 的文件夹,其中包含 2 个文件:

#spec_helper.rb
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'my_gem'

#my_gem_spec.rb
describe MyGem do
  it 'should have a version number' do
    MyGem::VERSION.should_not be_nil
  end

  #............
end

然后我运行它

rspec spec
/var/lib/gems/1.9.1/gems/rspec-core-2.12.2/lib/rspec/core/configuration.rb:491:in `add_formatter': Formatter 'specdoc' unknown - maybe you meant 'documentation' or 'progress'?. (ArgumentError)
        from /var/lib/gems/1.9.1/gems/rspec-core-2.12.2/lib/rspec/core/configuration_options.rb:30:in `block in configure'
        from /var/lib/gems/1.9.1/gems/rspec-core-2.12.2/lib/rspec/core/configuration_options.rb:30:in `each'
        from /var/lib/gems/1.9.1/gems/rspec-core-2.12.2/lib/rspec/core/configuration_options.rb:30:in `configure'
        from /var/lib/gems/1.9.1/gems/rspec-core-2.12.2/lib/rspec/core/command_line.rb:21:in `run'
        from /var/lib/gems/1.9.1/gems/rspec-core-2.12.2/lib/rspec/core/runner.rb:80:in `run'
        from /var/lib/gems/1.9.1/gems/rspec-core-2.12.2/lib/rspec/core/runner.rb:17:in `block in autorun'

这是什么意思?如何摆脱它?

这是捆绑包的输出

bundle install
Using rake (10.0.3) 
Using diff-lcs (1.1.3) 
Using my_gem (0.0.1) from source at . 
Using rspec-core (2.12.2) 
Using rspec-expectations (2.12.1) 
Using rspec-mocks (2.12.1) 
Using rspec (2.12.0) 
Using bundler (1.3.0.pre.4) 
4

1 回答 1

1

卸载所有以前版本的 rspec 及其依赖项。

gem uninstall rspec
gem uninstall rspec-core
gem uninstall rspec-mocks
gem uninstall rspec-expectations

在 gem 文件install rspec中安装正确版本的rspec 。

group :development, :test do
  gem 'rspec-rails', '~> 3.0.0'
end

看到这个答案

于 2014-08-10T00:40:11.107 回答