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 Write Our First Tests

Why am I getting this failure when I run bin/rake spec?

here is the error:

treehouse:~/projects/odot (master) $ bin/rake spec
/home/treehouse/.rbenv/versions/2.0.0-p353/bin/ruby -S 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
**................F............

Pending:
  TodoListsHelper add some examples to (or delete) /home/treehouse/projects/odot/spec/helpers/todo_lists_helper_spec.rb
    # No reason given
    # ./spec/helpers/todo_lists_helper_spec.rb:14
  TodoList add some examples to (or delete) /home/treehouse/projects/odot/spec/models/todo_list_spec.rb
    # No reason given
    # ./spec/models/todo_list_spec.rb:4

Failures:

  1) Creating todo lists redirects to the todo list index page on success
     Failure/Error: expect(page).to have_content("New Todo List")
       expected to find text "New Todo List" in "New todo_list Title Description Back"
     # ./spec/features/todo_lists/create_spec.rb:7:in `block (2 levels) in <top (required)>'

Deprecation Warnings:

--------------------------------------------------------------------------------
RSpec::Core::ExampleGroup#example is deprecated and will be removed
in RSpec 3. There are a few options for what you can use instead:

  - rspec-core's DSL methods (`it`, `before`, `after`, `let`, `subject`, etc)
    now yield the example as a block argument, and that is the recommended
    way to access the current example from those contexts.
  - The current example is now exposed via `RSpec.current_example`,
    which is accessible from any context.
  - If you can't update the code at this call site (e.g. because it is in
    an extension gem), you can use this snippet to continue making this
    method available in RSpec 2.99 and RSpec 3:

      RSpec.configure do |c|
        c.expose_current_running_example_as :example
      end

(Called from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/capybara-2.1.0/lib/capybara/rspec.rb:20:in `block (2 levels) in <top (required)>')
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
RSpec::Core::ExampleGroup#example is deprecated and will be removed
in RSpec 3. There are a few options for what you can use instead:

  - rspec-core's DSL methods (`it`, `before`, `after`, `let`, `subject`, etc)
    now yield the example as a block argument, and that is the recommended
    way to access the current example from those contexts.
  - The current example is now exposed via `RSpec.current_example`,
    which is accessible from any context.
  - If you can't update the code at this call site (e.g. because it is in
    an extension gem), you can use this snippet to continue making this
    method available in RSpec 2.99 and RSpec 3:

      RSpec.configure do |c|
        c.expose_current_running_example_as :example
      end

(Called from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/capybara-2.1.0/lib/capybara/rspec.rb:21:in `block (2 levels) 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/treehouse/projects/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/treehouse/projects/odot/spec/models/todo_list_spec.rb:4:in `block in <top (required)>'.

--------------------------------------------------------------------------------

`stub_model` is deprecated. Use the `rspec-activemodel-mocks` gem instead. Called from /home/treehouse/projects/odot/spec/views/todo_lists/index.html.erb_spec.rb:6:in `block (2 levels) in <top (required)>'.
`stub_model` is deprecated. Use the `rspec-activemodel-mocks` gem instead. Called from /home/treehouse/projects/odot/spec/views/todo_lists/index.html.erb_spec.rb:10:in `block (2 levels) in <top (required)>'.
`stub_model` is deprecated. Use the `rspec-activemodel-mocks` gem instead. Called from /home/treehouse/projects/odot/spec/views/todo_lists/edit.html.erb_spec.rb:5:in `block (2 levels) in <top (required)>'.
Too many uses of deprecated '`stub_model`'. Pass `--deprecation-out` or set `config.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.

9 deprecation warnings total

Finished in 1.78 seconds
31 examples, 1 failure, 2 pending

Failed examples:

rspec ./spec/features/todo_lists/create_spec.rb:4 # Creating todo lists redirects to the todo list index page on success

Randomized with seed 6914

/home/treehouse/.rbenv/versions/2.0.0-p353/bin/ruby -S 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
treehouse:~/projects/odot (master) $ 

2 Answers

Seth Reece
Seth Reece
32,867 Points

Hi Kaitlin,

You are getting a handful of deprecation warnings. Adding the line: c.expose_current_running_example_as :example to your spec helper will clear some up. Your failed test is looking for "New Todo List", but is finding "New todo_list". You need to change either your test, or your view. I would suggest the view since "New todo_list" doesn't give a good user experience. Also if you add "gem 'rspec-activemodel-mocks'" to your gem file under test: e.g.

group :test do
  gem 'capybara', '~> 2.1.0'
  gem "capybara-email", "~> 2.2.0"
  gem 'shoulda-matchers', '~> 2.6.0'
  gem 'rspec-activemodel-mocks'
end

Should get rid of your stub_model deprecation warning.

Neither one of these things fixed my errors unfortunately

Jan Park
Jan Park
4,296 Points

I'm not quite sure why you get those errors, but I also had issues with the same command.

So, I checked the file spec/spec_helper.rb and noticed that I have a typo on 'capybara/rspec' because I've wrote capybara/rsspec, (notice the double s).

# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'capybara/rspec'

I hope this helps.