Module: RSpec::Core::Example::Procsy

Defined in:
lib/rspec/core/example.rb

Overview

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.

Used to extend a Proc with behavior that makes it look something like an RSpec::Core::Example in an around hook.

Examples:


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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#metadataObject (readonly)

The metadata of the RSpec::Core::Example instance.



173
174
175
# File 'lib/rspec/core/example.rb', line 173

def 
  @metadata
end

Class Method Details

.extended(proc) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Adds a run method to the extended Proc, allowing it to be invoked in an around hook using either run or call.

Parameters:

  • (Proc)


180
181
182
183
184
# File 'lib/rspec/core/example.rb', line 180

def self.extended(proc)
  # @api public
  # Foo bar
  def proc.run; call; end
end

Instance Method Details

#with(metadata) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



187
188
189
190
# File 'lib/rspec/core/example.rb', line 187

def with()
  @metadata = 
  self
end