Class: OhSnap::Snapshot
- Inherits:
-
Object
- Object
- OhSnap::Snapshot
- Defined in:
- lib/oh_snap/snapshot.rb
Overview
Represents a snapshot
Instance Attribute Summary collapse
-
#actual ⇒ Object
readonly
Returns the value of attribute actual.
-
#expected ⇒ Object
readonly
Returns the value of attribute expected.
-
#matched ⇒ Object
readonly
Returns the value of attribute matched.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(expected = nil, serializer:) ⇒ Snapshot
constructor
A new instance of Snapshot.
- #inspect ⇒ Object
- #touched? ⇒ Boolean
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
#actual ⇒ Object (readonly)
Returns the value of attribute actual.
6 7 8 |
# File 'lib/oh_snap/snapshot.rb', line 6 def actual @actual end |
#expected ⇒ Object (readonly)
Returns the value of attribute expected.
6 7 8 |
# File 'lib/oh_snap/snapshot.rb', line 6 def expected @expected end |
#matched ⇒ Object (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 |
#inspect ⇒ Object
24 25 26 |
# File 'lib/oh_snap/snapshot.rb', line 24 def inspect @expected.inspect end |
#touched? ⇒ Boolean
20 21 22 |
# File 'lib/oh_snap/snapshot.rb', line 20 def touched? defined?(@matched) && !@matched end |