Bummer! You have been redirected as the page you requested could not be found.

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

Vishakha Agarwal
Vishakha Agarwal
9,130 Points

Getting Depreciation Warning each time I run the test.

Each time I run the test I get the following warning along with the test results. What should I do?

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 /Users/vishakhaagarwal/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.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 /Users/vishakhaagarwal/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/capybara-2.1.0/lib/capybara/rspec.rb:21:in `block (2 levels) in <top (required)>')

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.

Satu Korhonen
Satu Korhonen
3,360 Points

I am getting the same as well. What are they? What do I need to do now?

Yeah I get the same error... from what i can tell it is because we are using a newer version of RSpec where some methods are deprecated? But i have not found a "smooth" solution yet... I am totally new on Ruby and the Rails framework, it's my first back-end language that i confronted. I will post the solution here, if I find one....

Iv'e done a bunch of courses on teamtreehouse and they are always good! But this Rails todo list app has been VERY VERY upsetting / confusing / frustrating / (Maybe a little outdated???) !! Iv'e had to reinstall ruby, rails and other things several times and had to look for solutions on other sites for problems iv'e encountered from the very first video and every video after that because the instructions in the videos are not up to date with Rails!

First I installed a newer version of Ruby and Rails and then nothing worked anymore and i didn't find a solution, my bad because the instructions are for the older ruby on rails. So i reinstalled everything with the exact versions shown in the videos and I STILL got a bunch of errors, that i luckily found solutions for after some research. But it is time consuming and irritating when you think that the instructions should be correct for something you've never done before! At least post the solutions to common "new" errors because version updates or other things in the teachers notes!

Please do something about this course TTH !

Sorry for the negative comment, had to say it... I'm not the only one. ( Otherwise, you are AWESOME Treehouse ;D )

I am also having the same issue, wish I knew how to make it go away. This course needs to be updated.

2 Answers

Otavio Gaiao
Otavio Gaiao
1,933 Points

I'm also having the same problem.... This course is confusing :/

Jonathan Chua
Jonathan Chua
4,136 Points

Here is everything I know about this issue after working through it myself. The specific solution seems to depend on the exact depreciation error that comes up and what the code in your odot/spec/spec_helper.rb file looks like.

If you see this:

rspec-rails 3 will no longer automatically infer an example group's spec type
from the file location. You can explicitly opt-in to this feature using this
snippet:

RSpec.configure do |config|
  config.infer_spec_type_from_file_location!
end

then add this to the Rspec.configure do |config| block just above the line that contains end.

config.infer_spec_type_from_file_location!

My spec_helper.rb file already contained that line of code. My depreciation warning looked like this:

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 

The solution is to add this to the Rspec.configure do |c| block just above the line that contains end.

c.expose_current_running_example_as :example 

However, my spec_helper.rb file does not contain a Rspec.configure do |c| block. Instead it has Rspec.configure do |config|.

In this case, the solution is to add this to the Rspec.configure do |config| block just above the line that contains end.

config.expose_current_running_example_as :example

What are deprecation warnings and why do these code snippets make them go away?

A depreciation warning tells you that in the next version of the software something will not work the way that it is working now in the current version. Adding these snippets explicitly tells rspec to continue behaving the same if and when you upgrade it to the next version. If a depreciation warning is ignored and the software is upgraded it will probably break your code and you'll have to rewrite a bunch of it to make it work again.