9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/snapshot_ui/test/minitest_helpers.rb', line 9
def take_snapshot(snapshotee)
return unless SnapshotUI.snapshot_taking_enabled?
unless snapshotee.respond_to?(:body)
message =
"#take_snapshot only accepts an argument that responds to a method `#body`. " \
"You provided an argument of type `#{snapshotee.class}` that does not respond to `#body`."
raise ArgumentError.new(message)
end
SnapshotUI.exit_if_not_configured!
increment_take_snapshot_counter_scoped_by_test
SnapshotUI::Snapshot.persist(
snapshotee: snapshotee,
context: {
test_framework: "minitest",
method_name: name,
source_location: build_source_location(caller_locations(1..1).first),
test_case_name: self.class.to_s,
take_snapshot_index: _take_snapshot_counter - 1
}
)
end
|