module RSpec
def self.clear_examples
current configuration when they use the runner multiple times within the
Users must invoke this if they want to clear all examples but preserve
process and ensures user configuration is persisted.
Used to ensure examples get reloaded between multiple runs in the same
def self.clear_examples world.reset configuration.reset_reporter configuration.start_time = ::RSpec::Core::Time.now configuration.reset_filters end
def self.configuration
- See: Core::Configuration -
See: RSpec.configure -
def self.configuration @configuration ||= RSpec::Core::Configuration.new end
def self.configure
- See: Core::Configuration -
Other tags:
- Yield: - global configuration
def self.configure yield configuration if block_given? end
def self.const_missing(name)
- Private: -
def self.const_missing(name) # Load rspec-expectations when RSpec::Matchers is referenced. This allows # people to define custom matchers (using `RSpec::Matchers.define`) before # rspec-core has loaded rspec-expectations (since it delays the loading of # it to allow users to configure a different assertion/expectation # framework). `autoload` can't be used since it works with ruby's built-in # require (e.g. for files that are available relative to a load path dir), # but not with rubygems' extended require. # # As of rspec 2.14.1, we no longer require `rspec/mocks` and # `rspec/expectations` when `rspec` is required, so we want # to make them available as an autoload. require MODULES_TO_AUTOLOAD.fetch(name) { return super } ::RSpec.const_get(name) end
def self.current_example
end
end
# ...
example = fetch_current_example.call(self)
c.before(:example) do
proc { RSpec.current_example } : proc { |context| context.example }
fetch_current_example = RSpec.respond_to?(:current_example) ?
# available until RSpec 3.0.
# context.example is deprecated, but RSpec.current_example is not
RSpec.configure do |c|
@example
versions of RSpec 2 and 3.
to the example currently being executed and also want to support all
The primary audience for this method is library authors who need access
The example being executed.
def self.current_example RSpec::Support.thread_local_data[:current_example] end
def self.current_example=(example)
- Api: - private
def self.current_example=(example) RSpec::Support.thread_local_data[:current_example] = example end
def self.reset
they use the runner multiple times within the same process. Users must deal
Users must invoke this if they want to have the configuration reset when
defaults between multiple runs in the same process.
Used to ensure examples get reloaded and user configuration gets reset to
def self.reset RSpec::ExampleGroups.remove_all_constants @world = nil @configuration = nil end
def self.world
- Private: -
def self.world @world ||= RSpec::Core::World.new end