Class: RSpec::Core::Example::Procsy
- Inherits:
-
Object
- Object
- RSpec::Core::Example::Procsy
- Defined in:
- lib/rspec/core/example.rb
Overview
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.
Instance Attribute Summary (collapse)
-
- (void) example
readonly
The RSpec::Core::Example instance.
Instance Method Summary (collapse)
-
- (void) call(*args, &block)
(also: #run)
Calls the proc and notes that the example has been executed.
-
- (Boolean) executed?
Indicates whether or not the around hook has executed the example.
-
- (Procsy) initialize(example, &block)
constructor
A new instance of Procsy.
-
- (void) to_proc
Provides a wrapped proc that will update our
executed?
state when executed.
Constructor Details
- (Procsy) initialize(example, &block)
Returns a new instance of Procsy
257 258 259 260 261 |
# File 'lib/rspec/core/example.rb', line 257 def initialize(example, &block) @example = example @proc = block @executed = false end |
Instance Attribute Details
- (void) example (readonly)
The RSpec::Core::Example instance.
230 231 232 |
# File 'lib/rspec/core/example.rb', line 230 def example @example end |
Instance Method Details
- (void) call(*args, &block) Also known as: run
Calls the proc and notes that the example has been executed.
245 246 247 248 |
# File 'lib/rspec/core/example.rb', line 245 def call(*args, &block) @executed = true @proc.call(*args, &block) end |
- (Boolean) executed?
Indicates whether or not the around hook has executed the example.
269 270 271 |
# File 'lib/rspec/core/example.rb', line 269 def executed? @executed end |
- (void) to_proc
Provides a wrapped proc that will update our executed?
state when
executed.
253 254 255 |
# File 'lib/rspec/core/example.rb', line 253 def to_proc method(:call).to_proc end |