Class: Backspin::Matcher

Inherits:
Object
  • Object
show all
Defined in:
lib/backspin/matcher.rb

Overview

Handles matching logic between expected and actual snapshots.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config:, expected:, actual:) ⇒ Matcher

Returns a new instance of Matcher.



8
9
10
11
12
# File 'lib/backspin/matcher.rb', line 8

def initialize(config:, expected:, actual:)
  @config = normalize_config(config)
  @expected = expected
  @actual = actual
end

Instance Attribute Details

#actualObject (readonly)

Returns the value of attribute actual.



6
7
8
# File 'lib/backspin/matcher.rb', line 6

def actual
  @actual
end

#configObject (readonly)

Returns the value of attribute config.



6
7
8
# File 'lib/backspin/matcher.rb', line 6

def config
  @config
end

#expectedObject (readonly)

Returns the value of attribute expected.



6
7
8
# File 'lib/backspin/matcher.rb', line 6

def expected
  @expected
end

Instance Method Details

#failure_reasonString

Returns reason why matching failed.

Returns:

  • (String)

    reason why matching failed



20
21
22
# File 'lib/backspin/matcher.rb', line 20

def failure_reason
  evaluation[:reason]
end

#match?Boolean

Returns true if snapshots match according to configured matcher.

Returns:

  • (Boolean)

    true if snapshots match according to configured matcher



15
16
17
# File 'lib/backspin/matcher.rb', line 15

def match?
  evaluation[:match]
end