module RSpec::Core::Example::Procsy

Used to extend a `Proc` with behavior that makes it look something like an {Example} in an {Hooks#around around} hook.

@note Procsy, itself, is not a public API, but we're documenting it

here to document how to interact with the object yielded to an
`around` hook.

@example

RSpec.configure do |c|
  c.around do |ex| # ex is a Proc extended with Procsy
    if ex.metadata[:key] == :some_value && some_global_condition
      raise "some message"
    end
    ex.run         # run delegates to ex.call
  end
end

Attributes

metadata[R]

The `metadata` of the {Example} instance.

Public Class Methods

extended(proc) click to toggle source

@api private @param [Proc] Adds a `run` method to the extended Proc, allowing it to be invoked in an [around](../Hooks#around-instance_method) hook using either `run` or `call`.

# File lib/rspec/core/example.rb, line 176
def self.extended(proc)
  # @api public
  # Foo bar
  def proc.run; call; end
end

Public Instance Methods

with(metadata) click to toggle source

@api private

# File lib/rspec/core/example.rb, line 183
def with(metadata)
  @metadata = metadata
  self
end