我正在尝试使用ChefSpec运行一个HelloWorld类型的示例。我运行$ chef generate cookbook learn_chef2生成了一个具有适当目录结构的厨师食谱。
然后我用default.rb创建了一个超级简单的厨师食谱:
package 'ant'
package 'php5'
package 'git'和我在default_spec.rb中的ChefSpec测试:
#require 'spec_helper'
require 'chefspec'
require 'chefspec/berkshelf'
describe 'package::install' do
let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
it 'converges successfully' do
expect(chef_run).to install_package('ant')
end
end但是,当我运行rspec时,我得到以下结果:
/var/lib/gems/2.1.0/gems/rspec-core-3.2.3/lib/rspec/core/formatters/progress_formatter.rb:1:in `<top (required)>': undefined method `require_rspec_core' for RSpec::Support:Module (NoMethodError)
from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/lib/ruby/vendor_ruby/rspec/core/configuration.rb:1093:in `built_in_formatter'
from /usr/lib/ruby/vendor_ruby/rspec/core/configuration.rb:573:in `add_formatter'
from /usr/lib/ruby/vendor_ruby/rspec/core/configuration.rb:589:in `reporter'
from /usr/lib/ruby/vendor_ruby/rspec/core/command_line.rb:25:in `run'
from /usr/lib/ruby/vendor_ruby/rspec/core/runner.rb:80:in `run'
from /usr/lib/ruby/vendor_ruby/rspec/core/runner.rb:17:in `block in autorun'我是Ruby和RSpec的新手,我确信这是一个简单的配置问题。有什么想法吗?
谢谢!
发布于 2015-05-13 04:44:29
通常,您需要做的是将require 'rspec'作为第一行,但我非常确定这是在spec_helper.rb中编写的,您已经在第1行注释掉了它。
https://stackoverflow.com/questions/30200732
复制相似问题