Sha256: 462d2aa97064f9df6146f38b877f03b153f36e384f24f21d8a91e0a6ded90b0e

Contents?: true

Size: 1 KB

Versions: 4

Compression:

Stored size: 1 KB

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 "simulates_argument_error/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

4 entries across 4 versions & 1 rubygems

Version Path
mocktail-0.0.6 lib/mocktail/simulates_argument_error.rb
mocktail-0.0.5 lib/mocktail/simulates_argument_error.rb
mocktail-0.0.4 lib/mocktail/simulates_argument_error.rb
mocktail-0.0.3 lib/mocktail/simulates_argument_error.rb