Rspec failing to find the model

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 street_spec.rb, I’m trying to create a new instance of the street
class, but it doesn’t
know what street is. That’s acceptable, but when I add require 'streets'
and it still fails:

$ rspec spec/models/street_spec.rb
/home/sjouke/streetmap/spec/models/street_spec.rb:2:in require': cannot load such file -- street (LoadError) from /home/sjouke/streetmap/spec/models/street_spec.rb:2:in<top
(required)>’
from
/home/sjouke/.rvm/gems/ruby-2.1.2@streetmap/gems/rspec-core-3.0.2/lib/rspec/core/configuration.rb:1057:in
load' from /home/sjouke/.rvm/gems/ruby-2.1.2@streetmap/gems/rspec-core-3.0.2/lib/rspec/core/configuration.rb:1057:inblock in load_spec_files’
from
/home/sjouke/.rvm/gems/ruby-2.1.2@streetmap/gems/rspec-core-3.0.2/lib/rspec/core/configuration.rb:1057:in
each' from /home/sjouke/.rvm/gems/ruby-2.1.2@streetmap/gems/rspec-core-3.0.2/lib/rspec/core/configuration.rb:1057:inload_spec_files’
from
/home/sjouke/.rvm/gems/ruby-2.1.2@streetmap/gems/rspec-core-3.0.2/lib/rspec/core/runner.rb:97:in
setup' from /home/sjouke/.rvm/gems/ruby-2.1.2@streetmap/gems/rspec-core-3.0.2/lib/rspec/core/runner.rb:85:inrun’
from
/home/sjouke/.rvm/gems/ruby-2.1.2@streetmap/gems/rspec-core-3.0.2/lib/rspec/core/runner.rb:70:in
run' from /home/sjouke/.rvm/gems/ruby-2.1.2@streetmap/gems/rspec-core-3.0.2/lib/rspec/core/runner.rb:38:ininvoke’
from
/home/sjouke/.rvm/gems/ruby-2.1.2@streetmap/gems/rspec-core-3.0.2/exe/rspec:4:in
<top (required)>' from /home/sjouke/.rvm/gems/ruby-2.1.2@streetmap/bin/rspec:23:inload’
from /home/sjouke/.rvm/gems/ruby-2.1.2@streetmap/bin/rspec:23:in
<main>' from /home/sjouke/.rvm/gems/ruby-2.1.2@streetmap/bin/ruby_executable_hooks:15:ineval’
from
/home/sjouke/.rvm/gems/ruby-2.1.2@streetmap/bin/ruby_executable_hooks:15:in
`’

Any idea why it wouldn’t be loading the file appropriately?
Also, I’m using using rspec-rails after a suggestion from somebody in
IRC.

On Tuesday, July 22, 2014 1:08:08 AM UTC+2, Sjouke F. wrote:

Within street_spec.rb, I’m trying to create a new instance of the street

/home/sjouke/.rvm/gems/ruby-2.1.2@streetmap/gems/rspec-core-3.0.2/lib/rspec/core/configuration.rb:1057:in

 from

invoke' from /home/sjouke/.rvm/gems/ruby-2.1.2@streetmap/bin/ruby_executable_hooks:15:in

Any idea why it wouldn’t be loading the file appropriately?
Also, I’m using using rspec-rails after a suggestion from somebody in IRC.

  1. Please, post your street_spec.rb file content.
  2. Did you run rails generate rspec:install ?

Hi Javix, I did run rails generate rspec:install. I forgot to mention
that.

Here’s the output of the files I mentioned:

$ cat spec/models/street_spec.rb

require “spec_helper”
require “street”

describe “a street” do
it “can be created” do
Street.new
end
end

$ cat app/models/street.rb

class Street < ActiveRecord::Base
attr_accessor :coordinates
end

On Tuesday, July 22, 2014 1:08:08 AM UTC+2, Sjouke F. wrote:

Within street_spec.rb, I’m trying to create a new instance of the street

/home/sjouke/.rvm/gems/ruby-2.1.2@streetmap/gems/rspec-core-3.0.2/lib/rspec/core/configuration.rb:1057:in

 from

invoke' from /home/sjouke/.rvm/gems/ruby-2.1.2@streetmap/bin/ruby_executable_hooks:15:in

Any idea why it wouldn’t be loading the file appropriately?
Also, I’m using using rspec-rails after a suggestion from somebody in IRC.

You should have smth liek that in your street_spec.rb:

require ‘spec_helper’

describe Street do
describe ‘whatever you want’ do
before { @street = Street.new}
it ‘has something to check’ do

 end

end
end

You should remove the line ‘require “street”’.