Class: RSpec::Core::Example::Procsy
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/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
-
#example ⇒ Object
readonly
The RSpec::Core::Example instance.
Instance Method Summary collapse
-
#call(*args, &block) ⇒ Object
(also: #run)
Calls the proc and notes that the example has been executed.
-
#executed? ⇒ Boolean
Indicates whether or not the around hook has executed the example.
-
#initialize(example, &block) ⇒ Procsy
constructor
A new instance of Procsy.
- #inspect ⇒ Object
-
#to_proc ⇒ Object
Provides a wrapped proc that will update our ‘executed?` state when executed.
- #wrap(&block) ⇒ Object
Constructor Details
#initialize(example, &block) ⇒ Procsy
Returns a new instance of Procsy.
362 363 364 365 366 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/example.rb', line 362 def initialize(example, &block) @example = example @proc = block @executed = false end |
Instance Attribute Details
#example ⇒ Object (readonly)
The RSpec::Core::Example instance.
333 334 335 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/example.rb', line 333 def example @example end |
Instance Method Details
#call(*args, &block) ⇒ Object Also known as: run
Calls the proc and notes that the example has been executed.
350 351 352 353 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/example.rb', line 350 def call(*args, &block) @executed = true @proc.call(*args, &block) end |
#executed? ⇒ Boolean
Indicates whether or not the around hook has executed the example.
374 375 376 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/example.rb', line 374 def executed? @executed end |
#inspect ⇒ Object
379 380 381 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/example.rb', line 379 def inspect @example.inspect.gsub('Example', 'Example::Procsy') end |
#to_proc ⇒ Object
Provides a wrapped proc that will update our ‘executed?` state when executed.
358 359 360 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/example.rb', line 358 def to_proc method(:call).to_proc end |
#wrap(&block) ⇒ Object
369 370 371 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/example.rb', line 369 def wrap(&block) self.class.new(example, &block) end |