Module: Trailblazer::Test::Deprecation::Operation::Assertions

Includes:
Operation::Assertions
Defined in:
lib/trailblazer/test/deprecation/operation/assertions.rb

Instance Method Summary collapse

Methods included from Operation::Assertions

#_assert_call, #assert_fail, #assert_fail_with_model, #assert_pass, #assert_pass_with_model, #merge_for

Instance Method Details

#_call_operation(operation_class, *args) ⇒ Object

compatibility call for TRB 2.0



32
33
34
# File 'lib/trailblazer/test/deprecation/operation/assertions.rb', line 32

def _call_operation(operation_class, *args)
  operation_class.(args[0][0], args[0][1])
end

#_default_options(options: default_options) ⇒ Object



27
28
29
# File 'lib/trailblazer/test/deprecation/operation/assertions.rb', line 27

def _default_options(options: default_options)
  options
end

#_model(result) ⇒ Object



36
37
38
# File 'lib/trailblazer/test/deprecation/operation/assertions.rb', line 36

def _model(result)
  result["model"]
end

#ctx(new_params, *options) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/trailblazer/test/deprecation/operation/assertions.rb', line 14

def ctx(new_params, *options)
  # need *options to allow user to do something like:
  # ctx({yeah: 'nah'}, "current_user" => Object, some: 'other' )

  # this is not greate but seems necessary using *options
  new_options = options.first || {}
  deep_merge = new_options[:deep_merge].nil? ? true : deep_merge
  new_options.delete(:deep_merge)

  ctx = merge_for(_default_options, options.first || {}, deep_merge)
  [merge_for(params[0], new_params, deep_merge), ctx]
end

#params(default_params: self.default_params, deep_merge: true, **new_params) ⇒ Object



10
11
12
# File 'lib/trailblazer/test/deprecation/operation/assertions.rb', line 10

def params(default_params: self.default_params, deep_merge: true, **new_params)
  [merge_for(default_params, new_params, deep_merge), {}]
end