Class: RSpec::Core::Example::Procsy
Relationships & Source Files | |
Inherits: | Object |
Defined in: | rspec-core/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.
Class Method Summary
- .new(example, &block) ⇒ Procsy constructor
Instance Attribute Summary
-
#example
readonly
The
::RSpec::Core::Example
instance. -
#executed? ⇒ Boolean
readonly
Indicates whether or not the around hook has executed the example.
Instance Method Summary
-
#call(*args, &block)
(also: #run)
Calls the proc and notes that the example has been executed.
- #inspect Internal use only Internal use only
-
#run(*args, &block)
Alias for #call.
-
#to_proc
Provides a wrapped proc that will update our #executed? state when executed.
- #wrap(&block) Internal use only Internal use only
Constructor Details
.new(example, &block) ⇒ Procsy
Instance Attribute Details
#example (readonly)
The ::RSpec::Core::Example
instance.
# File 'rspec-core/lib/rspec/core/example.rb', line 333
attr_reader :example
#executed? ⇒ Boolean
(readonly)
Indicates whether or not the around hook has executed the example.
# File 'rspec-core/lib/rspec/core/example.rb', line 374
def executed? @executed end
Instance Method Details
#call(*args, &block) Also known as: #run
Calls the proc and notes that the example has been executed.
# File 'rspec-core/lib/rspec/core/example.rb', line 350
def call(*args, &block) @executed = true @proc.call(*args, &block) end
#inspect
# File 'rspec-core/lib/rspec/core/example.rb', line 379
def inspect @example.inspect.gsub('Example', 'Example::Procsy') end
#run(*args, &block)
Alias for #call.
# File 'rspec-core/lib/rspec/core/example.rb', line 354
alias run call
#to_proc
Provides a wrapped proc that will update our #executed? state when executed.
# File 'rspec-core/lib/rspec/core/example.rb', line 358
def to_proc method(:call).to_proc end