Class: RSpec::Core::Example::Procsy

Inherits:
Object
  • Object
show all
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.

Wraps a Proc and exposes a run method for use in around hooks.

Examples:


RSpec.configure do |c|
  c.around do |ex| # Procsy which wraps the example
    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)

Instance Method Summary (collapse)

Constructor Details

- (Procsy) initialize(metadata, &block)

Returns a new instance of Procsy



190
191
192
193
# File 'lib/rspec/core/example.rb', line 190

def initialize(, &block)
  @metadata = 
  @proc = block
end

Instance Attribute Details

- (void) metadata (readonly)

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



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

def 
  @metadata
end