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
-
#instance ⇒ Object
Reference to the instantiated object, if testing an instance or instance method (but not class method).
-
#subject ⇒ Object
The only monkey-patching in this gem.
Methods included from RSpec::Arguments
#call_initializer_with_args, #call_method_with_args, #call_with_args, #method_under_test, #process_instance, #process_instance_subject, #process_subject, #search_method_name
Instance Method Details
#instance ⇒ Object
Reference to the instantiated object, if testing an instance or instance method (but not class method).
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rspec/arguments/monkey_patcher.rb', line 33 def instance __memoized.fetch_or_store(:instance) do = self.class. described = described_class || .fetch(:description_args).first if described.is_a?(Class) if [:rspec_arguments] || [:method] || [:class_method] raise 'Instance is only available when testing class instances or instance methods' if [:class_method] process_instance(described) else described.new end end end end |
#subject ⇒ Object
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 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rspec/arguments/monkey_patcher.rb', line 13 def subject __memoized.fetch_or_store(:subject) do = self.class. described = described_class || .fetch(:description_args).first if described.is_a?(Class) if [:rspec_arguments] || [:method] || [:class_method] process_subject(described) else described.new end else described end end end |