Sha256: eb118944f0efe5cc4b6c66b33e77e7b269ff9114031918afbc395c9b6afb8705

Contents?: true

Size: 816 Bytes

Versions: 2

Compression:

Stored size: 816 Bytes

Contents

# frozen_string_literal: true

module ActiveMocker
  module MockableMethod
    private

    def __am_raise_not_mocked_error(method:, caller:, type:)
      variable_name = if is_a?(Relation)
                        "#{self.class.name.underscore.split("/").first}_relation"
                      elsif type == "#"
                        "#{self.class.name.underscore}_record"
                      else
                        name
                      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)
      ERROR

      raise NotImplementedError, message, caller
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
active_mocker-2.5.3 lib/active_mocker/mock/mockable_method.rb
active_mocker-2.5.2 lib/active_mocker/mock/mockable_method.rb