Sha256: fb20624804c7f25ae9e05435b41314814ee63f82ae0f04687c8e655af5e0f4d7

Contents?: true

Size: 807 Bytes

Versions: 1

Compression:

Stored size: 807 Bytes

Contents

# typed: strict

require_relative "makes_double/declares_dry_class"
require_relative "makes_double/gathers_fakeable_instance_methods"

module Mocktail
  class MakesDouble
    extend T::Sig

    sig { void }
    def initialize
      @declares_dry_class = T.let(DeclaresDryClass.new, DeclaresDryClass)
      @gathers_fakeable_instance_methods = T.let(GathersFakeableInstanceMethods.new, GathersFakeableInstanceMethods)
    end

    sig { params(type: T::Class[Object]).returns(Double) }
    def make(type)
      dry_methods = @gathers_fakeable_instance_methods.gather(type)
      dry_type = @declares_dry_class.declare(type, dry_methods)

      Double.new(
        original_type: type,
        dry_type: dry_type,
        dry_instance: dry_type.new,
        dry_methods: dry_methods
      )
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mocktail-2.0.0 lib/mocktail/sorbet/mocktail/imitates_type/makes_double.rb