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

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/core/example.rb

Overview

Note:

This class also exposes the instance methods of RSpec::Core::Example, proxying them through to the wrapped RSpec::Core::Example instance.

Wraps both a Proc and an RSpec::Core::Example for use in around hooks. In around hooks we need to yield this special kind of object (rather than the raw RSpec::Core::Example) because when there are multiple around hooks we have to wrap them recursively.

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(example, &block)

Returns a new instance of Procsy

214
215
216
217
# File 'lib/rspec/core/example.rb', line 214
def initialize(example, &block)
  @example = example
  @proc    = block
end

Instance Attribute Details

- (void) example (readonly)

The RSpec::Core::Example instance.

201
202
203
# File 'lib/rspec/core/example.rb', line 201
def example
  @example
end