Require Lib in Rspec with Ruby 1.9.2 Brings "No Such File to Load"

require lib in RSpec with Ruby 1.9.2 brings no such file to load

The load path in ruby 1.9 doesn't work exactly like it did in 1.8.

You need to add the project's root directory to your load path.

You can do this by either running rspec like this:

rspec -I . ./spec/models/tipp_remember_spec.rb

...or by manually adding stuff to the load path in your spec_helper.rb (put this at the top of your spec_helper.rb

$:<< File.join(File.dirname(__FILE__), '..')

I think rspec by default adds your local lib directory to the load path as well, so you might be able to rewrite the require line as follows instead:

require 'services/my_lib'

`require': cannot load such file

You should use require_relative:

require_relative 'mixins2'

ImageUtils.status

Ssetting up rspec2 task in Rakefile

The syntax looks fine to me. Are you 100% sure you have rspec 2 installed? Does it appear with gem which rspec? Maybe you forgot to run bundle install or you don't list rspec in the .gemspec file as a (development) dependency?

Ruby Strange Error

Rubygems is installed with ruby 1.9 by default.

Check that the file you are trying to load is in a directory listed in the variable $: or specify the entire path to the file in the require. Or, add the directory to $: explicitly:

$: << '/my/lib/path'
require 'mylib'


Related Topics



Leave a reply



Submit