Class: RSpec::Cheki::Matchers::MatchSnapshot

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/rspec/cheki/matchers/match_snapshot.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize ⇒ MatchSnapshot

Returns a new instance of MatchSnapshot.



10
11
12
13
# File 'lib/rspec/cheki/matchers/match_snapshot.rb', line 10

def initialize
  @example = RSpec.current_example
  @snapshot = RSpec::Cheki::Manager.create_snapshot(example: example)
end

Instance Attribute Details

#example ⇒ Object (readonly)

Returns the value of attribute example.



5
6
7
# File 'lib/rspec/cheki/matchers/match_snapshot.rb', line 5

def example
  @example
end

#snapshot ⇒ Object (readonly)

Returns the value of attribute snapshot.



5
6
7
# File 'lib/rspec/cheki/matchers/match_snapshot.rb', line 5

def snapshot
  @snapshot
end

Instance Method Details

#description ⇒ Object



19
20
21
# File 'lib/rspec/cheki/matchers/match_snapshot.rb', line 19

def description
  "match stored snapshot"
end

#diffable? ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/rspec/cheki/matchers/match_snapshot.rb', line 28

def diffable?
  true
end

#failure_message ⇒ Object



15
16
17
# File 'lib/rspec/cheki/matchers/match_snapshot.rb', line 15

def failure_message
  "received value does not match stored snapshot #{snapshot.key}"
end

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
26
# File 'lib/rspec/cheki/matchers/match_snapshot.rb', line 23

def matches?(actual)
  snapshot.actual = actual
  snapshot.match?
end