Module: RSpec::Arguments::MonkeyPatcher

Includes:
RSpec::Arguments
Defined in:
lib/rspec/arguments/monkey_patcher.rb

Constant Summary

Constants included from RSpec::Arguments

ARG_PREFIX, BLOCK_ARG, BLOCK_ARG_SUFFIX, KEYWORD_ARG, KEYWORD_ARG_SUFFIX, METHOD_ARG_PREFIX, METHOD_BLOCK_ARG, METHOD_KEYWORD_ARG, METHOD_POSITIONAL_ARG, POSITIONAL_ARG, POSITIONAL_ARG_SUFFIX, VERSION

Instance Method Summary collapse

Methods included from RSpec::Arguments

#call_initializer_with_args, #call_method_with_args, #call_with_args, #method_under_test, #process_instance_subject, #process_subject, #search_method_name

Instance Method Details

#subjectObject

The only monkey-patching in this gem.

Mostly untouched, except we call ‘process_subject`, instead of simply instantiating the described_class.



13
14
15
16
17
18
# File 'lib/rspec/arguments/monkey_patcher.rb', line 13

def subject
  __memoized.fetch_or_store(:subject) do
    described = described_class || self.class..fetch(:description_args).first
    described.is_a?(Class) ? process_subject(described) : described
  end
end