Class: OhSnap::Snapshot

Inherits:
Object
  • Object
show all
Defined in:
lib/oh_snap/snapshot.rb

Overview

Represents a snapshot

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(expected = nil, serializer:) ⇒ Snapshot

Returns a new instance of Snapshot.



8
9
10
11
12
# File 'lib/oh_snap/snapshot.rb', line 8

def initialize(expected = nil, serializer:)
  @actual = nil
  @expected = expected
  @serializer = serializer
end

Instance Attribute Details

#actualObject (readonly)

Returns the value of attribute actual.



6
7
8
# File 'lib/oh_snap/snapshot.rb', line 6

def actual
  @actual
end

#expectedObject (readonly)

Returns the value of attribute expected.



6
7
8
# File 'lib/oh_snap/snapshot.rb', line 6

def expected
  @expected
end

#matchedObject (readonly)

Returns the value of attribute matched.



6
7
8
# File 'lib/oh_snap/snapshot.rb', line 6

def matched
  @matched
end

Instance Method Details

#==(other) ⇒ Object



14
15
16
17
18
# File 'lib/oh_snap/snapshot.rb', line 14

def ==(other)
  @actual = serialize(other)
  @expected ||= serialize(other)
  @matched = @expected == @actual
end

#inspectObject



24
25
26
# File 'lib/oh_snap/snapshot.rb', line 24

def inspect
  @expected.inspect
end

#touched?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/oh_snap/snapshot.rb', line 20

def touched?
  defined?(@matched) && !@matched
end