Class: Trailblazer::Test::Assertion::AssertPass::Passed

Inherits:
Object
  • Object
show all
Defined in:
lib/trailblazer/test/assertion/assert_pass.rb

Instance Method Summary collapse

Instance Method Details

#arguments_for_assertion(signal) ⇒ Object

What needs to be compared?



32
33
34
# File 'lib/trailblazer/test/assertion/assert_pass.rb', line 32

def arguments_for_assertion(signal)
  return true, Assertion::SUCCESS_TERMINI.include?(signal.to_h[:semantic])
end

#assertion(expected_outcome, actual_outcome, error_msg, test:) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/trailblazer/test/assertion/assert_pass.rb', line 42

def assertion(expected_outcome, actual_outcome, error_msg, test:, **)
  test.assert_equal(
    expected_outcome,
    actual_outcome,
    error_msg
  )
end

#call(signal, ctx, **options) ⇒ Object

Check if the operation terminates on :success. @semi-public Used in rspec-trailblazer



23
24
25
26
27
28
29
# File 'lib/trailblazer/test/assertion/assert_pass.rb', line 23

def call(signal, ctx, **options)
  expected_outcome, actual_outcome = arguments_for_assertion(signal)
  error_msg = error_message(signal, ctx, **options) # DISCUSS: compute error message before there was an error?

  outcome = assertion(expected_outcome, actual_outcome, error_msg, **options)
  return outcome, error_msg
end

#error_message(signal, ctx, operation:) ⇒ Object



36
37
38
39
40
# File 'lib/trailblazer/test/assertion/assert_pass.rb', line 36

def error_message(signal, ctx, operation:, **)
  colored_errors = Errors.colored_errors_for(ctx)

  %{{#{operation}} failed: #{colored_errors}} # FIXME: only if contract's there!
end