Module: Trailblazer::Test::Assertions

Defined in:
lib/trailblazer/test/assertions.rb

Class Method Summary collapse

Class Method Details

.assert_exposes(asserted, tuples, reader: nil) ⇒ Object

Test if all ‘tuples` values on `asserted` match the expected values. TODO: test err msgs!

Parameters:

  • asserted

    Object Object that exposes attributes to test

  • tuples

    Hash Key/value attribute pairs to test

  • options

    Hash Default :reader is ‘asserted.name`,



25
26
27
28
29
30
31
32
# File 'lib/trailblazer/test/assertions.rb', line 25

def assert_exposes(asserted, tuples, reader: nil)
  tuples.each do |k, v|
    actual          = Test.actual(asserted, reader, k)
    expected, is_eq = Test.expected(asserted, v, actual)

    is_eq ? assert_equal(expected, actual, "Property [#{k}] mismatch") : assert(expected, "Actual: #{actual.inspect}.")
  end
end