Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialKota Fukada
16,243 PointsGot error with spec/models/todo_item_spec.rb
When I type /Users/macuser/.rbenv/shims/rspec spec/models/todo_item_spec.rb , I got error message. And I can't figure it out....
/Users/macuser/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/configuration.rb:1361:in load': cannot load such file -- /Users/macuser/spec/models/todo_item_spec.rb (LoadError)
from /Users/macuser/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/configuration.rb:1361:in
block in load_spec_files'
from /Users/macuser/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/configuration.rb:1359:in each'
from /Users/macuser/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/configuration.rb:1359:in
load_spec_files'
from /Users/macuser/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:106:in setup'
from /Users/macuser/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:92:in
run'
from /Users/macuser/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:78:in run'
from /Users/macuser/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:45:in
invoke'
from /Users/macuser/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/exe/rspec:4:in <top (required)>'
from /Users/macuser/.rbenv/versions/2.3.0/bin/rspec:23:in
load'
from /Users/macuser/.rbenv/versions/2.3.0/bin/rspec:23:in `<main>'
3 Answers
Josh Roberts
9,930 PointsThis is what fixed it for me https://github.com/thoughtbot/shoulda-matchers#rspec I just commented out what I didn't need. This left me with just the rspec framework and library rails.
Todd MacIntyre
12,248 PointsRoll back your version of shoulda matchers to that which is used in Jason's video. Put this into your gemfile in the group :test
section:
gem 'shoulda-matchers', '~> 2.4.0'
and then re-bundle your gemfiles by going into the odot directory in your console and entering:
bundle
Todd MacIntyre
12,248 PointsCheck the output from bundler to ensure that version 2.4.* is being used.
Jeff Wolfram
10,490 PointsI am having the same problem. I typed in
require 'spec_helper'
describe TodoItem do
it { should belong_to(:todo_list) }
end
It then started throwing the error Failures:
1) TodoItem
Failure/Error: it {should belong_to(:todo_list) }
NoMethodError:
undefined method belong_to' for #<RSpec::Core::ExampleGroup::Nested_1:0x007f80699890b8>
# ./spec/models/todo_item_spec.rb:4:in
block (2 levels) in <top (required)>'
Finished in 0.00107 seconds 1 example, 1 failure
Failed examples:
rspec ./spec/models/todo_item_spec.rb:4 # TodoItem
Did you have any luck figuring it out?
Kota Fukada
16,243 PointsKota Fukada
16,243 PointsThis is my todo_item_spec.rb.
require 'rails_helper'
RSpec.describe TodoItem, type: :model do it { should belong_to(:todo_list) } end