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

SERGIO RODRIGUEZ
SERGIO RODRIGUEZ
17,532 Points

Besides the RSpec::Core::ExampleGroup#example is deprecated warning, I get a bunch of `stub_model` is deprecated.

What does this warning mean? Can I continue with this warning? How can I fix this?

3 Answers

Hi Sergio

Okay, can you add the following line to spec_helper.rb file?

Search folder spec ---> views ---> spec_helper.rb
@0:41

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

More details

Hope that helps ;-)

SERGIO RODRIGUEZ
SERGIO RODRIGUEZ
17,532 Points

Thanks!

That seems to fix the RSpec::Core::ExampleGroup#example but not the "stub_model is deprecated" warning.

Ah I forgot to mention, you need to add another lines to spec_helper.rb and also put in Gemfile file.

RSpec.configure do |c|
  c.raise_errors_for_deprecations!
end

-Open your Gemfile to add below:

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

  # Support for stubbing model in view specs:
  gem 'rspec-activemodel-mocks', '~> 1.0.1'
SERGIO RODRIGUEZ
SERGIO RODRIGUEZ
17,532 Points

should I run bundle after editing the Gemfile?

Yes correct.

Hello, I am running into the same issue, I have nine deprecation warnings regarding the Stub Model. I tried to implement the fix you listed and it caused a bunch of failures. Any different suggestions to get it working?

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

`stub_model` is deprecated. Use the `rspec-activemodel-mocks` gem instead. Called from /Users/Blake/TreeHouse/projects/odot/spec/views/todo_lists/show.html.erb_spec.rb:5:in `block (2 levels) in <top (required)>'.
`stub_model` is deprecated. Use the `rspec-activemodel-mocks` gem instead. Called from /Users/Blake/TreeHouse/projects/odot/spec/views/todo_lists/edit.html.erb_spec.rb:5:in `block (2 levels) in <top (required)>'.
`stub_model` is deprecated. Use the `rspec-activemodel-mocks` gem instead. Called from /Users/Blake/TreeHouse/projects/odot/spec/views/todo_lists/new.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 0.78846 seconds
30 examples, 0 failures, 2 pending

Randomized with seed 19003