stuartc
stuartc

Reputation: 2274

RSpec Rake file and no such file to load -- rake/tasklib

I'm trying to write a spec rake task to load bundler, but regardless of loading bundler or not I get:

no such file to load -- rake/tasklib

Below is the Rakefile

require 'rake'
require "rubygems"
require "bundler"
Bundler.setup(:default, :test)

task :spec do
  begin
    require 'rspec/core/rake_task'

    desc "Run the specs under spec/"
    RSpec::Core::RakeTask.new do |t|
      t.spec_files = FileList['spec/**/*_spec.rb']
    end
  rescue NameError, LoadError => e
    puts e
  end
end

It seems the culprit is require 'rspec/core/rake_task'

Any advice?

I can still run my specs by using rspec spec or bundle exec rspec spec but I would prefer to use a rake task for this.

Upvotes: 3

Views: 5476

Answers (1)

stuartc
stuartc

Reputation: 2274

Doh!

Ok, pretty straight forward. Bundler's purpose is to isolate your app's Gems.

gem 'rake'

Thats all that was needed in the Gemfile

Upvotes: 5

Related Questions