Sha256: d27b9eed85cdfa5fc3204c88943fa176ebc0264d20d6d77585b2d8ea2b396678

Contents?: true

Size: 1008 Bytes

Versions: 9

Compression:

Stored size: 1008 Bytes

Contents

require_relative "simulates_argument_error/transforms_params"
require_relative "simulates_argument_error/reconciles_args_with_params"
require_relative "simulates_argument_error/recreates_message"
require_relative "share/cleans_backtrace"
require_relative "share/stringifies_call"

module Mocktail
  class SimulatesArgumentError
    def initialize
      @transforms_params = TransformsParams.new
      @reconciles_args_with_params = ReconcilesArgsWithParams.new
      @recreates_message = RecreatesMessage.new
      @cleans_backtrace = CleansBacktrace.new
      @stringifies_call = StringifiesCall.new
    end

    def simulate(dry_call)
      signature = @transforms_params.transform(dry_call)

      unless @reconciles_args_with_params.reconcile(signature)
        @cleans_backtrace.clean(
          ArgumentError.new([
            @recreates_message.recreate(signature),
            "[Mocktail call: `#{@stringifies_call.stringify(dry_call)}']"
          ].join(" "))
        )
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
mocktail-1.2.3 lib/mocktail/simulates_argument_error.rb
mocktail-1.2.2 lib/mocktail/simulates_argument_error.rb
mocktail-1.2.1 lib/mocktail/simulates_argument_error.rb
mocktail-1.2.0 lib/mocktail/simulates_argument_error.rb
mocktail-1.1.3 lib/mocktail/simulates_argument_error.rb
mocktail-1.1.2 lib/mocktail/simulates_argument_error.rb
mocktail-1.1.1 lib/mocktail/simulates_argument_error.rb
mocktail-1.1.0 lib/mocktail/simulates_argument_error.rb
mocktail-1.0.0 lib/mocktail/simulates_argument_error.rb