Method: Tap::Test::TapTest#assert_audit_equal
- Defined in:
- lib/tap/test/tap_test.rb
#assert_audit_equal(expected, audit, msg = nil, &block) ⇒ Object
Asserts that an audit trail matches the expected trail. By default the expected trail should be composed of [key, value] arrays representing each audit, but a block may be provided to collect other attributes.
Simple assertion:
a = Audit.new(:a, 'a')
b = Audit.new(:b, 'b', a)
e = [[:a, 'a'], [:b, 'b']]
assert_audit_equal(e, b)
Assertion with merge:
a = Audit.new(:a, 'a')
b = Audit.new(:b, 'b', a)
c = Audit.new(:c, 'c')
d = Audit.new(:d, 'd', c)
e = Audit.new(:e, 'e')
f = Audit.new(:f, 'f', [b,d])
eb = [[:a, "a"], [:b, "b"]]
ed = [[:c, "c"], [:d, "d"]]
e = [[eb, ed], [:e, "e"], [:f, "f"]]
assert_audit_equal(e, c)
66 67 68 69 70 |
# File 'lib/tap/test/tap_test.rb', line 66 def assert_audit_equal(expected, audit, msg=nil, &block) block = lambda {|audit| [audit.key, audit.value] } unless block actual = audit.trail(&block) assert_equal(expected, actual, msg) end |