Ruby Build a Todo List Application with Rails 4 Build a Todo List Application with Rails 4 Write Our First Tests

Roland Cedo
Roland Cedo
21,261 Points

Rake aborts rSpec with several deprecation errors

Trying to run bin/rake rspec but I get several deprecation errors:

[DEPRECATION] `last_comment` is deprecated.  Please use `last_description` instead.
[DEPRECATION] `last_comment` is deprecated.  Please use `last_description` instead.
[DEPRECATION] `last_comment` is deprecated.  Please use `last_description` instead.
[DEPRECATION] `last_comment` is deprecated.  Please use `last_description` instead.
[DEPRECATION] `last_comment` is deprecated.  Please use `last_description` instead.
[DEPRECATION] `last_comment` is deprecated.  Please use `last_description` instead.
[DEPRECATION] `last_comment` is deprecated.  Please use `last_description` instead.
rake aborted!
Don't know how to build task 'rspec' (see --tasks)
/home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/task_manager.rb:71:in `[]'
/home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/application.rb:149:in `invoke_task'
/home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/application.rb:106:in `each'
/home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/application.rb:106:in `block in top_level'
/home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/application.rb:115:in `run_with_threads'
/home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/application.rb:100:in `top_level'
/home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/application.rb:78:in `block in run'
/home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/application.rb:176:in `standard_exception_handling'
/home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/application.rb:75:in `run'
bin/rake:4:in `<main>'

Here's my Gemfile:

source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.1'

# Use sqlite3 as the database for Active Record
gem 'sqlite3'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'

# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'

# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'

# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'


group :doc do
  # bundle exec rake doc:rails generates the API under doc/api.
  gem 'sdoc', require: false
end


group :development do
    # Rspec for testing
    gem 'rspec-rails', '~> 2.0'
end

group :test do
    gem 'capybara', '~> 2.1.0'
end
# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.1.2'

# Use unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano', group: :development

# Use debugger
# gem 'debugger', group: [:development, :test]

I followed the tutorial up to this point with no previous issues. I've also tried to update rspec-core with no avail. Any ideas?

Roland Cedo
Roland Cedo
21,261 Points

Ceri-anne Jackson: Asked some Mod's and Tweeted the issue to Treehouse. Fingers crossed!

5 Answers

Jay McGavren
STAFF
Jay McGavren
Treehouse Teacher

The video actually shows running rake spec, not rake rspec. (My guess is that Rails does this because you could theoretically write specs in a different framework besides RSpec.) You can get a list of the tasks that are available to run by typing rake -T (or bin/rake -T) at the command line.

But actually, I typically just run my specs by running RSpec directly, without using Rake (as Jason demonstrates later in the video). Just type rspec (or bin/rspec) by itself at the command line, and it will find and run all specs in your spec/ directory.

Jay McGavren
Jay McGavren
Treehouse Teacher

By the way, the deprecation warnings are unrelated, and can probably safely be ignored for now.

Roland Cedo
Roland Cedo
21,261 Points

Hey Jay! Thanks for the reply. So I've run both 'rake spec' and bin/rpsec and got different results.

So I run 'rake spec' and here's what I get:

treehouse:~/projects/odot $ rake spec
[DEPRECATION] `last_comment` is deprecated.  Please use `last_description` instead.
[DEPRECATION] `last_comment` is deprecated.  Please use `last_description` instead.
[DEPRECATION] `last_comment` is deprecated.  Please use `last_description` instead.
[DEPRECATION] `last_comment` is deprecated.  Please use `last_description` instead.
[DEPRECATION] `last_comment` is deprecated.  Please use `last_description` instead.
[DEPRECATION] `last_comment` is deprecated.  Please use `last_description` instead.
[DEPRECATION] `last_comment` is deprecated.  Please use `last_description` instead.
[DEPRECATION] `last_comment` is deprecated.  Please use `last_description` instead.
[DEPRECATION] `last_comment` is deprecated.  Please use `last_description` instead.
[DEPRECATION] `last_comment` is deprecated.  Please use `last_description` instead.
/home/treehouse/.rbenv/versions/2.0.0-p353/bin/ruby -S bundle exec rspec "./spec/controllers/todo_lists_controller_spec.rb" "./spec/features/todo_lists/create_spec.rb" "./spec/helpers/todo_lists_helper_spec.rb" "./spec/models/todo_list_spec.rb" "./spec/requests/todo_lists_spec.rb" "./spec/routing/todo_lists_routing_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"
`include Capybara` is deprecated. Please use `include Capybara::DSL` instead.
`include Capybara` is deprecated. Please use `include Capybara::DSL` instead.
`include Capybara` is deprecated. Please use `include Capybara::DSL` instead.
/home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:229:in `require': cannot load such file -- spec-helper (LoadError)
    from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:229:in `block in require'
    from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:214:in `load_dependency'
    from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:229:in `require'
    from /home/treehouse/projects/odot/spec/features/todo_lists/create_spec.rb:1:in `<top (required)>'
    from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:223:in `load'
    from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:223:in `block in load'
    from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:214:in `load_dependency'
    from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:223:in `load'
    from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/configuration.rb:306:in `block in load_spec_files'
    from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/configuration.rb:306:in `map'
    from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/configuration.rb:306:in `load_spec_files'
    from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/command_line.rb:18:in `run'
    from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/runner.rb:55:in `run_in_process'
    from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/runner.rb:46:in `run'
    from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/runner.rb:10:in `block in autorun'
