Class: RSpec::Cheki::Snapshot

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key) ⇒ Snapshot

Returns a new instance of Snapshot.

Parameters:

  • key (String) —

    The key



9
10
11
12
13
# File 'lib/rspec/cheki/snapshot.rb', line 9

def initialize key
  @key = key
  @expected_updated = false
  @actual_updated = false
end

Instance Attribute Details

#actual ⇒ Object

Returns the value of attribute actual.



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

def actual
  @actual
end

#expected ⇒ Object

Returns the value of attribute expected.



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

def expected
  @expected
end

#key ⇒ Object (readonly)

Returns the value of attribute key.



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

def key
  @key
end

Instance Method Details

#match? ⇒ boolean

Returns true if the actual value is equal to stored value from snapshot.

Returns:

  • (boolean) —

    true if the actual value is equal to stored value from snapshot



16
17
18
# File 'lib/rspec/cheki/snapshot.rb', line 16

def match?
  actual == expected
end

#needs_update? ⇒ boolean

Returns true if the snapshot changed.

Returns:

  • (boolean) —

    true if the snapshot changed



26
27
28
# File 'lib/rspec/cheki/snapshot.rb', line 26

def needs_update?
  @actual_updated && !match?
end

#new? ⇒ boolean

Returns true if the snapshot is stored.

Returns:

  • (boolean) —

    true if the snapshot is stored



21
22
23
# File 'lib/rspec/cheki/snapshot.rb', line 21

def new?
  !@expected_updated
end