Class: RSpec::Mocks::AndYieldImplementation Private
Relationships & Source Files | |
Inherits: | Object |
Defined in: | rspec-mocks/lib/rspec/mocks/message_expectation.rb |
Overview
Handles the implementation of an and_yield
declaration.
Other Constraints
- #call(*_args_to_ignore, &block) Internal use only
- .new(args_to_yield, eval_context, error_generator) ⇒ AndYieldImplementation constructor Internal use only
Constructor Details
.new(args_to_yield, eval_context, error_generator) ⇒ AndYieldImplementation
# File 'rspec-mocks/lib/rspec/mocks/message_expectation.rb', line 695
def initialize(args_to_yield, eval_context, error_generator) @args_to_yield = args_to_yield @eval_context = eval_context @error_generator = error_generator end
Instance Method Details
#call(*_args_to_ignore, &block)
[ GitHub ]# File 'rspec-mocks/lib/rspec/mocks/message_expectation.rb', line 701
def call(*_args_to_ignore, &block) return if @args_to_yield.empty? && @eval_context.nil? @error_generator.raise_missing_block_error @args_to_yield unless block value = nil block_signature = Support::BlockSignature.new(block) @args_to_yield.each do |args| unless Support::StrictSignatureVerifier.new(block_signature, args).valid? @error_generator.raise_wrong_arity_error(args, block_signature) end value = @eval_context ? @eval_context.instance_exec(*args, &block) : yield(*args) end value end