Strangely, everything works, I don't know why. I didn't even need to use
the -I flag or the require statement. I wonder if was because I started
using `bundle exec rspec`  instead of `rspec`.


On Tue, Jul 22, 2014 at 1:40 AM, Stefano Crocco <stefano.crocco / alice.it>
wrote:

> Excerpts from Sjouke Fikse's message of 2014-07-22 02:35:45 +0200:
> > Hi everyone, I'm doing my best to get up to speed in ruby and rails.
> Within
> > a test project, I'm trying to create an instance of a class in a spec
> file,
> > but I'm failing to do this.
> >
> > These two files exists:
> >   app/models/street.rb
> >   spec/models/street_spec.rb
> >
> > Within the spec, I'm trying to create a new instance of the street class,
> > but it doesn't know what street is. That's acceptable, I add `require
> > 'streets'` and it still fails with
> >
> > $ rspec spec/models/street_spec.rb
> > /home/sjouke/streetmap/spec/models/street_spec.rb:2:in `require': cannot
> > load such file -- street (LoadError)
> ...
> > Any idea why it wouldn't be loading the file appropriately?
> > I'm also using rspec-rails.
>
> I think the issue is that you need to tell require where 'street.rb'
> really is.
> I never used rails, so I can't say if rspec is supposed to be able to
> determine
> it automatically, but otherwise you'd need to either write
>
> require './app/models/street.rb'
>
> or
>
> require_relative '../../../app/models/street.rb'
>
> or call rspec adding your application directory to the load path, using
> the -I
> option: rspec -I app
>
> and use
>
> require 'models/street'
>
> I hope this helps
>
> Stefano
>