2

I am trying to configure rake using rspec, so I required rspec and rspec/core/rake_task on top of the rakefile. I'm sure I have already installed the rspec gem, but then I got the rspec load error.

The rakefile:

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 

Then i got this load error:

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>'
Nakilon
  • 34,866
  • 14
  • 107
  • 142
Superalan
  • 21
  • 1
  • 2
  • 2
    Have you installed rspec? Try typing `gem which rspec` to see. If it isn't installed, then add it to your Gemfile if you are using bundle. Otherwise, you can install it from the command-line using apt-get or gem. :) – Ziggy Mar 10 '13 at 05:04

0 Answers0