Sha256: 66c367c7096f8ee6fa0038004d9e55248d278b5d41f321e1d805f8d5326b456c
Contents?: true
Size: 1.38 KB
Versions: 4
Compression:
Stored size: 1.38 KB
Contents
# frozen_string_literal: true module ActiveMocker module MockableMethod private def __am_raise_not_mocked_error(method:, caller:, type:) variable_name, klass, method_type = if is_a?(Relation) klass = self.class.name.underscore.split("/").first ["#{klass}_relation", klass.camelize, :scopes] elsif type == "#" klass = self.class.name ["#{klass.underscore.split("/").first}_record", klass, :instance_methods] else [name, name, :class_methods] end message = <<-ERROR.strip_heredoc Unknown implementation for mock method: #{variable_name}.#{method} Stub method to continue. RSpec: allow( #{variable_name} ).to receive(:#{method}).and_return(:some_expected_result) OR Whitelist the method as safe to copy/run in the context of ActiveMocker (requires mock rebuild) # ActiveMocker.safe_methods #{method_type}: [:#{method}] class #{klass.gsub("Mock", "")} < ActiveRecord::Base end ERROR raise NotImplementedError, message, caller end end end
Version data entries
4 entries across 4 versions & 1 rubygems