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 trialDylan Shine
17,565 PointsRspec Deprecation Warnings
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/dylanshine/.rbenv/versions/2.0.0-p481/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 /Users/dylanshine/.rbenv/versions/2.0.0-p481/lib/ruby/gems/2.0.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.
2 deprecation warnings total
require 'spec_helper'
# Specs in this file have access to a helper object that includes
# the TodoListsHelper. For example:
#
# describe TodoListsHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
describe TodoListsHelper do
pending "add some examples to (or delete) #{__FILE__}"
end
RSpec.configure do |config|
config.expose_current_running_example_as :example
config.raise_errors_for_deprecations!
end
Can someone help me get rid of these?
2 Answers
Alessandro Middei
8,419 PointsI prefere add this line:
config.expose_current_running_example_as :example
In spec_helper.rb file under the line
config.order = "random"
It removes the deprecation warnings
Kyle Daugherty
16,441 PointsThe rspec generator
rails generate rspec:install
now puts the
--warnings
option in the .rspec file by default. Delete that line and it will silence the deprecation warnings.
Robert French
2,219 Pointsthe .rspec file contains only
--color
as of July 28 2015 Ruby 2.2.2p95 Rails 4.2.3 RSpec 2.99.2
jamaleh gyulay
874 Pointsjamaleh gyulay
874 Pointsthank you!