Top Level Namespace

Included Modules

Extended Modules

Defined in:

Method Summary

Method Detail

def assert_diff(before : A, after : B, file = __FILE__, line = __LINE__) forall A, B #

The same as .eq_diff, but this can be used independently.

assert_diff(before, after)

[View source]
def assert_diff_full(before : A, after : B, file = __FILE__, line = __LINE__) forall A, B #

The same as .eq_diff_full, but this can be used independently.

assert_diff_full(before, after)

[View source]
def eq_diff(value) #

The same as .eq, but print readable diff report if actual not equals value (!=).

x = {a: 1, b: 2, c: 0}
y = {a: 1, b: 2, c: 3}

x.should eq_diff y

# =>
# Expected: {a: 1, b: 2, c: 3}
#      got: {a: 1, b: 2, c: 0}
#     diff:   {
#             ...
#         -   c: 3,
#         +   c: 0,
#           }

[View source]
def eq_diff_full(value) #

The same as .eq_diff, but this print full diff report.

x = {a: 1, b: 2, c: 0}
y = {a: 1, b: 2, c: 3}

x.should eq_diff_full y

# =>
# Expected: {a: 1, b: 2, c: 3}
#      got: {a: 1, b: 2, c: 0}
#     diff:   {
#             a: 1,
#             b: 2,
#         -   c: 3,
#         +   c: 0,
#           }

[View source]
def print_diff(before, after, io : IO = STDOUT) #

Print diff to io.

Consecutive no-changed are ommited like "...". Use .assert_diff_full if you need full-report.

a = Rectangle.new(Point.new(0, 0), 4, 3)
b = Rectangle.new(Point.new(0, 1), 4, 7)
print_diff(a, b)
# =>
#   {
# -   height: 3,
# +   height: 7,
#     origin: {
#       ...
# -     y: 0,
# +     y: 1,
#     },
#     ...
#   }

[View source]
def print_diff_full(before, after, io : IO = STDOUT) #

Print full diff to io.

a = Rectangle.new(Point.new(0, 0), 4, 3)
b = Rectangle.new(Point.new(0, 1), 4, 7)
print_diff_full(a, b)
# =>
# {
# -   height: 3,
# +   height: 7,
#     origin: {
#       x: 0,
# -     y: 0,
# +     y: 1,
#     },
#     width: 4,
# }

[View source]