Method: RSpec.current_scope

Defined in:
lib/rspec/core.rb

.current_scopeSymbol

Get the current RSpec execution scope

Returns (in order of lifecycle):

  • :suite as an initial value, this is outside of the test lifecycle.
  • :before_suite_hook during before(:suite) hooks.
  • :before_context_hook during before(:context) hooks.
  • :before_example_hook during before(:example) hooks and around(:example) before example.run.
  • :example within the example run.
  • :after_example_hook during after(:example) hooks and around(:example) after example.run.
  • :after_context_hook during after(:context) hooks.
  • :after_suite_hook during after(:suite) hooks.
  • :suite as a final value, again this is outside of the test lifecycle.

Reminder, :context hooks have :all alias and :example hooks have :each alias.

Returns:

  • (Symbol)
[View source]

154
155
156
# File 'lib/rspec/core.rb', line 154

def self.current_scope
  RSpec::Support.thread_local_data[:current_scope]
end