rake aborted!
ruby -S bundle exec rspec "./spec/controllers/todo_lists_controller_spec.rb" "./spec/features/todo_lists/create_spec.rb" "./spec/helpers/todo_lists_helper_spec.rb" "./spec/models/todo_list_spec.rb" "./spec/requests/todo_lists_spec.rb" "./spec/routing/todo_lists_routing_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

Tasks: TOP => spec
(See full trace by running task with --trace)

Where as running bin/rspec returns a 0 examples/ 0 failures message. Where the video says it should have 30 examples, 0 failures, 2 pending.:

treehouse:~/projects/odot $ bin/rspec
Finished in 0.00002 seconds
0 examples, 0 failures

Also, running the bin/rspec found in spec/features/todo_list/create_spec.rb produces a LoadError:

treehouse:~/projects/odot $ bin/rspec spec/features/todo_list/create_spec.rb
/home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/configuration.rb:306:in `load': cannot load such file -- /home/treehouse/projects/odot/spec/features/todo_list/create_spec.rb (LoadError)
    from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/configuration.rb:306:in `block in load_spec_files'
    from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/configuration.rb:306:in `map'
    from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/configuration.rb:306:in `load_spec_files'
    from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/command_line.rb:18:in `run'
    from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/runner.rb:55:in `run_in_process'
    from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/runner.rb:46:in `run'
    from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/runner.rb:10:in `block in autorun'

Would be more than happy to give you more info on any of this. Thoughts?

Jay McGavren
STAFF
Jay McGavren
Treehouse Teacher

What happens if you run bin/rspec with a specific file name, e.g. bin/rspec spec/features/todo_lists/create_spec.rb?

Roland Cedo
Roland Cedo
21,261 Points

A LoadError from 'require' not being able to load such file spec-helper

treehouse:~/projects/odot $ bin/rspec spec/features/todo_lists/create_spec.rb
/home/treehouse/projects/odot/spec/features/todo_lists/create_spec.rb:1:in `require': cannot load such file -- spec-helper (LoadError)
    from /home/treehouse/projects/odot/spec/features/todo_lists/create_spec.rb:1:in `<top (required)>'
    from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/configuration.rb:306:in `load'
    from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/configuration.rb:306:in `block in load_spec_files'
    from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/configuration.rb:306:in `map'
    from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/configuration.rb:306:in `load_spec_files'
    from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/command_line.rb:18:in `run'
    from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/runner.rb:55:in `run_in_process'
    from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/runner.rb:46:in `run'
    from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/runner.rb:10:in `block in autorun'
Jay McGavren
STAFF
Jay McGavren
Treehouse Teacher

Hi, Roland,

