Module: SnapshotTesting::TestUnit

Defined in:
lib/snapshot_testing/test_unit.rb

Instance Method Summary collapse

Instance Method Details

#assert_snapshot(name = nil, actual) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/snapshot_testing/test_unit.rb', line 18

def assert_snapshot(name = nil, actual)
  if name.nil?
    assert_equal(@__snapshot_recorder__.record(actual), actual)
  else
    assert_equal(@__snapshot_recorder__.record_file(name, actual), actual)
  end
end

#setupObject



5
6
7
8
9
10
11
# File 'lib/snapshot_testing/test_unit.rb', line 5

def setup
  @__snapshot_recorder__ = SnapshotTesting::Recorder.new(
    name: method_name,
    path: method(method_name).source_location.first
  )
  super
end

#teardownObject



13
14
15
16
# File 'lib/snapshot_testing/test_unit.rb', line 13

def teardown
  super
  @__snapshot_recorder__.commit
end