Module: SnapshotInspector::Test::TestUnitHelpers
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/snapshot_inspector/test/test_unit_helpers.rb
Instance Method Summary collapse
-
#take_snapshot(snapshotee) ⇒ Object
Takes a snapshot of a given
snapshotee.
Instance Method Details
#take_snapshot(snapshotee) ⇒ Object
Takes a snapshot of a given snapshotee.
A snapshotee can be an instance of ActionDispatch::TestResponse or ActionMailer::MessageDelivery.
take_snapshot needs to be called after the snapshotee object becomes available
for inspection in the lifecycle of the test (e.g. integration or mailer test). You can take one or
more snapshots in a single test case.
Snapshots are taken only when explicitly enabled with a flag --take-snapshots
or when an environment variable TAKE_SNAPSHOTS=1 is set.
E.g. bin/rails test --take-snapshots
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/snapshot_inspector/test/test_unit_helpers.rb', line 21 def take_snapshot(snapshotee) return unless SnapshotInspector.configuration.snapshot_taking_enabled increment_take_snapshot_counter_scoped_by_test SnapshotInspector::Snapshot.persist( snapshotee: snapshotee, context: { test_framework: :test_unit, method_name: method_name, source_location: method(method_name).source_location, test_case_name: self.class.to_s, take_snapshot_index: _take_snapshot_counter - 1 } ) end |