rspec を使用して rake を構成しようとしているので、rakefile の上に rspec と rspec/core/rake_task が必要です。すでに rspec gem をインストールしていると確信していますが、rspec ロード エラーが発生しました。
レーキファイル:
require "rspec"
require "rspec/core/rake_task"
SPEC_OPTS = %w(--format documentation --color)
SPEC_OPTS << '--fail-fast' if (ENV['BAT_FAIL_FAST'] || "false").downcase == 'true'
SPEC_OPTS << '--tag ~ssh' if (ENV['BAT_SKIP_SSH'] || "false").downcase == 'true'
desc "Run BAT tests"
RSpec::Core::RakeTask.new(:bat) do |t|
cd 'bat'
t.pattern = %w[spec/env_spec.rb spec/bat/*_spec.rb]
t.rspec_opts = SPEC_OPTS
end
namespace "bat" do
desc "Verify BAT environment"
RSpec::Core::RakeTask.new(:env) do |t|
cd 'bat'
t.pattern = "spec/env_spec.rb"
t.rspec_opts = SPEC_OPTS
end
desc "Run release tests"
RSpec::Core::RakeTask.new(:release => :env) do |t|
t.pattern = "spec/bat/release_spec.rb"
t.rspec_opts = SPEC_OPTS
end
desc "Run deployment tests"
RSpec::Core::RakeTask.new(:deployment => :env) do |t|
t.pattern = "spec/bat/deployment_spec.rb"
t.rspec_opts = SPEC_OPTS
end
desc "Run stemcell tests"
RSpec::Core::RakeTask.new(:stemcell => :env) do |t|
t.pattern = "spec/bat/stemcell_spec.rb"
t.rspec_opts = SPEC_OPTS
end
desc "Run log tests"
RSpec::Core::RakeTask.new(:log => :env) do |t|
t.pattern = "spec/bat/log_spec.rb"
t.rspec_opts = SPEC_OPTS
end
desc "Run job tests"
RSpec::Core::RakeTask.new(:job => :env) do |t|
t.pattern = "spec/bat/job_spec.rb"
t.rspec_opts = SPEC_OPTS
end
desc "Run property tests"
RSpec::Core::RakeTask.new(:property => :env) do |t|
t.pattern = "spec/bat/property_spec.rb"
t.rspec_opts = SPEC_OPTS
end
desc "Run dns tests"
RSpec::Core::RakeTask.new(:dns => :env) do |t|
t.pattern = "spec/bat/dns_spec.rb"
t.rspec_opts = SPEC_OPTS
end
desc "Run agent tests"
RSpec::Core::RakeTask.new(:agent => :env) do |t|
t.pattern = "spec/bat/agent_spec.rb"
t.rspec_opts = SPEC_OPTS
end
desc "Run disk tests"
RSpec::Core::RakeTask.new(:disk => :env) do |t|
t.pattern = "spec/bat/disk_spec.rb"
t.rspec_opts = SPEC_OPTS
end
end
次に、このロードエラーが発生しました:
rake aborted!
cannot load such file -- rspec
/home/alan/bosh/rake/spec.rake:1:in `require'
/home/alan/bosh/rake/spec.rake:1:in `<top (required)>'
/home/alan/.rvm/gems/ruby-1.9.3-p385@global/gems/rake-10.0.3/lib/rake/rake_module.rb:25:in `load'
/home/alan/.rvm/gems/ruby-1.9.3-p385@global/gems/rake-10.0.3/lib/rake/rake_module.rb:25:in `load_rakefile'
/home/alan/.rvm/gems/ruby-1.9.3-p385@global/gems/rake-10.0.3/lib/rake/default_loader.rb:6:in `load'
/home/alan/.rvm/gems/ruby-1.9.3-p385@global/gems/rake-10.0.3/lib/rake/application.rb:651:in `load_imports'
/home/alan/.rvm/gems/ruby-1.9.3-p385@global/gems/rake-10.0.3/lib/rake/application.rb:590:in `raw_load_rakefile'
/home/alan/.rvm/gems/ruby-1.9.3-p385@global/gems/rake-10.0.3/lib/rake/application.rb:89:in `block in load_rakefile'
/home/alan/.rvm/gems/ruby-1.9.3-p385@global/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
/home/alan/.rvm/gems/ruby-1.9.3-p385@global/gems/rake-10.0.3/lib/rake/application.rb:88:in `load_rakefile'
/home/alan/.rvm/gems/ruby-1.9.3-p385@global/gems/rake-10.0.3/lib/rake/application.rb:72:in `block in run'
/home/alan/.rvm/gems/ruby-1.9.3-p385@global/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
/home/alan/.rvm/gems/ruby-1.9.3-p385@global/gems/rake-10.0.3/lib/rake/application.rb:70:in `run'
/home/alan/.rvm/gems/ruby-1.9.3-p385@global/gems/rake-10.0.3/bin/rake:33:in `<top (required)>'
/home/alan/.rvm/gems/ruby-1.9.3-p385@global/bin/rake:19:in `load'
/home/alan/.rvm/gems/ruby-1.9.3-p385@global/bin/rake:19:in `<main>'
/home/alan/.rvm/gems/ruby-1.9.3-p385@bosh/bin/ruby_noexec_wrapper:14:in `eval'
/home/alan/.rvm/gems/ruby-1.9.3-p385@bosh/bin/ruby_noexec_wrapper:14:in `<main>'