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.



169
170
171
# File 'lib/rspec/core/example.rb', line 169

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)


176
177
178
179
180
# File 'lib/rspec/core/example.rb', line 176

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.



183
184
185
186
# File 'lib/rspec/core/example.rb', line 183

def with()
  @metadata = 
  self
end