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
- 
  
      #example  ⇒ void 
  
      readonly
    
The RSpec::Core::Example instance.
 
Instance Method Summary collapse
- 
  
      #call(*args, &block)  ⇒ void 
      (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.
 - 
  
      #to_proc  ⇒ void 
  
    
Provides a wrapped proc that will update our
executed?state when executed. 
Constructor Details
#initialize(example, &block) ⇒ Procsy
Returns a new instance of Procsy.
      355 356 357 358 359  | 
    
      # File 'lib/rspec/core/example.rb', line 355 def initialize(example, &block) @example = example @proc = block @executed = false end  | 
  
Instance Attribute Details
#example ⇒ void (readonly)
The RSpec::Core::Example instance.
      326 327 328  | 
    
      # File 'lib/rspec/core/example.rb', line 326 def example @example end  | 
  
Instance Method Details
#call(*args, &block) ⇒ void Also known as: run
Calls the proc and notes that the example has been executed.
      343 344 345 346  | 
    
      # File 'lib/rspec/core/example.rb', line 343 def call(*args, &block) @executed = true @proc.call(*args, &block) end  | 
  
#executed? ⇒ Boolean
Indicates whether or not the around hook has executed the example.
      367 368 369  | 
    
      # File 'lib/rspec/core/example.rb', line 367 def executed? @executed end  | 
  
#to_proc ⇒ void
Provides a wrapped proc that will update our executed? state when
executed.
      351 352 353  | 
    
      # File 'lib/rspec/core/example.rb', line 351 def to_proc method(:call).to_proc end  |