Module: Insta::SnapshotMismatchHandler
- Defined in:
- lib/insta/snapshot_mismatch_handler.rb,
sig/insta/snapshot_mismatch_handler.rbs
Class Method Summary collapse
-
.failure_message(expected, content, label, path, caller_line: nil) ⇒ String
: (String, String, String, Pathname, ?caller_line: String?) -> String.
-
.handle(snapshot_file, path, content, metadata, expected, caller_line: nil) ⇒ Symbol
Returns :updated, :force_passed, or :failed : (SnapshotFile, Pathname, String, Snapshot::snapshot_metadata, String, ?caller_line: String?) -> Symbol.
Class Method Details
.failure_message(expected, content, label, path, caller_line: nil) ⇒ String
: (String, String, String, Pathname, ?caller_line: String?) -> String
27 28 29 30 31 32 |
# File 'lib/insta/snapshot_mismatch_handler.rb', line 27 def self.(expected, content, label, path, caller_line: nil) Diff.( expected, content, label, path.to_s, caller_line, file_extension: File.extname(path.to_s).delete_prefix(".") ) end |
.handle(snapshot_file, path, content, metadata, expected, caller_line: nil) ⇒ Symbol
Returns :updated, :force_passed, or :failed : (SnapshotFile, Pathname, String, Snapshot::snapshot_metadata, String, ?caller_line: String?) -> Symbol
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/insta/snapshot_mismatch_handler.rb', line 7 def self.handle(snapshot_file, path, content, , expected, caller_line: nil) coordinator = UpdateCoordinator.new(Insta.configuration.resolved_update_mode) decision = coordinator.resolve(expected, content) case decision when :update snapshot_file.write(path, content, ) :updated when :pending pending_path = snapshot_file.pending_path(path) snapshot_file.write(pending_path, content, ) PendingLocations.add(pending_path.to_s, caller_line) if caller_line ENV["INSTA_FORCE_PASS"] ? :force_passed : :failed else :failed end end |