Class: RSpec::Mocks::AndInvokeImplementation

Inherits:
Object
  • Object
show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/message_expectation.rb

Overview

Handles the implementation of an ‘and_invoke` implementation.

Other Constraints collapse

Constructor Details

#initialize(procs_to_invoke) ⇒ AndInvokeImplementation

Returns a new instance of AndInvokeImplementation.



738
739
740
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/message_expectation.rb', line 738

def initialize(procs_to_invoke)
  @procs_to_invoke = procs_to_invoke
end

Instance Method Details

#call(*args, &block) ⇒ Object



742
743
744
745
746
747
748
749
750
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/message_expectation.rb', line 742

def call(*args, &block)
  proc = if @procs_to_invoke.size > 1
           @procs_to_invoke.shift
         else
           @procs_to_invoke.first
         end

  proc.call(*args, &block)
end