Class: Mocktail::SimulatesArgumentError

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/mocktail/simulates_argument_error.rb,
lib/mocktail/sorbet/mocktail/simulates_argument_error.rb

Instance Method Summary collapse

Constructor Details

#initializeSimulatesArgumentError

Returns a new instance of SimulatesArgumentError.



11
12
13
14
15
16
17
# File 'lib/mocktail/simulates_argument_error.rb', line 11

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

Instance Method Details

#simulate(dry_call) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/mocktail/simulates_argument_error.rb', line 19

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