0
我想獲得與ChefSpec一起運行的HelloWorld類型示例。我跑$ chef generate cookbook learn_chef2
生成一個適當的目錄結構的廚師食譜。RSpec:未定義的方法`require_rspec_core'爲RSpec ::支持:模塊(NoMethodError)
然後我創建了default.rb一個超級簡單的廚師配方:
package 'ant'
package 'php5'
package 'git'
而且我ChefSpec試驗default_spec.rb:
#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的新手,我確定它是一個簡單的配置問題。有什麼想法嗎?
謝謝!
兩個註釋掉'require'行註釋掉
spec_helper.rb
距離產生spec_helper文件。在進行故障排除時,我想我會消除spec_helper文件,並將其兩行放入我的RSpec文件中。我按照你的建議添加了'require'rspec'',但得到了相同的結果。 – je1910