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 trial

Ruby Build a Todo List Application with Rails 4 Build a Todo List Application with Rails 4 Cleaning Up Our Code

Rake error from out of nowhere

I cannot find where the error(s) are in my code.

Here is the terminal output:

[dcdevman@DCDevMan odot]$ bin/rake /usr/bin/ruby -S rspec ./spec/controllers/todo_items_controller_spec.rb ./spec/controllers/todo_lists_controller_spec.rb ./spec/features/todo_items/create_spec.rb ./spec/features/todo_items/edit_spec.rb ./spec/features/todo_items/index_spec.rb ./spec/features/todo_lists/create_spec.rb ./spec/features/todo_lists/destroy_spec.rb ./spec/features/todo_lists/edit_spec.rb ./spec/helpers/todo_items_helper_spec.rb ./spec/helpers/todo_lists_helper_spec.rb ./spec/models/todo_item_spec.rb ./spec/models/todo_list_spec.rb ./spec/requests/todo_lists_spec.rb ./spec/routing/todo_lists_routing_spec.rb ./spec/views/todo_items/index.html.erb_spec.rb ./spec/views/todo_lists/edit.html.erb_spec.rb ./spec/views/todo_lists/index.html.erb_spec.rb ./spec/views/todo_lists/new.html.erb_spec.rb ./spec/views/todo_lists/show.html.erb_spec.rb ...F........DEPRECATION WARNING: named_routes.helpers is deprecated, please use route_defined?(route_name) to see if a named route was defined. (called from method_missing at /usr/lib/ruby/gems/2.2.0/gems/rspec-rails-2.99.0/lib/rspec/rails/example/controller_example_group.rb:161) ..DEPRECATION WARNING: named_routes.helpers is deprecated, please use route_defined?(route_name) to see if a named route was defined. (called from method_missing at /usr/lib/ruby/gems/2.2.0/gems/rspec-rails-2.99.0/lib/rspec/rails/example/controller_example_group.rb:161) ......F............................*.

Pending: TodoListsHelper add some examples to (or delete) /home/dcdevman/Documents/devlang/RoR/odot/spec/helpers/todo_lists_helper_spec.rb # No reason given # ./spec/helpers/todo_lists_helper_spec.rb:14 TodoItemsHelper add some examples to (or delete) /home/dcdevman/Documents/devlang/RoR/odot/spec/helpers/todo_items_helper_spec.rb # No reason given # ./spec/helpers/todo_items_helper_spec.rb:14 todo_items/index.html.erb add some examples to (or delete) /home/dcdevman/Documents/devlang/RoR/odot/spec/views/todo_items/index.html.erb_spec.rb # No reason given # ./spec/views/todo_items/index.html.erb_spec.rb:4

Failures:

1) TodoItem Failure/Error: it { should belong_to(:todo_list) } NoMethodError: undefined method belong_to' for #<RSpec::Core::ExampleGroup::Nested_11:0x00000004a51050> # ./spec/models/todo_item_spec.rb:4:inblock (2 levels) in <top (required)>'

2) TodoList should have many :todo_items Failure/Error: it { should have_many(:todo_items) } NoMethodError: undefined method has_many?' for #<TodoList:0x0000000782d500> # ./spec/models/todo_list_spec.rb:4:inblock (2 levels) in <top (required)>'

Deprecation Warnings:


The semantics of RSpec::Core::ExampleGroup.pending are changing in RSpec 3. In RSpec 2.x, it caused the example to be skipped. In RSpec 3, the example will still be run but is expected to fail, and will be marked as a failure (rather than as pending) if the example passes, just like how pending with a block from within an example already works.

To keep the same skip semantics, change pending to skip. Otherwise, if you want the new RSpec 3 behavior, you can safely ignore this warning and continue to upgrade to RSpec 3 without addressing it.