Now we're getting into stuff that's difficult to diagnose without access to your project. I would suggest downloading the sample project from the Downloads tab here, and try the same commands there (you'll have to bundle install and bin/rake db:migrate first). If that works, you might compare the code between your project and the downloaded project (possibly using the diff command: diff --recursive my_odot_dir/ downloaded_odot_dir/) to see if there's a typo somewhere.

Roland Cedo
Roland Cedo
21,261 Points

Yeah, I was thinking of bringing in the whole project file and starting fresh. Thanks for helping out as much as you did! I'll drop another comment if I find anything interesting.

Jay McGavren
STAFF
Jay McGavren
Treehouse Teacher

Hi, Roland,

OK, so it seems like we're having better luck with the bin/rspec command; let's try and get that one working. My first guess is that it's not finding the *_spec.rb files in your spec/ directory for some reason.

I downloaded the project files under the Downloads link at this page, unzipped, ran find spec/ from the project directory, and got this list of files:

$ find spec/
spec/
spec/controllers
spec/controllers/todo_lists_controller_spec.rb
spec/features
spec/features/todo_lists
spec/features/todo_lists/create_spec.rb
spec/helpers
spec/helpers/todo_lists_helper_spec.rb
spec/models
spec/models/todo_list_spec.rb
spec/requests
spec/requests/todo_lists_spec.rb
spec/routing
spec/routing/todo_lists_routing_spec.rb
spec/spec_helper.rb
spec/views
spec/views/todo_lists
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

What files do you have in your spec/ directory?

Roland Cedo
Roland Cedo
21,261 Points

Hey again Jay,

Here's what 'find spec' gives me:

treehouse:~/projects/odot $ find spec
spec
spec/controllers
spec/controllers/todo_lists_controller_spec.rb
spec/features
spec/features/todo_lists
spec/features/todo_lists/create_spec.rb
spec/helpers
spec/helpers/todo_lists_helper_spec.rb
spec/models
spec/models/todo_list_spec.rb
spec/requests
spec/requests/todo_lists_spec.rb
spec/routing
spec/routing/todo_lists_routing_spec.rb
spec/spec_helper.rb
spec/views
spec/views/todo_lists
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
Jay McGavren
STAFF
Jay McGavren
Treehouse Teacher

Ah, OK. That error message is helpful. Check the require statement in spec/features/todo_lists/create_spec.rb; I think the problem is there...

Roland Cedo
Roland Cedo
21,261 Points

Ahhh yeah, messed it up the require statement. It should have been an underscore. Fixed that and ran bin/rspec again, now getting this, but I'm not sure if it's from my test or not. Copy and pasted the first test from the Project File zip you linked to and still fails. We can p

treehouse:~/projects/odot $ bin/rspec spec/features/todo_lists/create_spec.rb
`include Capybara` is deprecated. Please use `include Capybara::DSL` instead.
`include Capybara` is deprecated. Please use `include Capybara::DSL` instead.
`include Capybara` is deprecated. Please use `include Capybara::DSL` instead.
F

Failures:
  1) Creating To Do List redirects to the to do list index page on success
     Failure/Error: Unable to find matching line from backtrace
     undefined method `run_all' for []:Array
     # /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/hooks.rb:116:in `run_hook_filtered'
     # /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/example_group.rb:176:in `eval_before_alls'
     # /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/example_group.rb:231:in `run'
     # /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/command_line.rb:26:in `block (2 levels) in run'
     # /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/command_line.rb:26:in `map'
     # /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/command_line.rb:26:in `block in run'
     # /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/reporter.rb:11:in `report'
     # /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/command_line.rb:23:in `run'
     # /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/runner.rb:55:in `run_in_process'
     # /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/runner.rb:46:in `run'
     # /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/runner.rb:10:in `block in autorun'

Finished in 0.00029 seconds
1 example, 1 failure
/home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/hooks.rb:116:in `run_hook_filtered': undefined method `run_all' for []:Array (NoMethodError)
    from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/example_group.rb:215:in `eval_after_alls'
    from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/example_group.rb:238:in `run'
    from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/command_line.rb:26:in `block (2 levels) in run'
    from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/command_line.rb:26:in `map'
    from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/command_line.rb:26:in `block in run'
    from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/reporter.rb:11:in `report'
    from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/command_line.rb:23:in `run'
    from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/runner.rb:55:in `run_in_process'
    from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/runner.rb:46:in `run'
    from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.0.0/lib/rspec/core/runner.rb:10:in `block in autorun'

Here's the first test that I copied from the Project Files:

require 'spec_helper'

describe "Creating todo lists" do
  it "redirects to the todo list index page on success" do
    visit "/todo_lists"
    click_link "New Todo list"
    expect(page).to have_content("New todo_list")

    fill_in "Title", with: "My todo list"
    fill_in "Description", with: "This is what I'm doing today."
    click_button "Create Todo list"

    expect(page).to have_content("My todo list")
  end
end

Thanks for all the timely replies tonight btw. I'm headed off to bed for now, happy to pick this back up tomorrow :)