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 Adding Validations to Todo Items

I get a very long warning message when running "rspec --format=documentation

Hi please help me with this warning

after run

rspec --format=documentation

I get a long text warning I tried to research but I could not find why I get those warnings and how to solve it, your help would be very appreciated.

Thanks

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/sebastian/ruby_projects/examples/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/sebastian/ruby_projects/examples/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/sebastian/ruby_projects/examples/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/sebastian/ruby_projects/examples/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/sebastian/ruby_projects/examples/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/sebastian/ruby_projects/examples/odot/spec/views/todo_lists/show.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.

3 Answers

Ok I fixed it just doing the following: in my Gemfile just added these gems

  # Support for its syntax
  gem 'rspec-its', '~> 1.0.1’

  # Support for stubbing model in view specs:
  gem 'rspec-activemodel-mocks', '~> 1.0.1'

then in the spec_helper.rb I just added

config.raise_errors_for_deprecations!

After that I just upgrade to rspec 3.0, capybara to 2.3 and rspec-expectations to 3.0, changed the version of rspec in my Gemfile

 gem 'rspec-rails', '~> 3.0.0' 
gem 'rspec-expectations', '~> 3.0.0'
gem 'capybara', '~> 2.3.0'

then I ran a bundle update, just typing "bundle" in the command line

then the last step was add these lines to my spec_helper.rb into the RSpec.configure block

config.mock_with :rspec do |c|
    c.syntax = [:should, :expect]
  end
  config.expect_with :rspec do |c|
    c.syntax = [:should, :expect]
  end

After that all the tests are runnign successfully without any warnings. Thanks

kabir k
kabir k
Courses Plus Student 18,036 Points

Hey Sebastian,

Where exactly in the Gemfile do you add this code line?

# Support for its syntax
  gem 'rspec-its', '~> 1.0.1

It's been giving me "Gemfile error" anywhere I put it in the Gemfile, when I run, bundle, in the command line

David O' Rojo
David O' Rojo
11,051 Points

You can change the offending files to use the RSpec 3 syntax or you can change the configuration to avoid displaying the warnings: https://stackoverflow.com/questions/20275510/how-to-avoid-deprecation-warning-for-stub-chain-in-rspec-3-0

What do you mean ? so the way Jason does the tests is deprecated?, what happen if I only configure to avoid the warnings?, is that the wrong solution?

David O' Rojo
David O' Rojo
11,051 Points

Sebastian Velandia It just means that some software tools evolve at a quite fast pace (like RSpec does) and by the time a nicely produced tutorial (like this one) is available, things may have changed on how to use the tools. When this happens, you have to adapt your code by making changes according the most recent way to do things or by ignoring the deprecation warnings that may be raised.

In this case, either choice will do. In the real world, is up to your aims to a particular behaviour on your application codebase or the up to the choices of your manager.

Nick Fuller
Nick Fuller
9,027 Points

"Is that the wrong solution?" No. Not at all. It's deprecated, so it will still work. Just in future versions of rspec it won't anymore.

Maybe read up on the new rspec style and convert Jason's code to the new style, heck you can even post it here for him... maybe he will update his course with your content?