Called from /home/dcdevman/Documents/devlang/RoR/odot/spec/helpers/todo_items_helper_spec.rb:14:in `block in <top (required)>'.



The semantics of RSpec::Core::ExampleGroup.pending are changing in RSpec 3. In RSpec 2.x, it caused the example to be skipped. In RSpec 3, the example will still be run but is expected to fail, and will be marked as a failure (rather than as pending) if the example passes, just like how pending with a block from within an example already works.

To keep the same skip semantics, change pending to skip. Otherwise, if you want the new RSpec 3 behavior, you can safely ignore this warning and continue to upgrade to RSpec 3 without addressing it.

Called from /home/dcdevman/Documents/devlang/RoR/odot/spec/helpers/todo_lists_helper_spec.rb:14:in `block in <top (required)>'.



The semantics of RSpec::Core::ExampleGroup.pending are changing in RSpec 3. In RSpec 2.x, it caused the example to be skipped. In RSpec 3, the example will still be run but is expected to fail, and will be marked as a failure (rather than as pending) if the example passes, just like how pending with a block from within an example already works.

To keep the same skip semantics, change pending to skip. Otherwise, if you want the new RSpec 3 behavior, you can safely ignore this warning and continue to upgrade to RSpec 3 without addressing it.

Called from /home/dcdevman/Documents/devlang/RoR/odot/spec/views/todo_items/index.html.erb_spec.rb:4:in `block in <top (required)>'.


stub_model is deprecated. Use the rspec-activemodel-mocks gem instead. Called from /home/dcdevman/Documents/devlang/RoR/odot/spec/views/todo_lists/edit.html.erb_spec.rb:5:in block (2 levels) in <top (required)>'. stub_modelis deprecated. Use therspec-activemodel-mocksgem instead. Called from /home/dcdevman/Documents/devlang/RoR/odot/spec/views/todo_lists/new.html.erb_spec.rb:5:inblock (2 levels) in <top (required)>'. stub_model is deprecated. Use the rspec-activemodel-mocks gem instead. Called from /home/dcdevman/Documents/devlang/RoR/odot/spec/views/todo_lists/index.html.erb_spec.rb:6:in block (2 levels) in <top (required)>'. Too many uses of deprecated 'stub_model'. Pass--deprecation-outor setconfig.deprecation_stream` to a file for full output.

If you need more of the backtrace for any of these deprecations to identify where to make the necessary changes, you can configure config.raise_errors_for_deprecations!, and it will turn the deprecation warnings into errors, giving you the full backtrace.

8 deprecation warnings total

Finished in 0.66942 seconds 53 examples, 2 failures, 3 pending

Failed examples:

rspec ./spec/models/todo_item_spec.rb:4 # TodoItem rspec ./spec/models/todo_list_spec.rb:4 # TodoList should have many :todo_items

Randomized with seed 31730

/usr/bin/ruby -S rspec ./spec/controllers/todo_items_controller_spec.rb ./spec/controllers/todo_lists_controller_spec.rb ./spec/features/todo_items/create_spec.rb ./spec/features/todo_items/edit_spec.rb ./spec/features/todo_items/index_spec.rb ./spec/features/todo_lists/create_spec.rb ./spec/features/todo_lists/destroy_spec.rb ./spec/features/todo_lists/edit_spec.rb ./spec/helpers/todo_items_helper_spec.rb ./spec/helpers/todo_lists_helper_spec.rb ./spec/models/todo_item_spec.rb ./spec/models/todo_list_spec.rb ./spec/requests/todo_lists_spec.rb ./spec/routing/todo_lists_routing_spec.rb ./spec/views/todo_items/index.html.erb_spec.rb ./spec/views/todo_lists/edit.html.erb_spec.rb ./spec/views/todo_lists/index.html.erb_spec.rb ./spec/views/todo_lists/new.html.erb_spec.rb ./spec/views/todo_lists/show.html.erb_spec.rb failed

I checked the files mentioned. Here is todo_item_spec.rb:

require 'spec_helper'

describe TodoItem do it { should belong_to(:todo_list) } end

And here is todo_list_spec.rb:

require 'spec_helper'

describe TodoList do it { should have_many(:todo_items) } end

Please help.

2 Answers

Seth Reece
Seth Reece
32,867 Points

Most of those are deprecation warnings. If you're using shoulda-matchers 3.0, you need to add:

Shoulda::Matchers.configure do |config|
  config.integrate do |with|
    with.test_framework :rspec
    with.library :rails
  end
end

to you spec_helper.rb

@Seth Reece: Adding that worked for me! Thank you!