0
votes

When I ran my first test in RSpec I got 9 deprecations it then suggested I add the code below to spec_helper.rb which I did and it reduced the deprecations by 2 to 7.

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

The deprecation warnings that remain are as follows:

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

I did some searches here, on google and tried to look at the rspec documentation but could not find anything that really helped me. So my questions are:

  1. What does a deprecation really mean? It's clearly not an error. I think it is the difference between two versions of rspec?
  2. How do I get rid of them, the text in the deprecation warning is not really very helpful. I think trying to update rspec could help? But I am concerned to try in case it makes things worse.

Any help would be greatly appreciated!

1
What are the warnings that you are getting?Antarr Byrd
"Deprecation" warning means you are using a feature that will probably go away in a future version of the software.Daiku
Show us an example of a test that causes this warning, and the exact message that you get.Daiku
stub_model is deprecated. Use the rspec-activemodel-mocks gem instead. Called from /Users/alexbromage/Documents/Projects/odot/spec/views/todo_lists/new.html.erb_spec.rb:5:in `block (2 levels) in <top (required)>'.theoneinskane
see example above, another one here: The semantics of RSpec::Core::ExampleGroup.pending are changing in RSpec 3.theoneinskane

1 Answers

0
votes

See https://en.wikipedia.org/wiki/Deprecation for a definition of deprecation. You get rid of deprecation warnings by no longer using the feature in question. Usually, the deprecation warning suggests an alternative approach to what you are trying to do.

In the case of stub_model, the advice was to include a gem, since the functionality was going to be removed from the main RSpec software but would continue to be available in that gem.

In the case of pending, the need for a feature (passing a block) was eliminated, so continued use of that feature made no sense. See http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#changes-to-pending-semantics-and-introduction-of-skip for more information on this issue and see the larger article for more discussion of deprecation-inducing changes.