Sha256: b19975251dc9e2694e83e80af6c9c9ef83e2a4e9a9277c29b0169cc764382fa7

Contents?: true

Size: 890 Bytes

Versions: 15

Compression:

Stored size: 890 Bytes

Contents

module Mocktail
  class HandlesDryNewCall
    def initialize
      @validates_arguments = ValidatesArguments.new
      @logs_call = LogsCall.new
      @fulfills_stubbing = FulfillsStubbing.new
      @imitates_type = ImitatesType.new
    end

    def handle(type, args, kwargs, block)
      @validates_arguments.validate(Call.new(
        original_method: type.instance_method(:initialize),
        args: args,
        kwargs: kwargs,
        block: block
      ))

      new_call = Call.new(
        singleton: true,
        double: type,
        original_type: type,
        dry_type: type,
        method: :new,
        args: args,
        kwargs: kwargs,
        block: block
      )
      @logs_call.log(new_call)
      if @fulfills_stubbing.satisfaction(new_call)
        @fulfills_stubbing.fulfill(new_call)
      else
        @imitates_type.imitate(type)
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
mocktail-1.2.3 lib/mocktail/handles_dry_new_call.rb
mocktail-1.2.2 lib/mocktail/handles_dry_new_call.rb
mocktail-1.2.1 lib/mocktail/handles_dry_new_call.rb
mocktail-1.2.0 lib/mocktail/handles_dry_new_call.rb
mocktail-1.1.3 lib/mocktail/handles_dry_new_call.rb
mocktail-1.1.2 lib/mocktail/handles_dry_new_call.rb
mocktail-1.1.1 lib/mocktail/handles_dry_new_call.rb
mocktail-1.1.0 lib/mocktail/handles_dry_new_call.rb
mocktail-1.0.0 lib/mocktail/handles_dry_new_call.rb
mocktail-0.0.6 lib/mocktail/handles_dry_new_call.rb
mocktail-0.0.5 lib/mocktail/handles_dry_new_call.rb
mocktail-0.0.4 lib/mocktail/handles_dry_new_call.rb
mocktail-0.0.3 lib/mocktail/handles_dry_new_call.rb
mocktail-0.0.2 lib/mocktail/handles_dry_new_call.rb
mocktail-0.0.1 lib/mocktail/handles_dry_new_call.rb