Support conversion of RSpec::Core::ExampleGroup#example #23

yujinakayama opened this Issue Nov 13, 2013 · 0 comments


None yet
1 participant

yujinakayama commented Nov 13, 2013


Deprecated since 2.99, removed at 3.0.

Yielding current running example to it/example and before/after hooks

Available since 2.99.


Available since 2.99.

expose_current_running_example_as config option

Available since 2.99.


rspec/rspec-core#666 (comment)

They have completely different purposes. It's not an either/or.

  • expose_current_running_example_as :example config option is meant to support users who are using gems that depend on the RSpec 2 API. It's not meant for library authors to use.
  • RSpec.current_example is an idea @alindeman suggested as a possible means to assist library authors in making their code work on RSpec 2 and RSpec 3. It's not meant for end users to use.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment