Module: Taski::TestHelper::TaskExtension Private

Defined in:
lib/taski/test_helper.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Module prepended to Task's singleton class to intercept define_class_accessor. Wraps the original accessor with a mock check.

Instance Method Summary collapse

Instance Method Details

#define_class_accessor(method) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/taski/test_helper.rb', line 25

def define_class_accessor(method)
  super
  original_method = self.method(method)

  define_singleton_method(method) do |args: {}|
    mock = MockRegistry.mock_for(self)
    return mock.get_exported_value(method) if mock

    original_method.call(args: args)
  end
end