Class: RSpec::Snapshot::Matchers::MatchSnapshot
- Inherits:
-
Object
- Object
- RSpec::Snapshot::Matchers::MatchSnapshot
- Defined in:
- lib/rspec/snapshot/matchers/match_snapshot.rb
Overview
RSpec matcher for snapshot testing
Instance Attribute Summary collapse
-
#actual ⇒ Object
readonly
Returns the value of attribute actual.
-
#expected ⇒ Object
readonly
Returns the value of attribute expected.
Instance Method Summary collapse
- #description ⇒ Object
- #diffable? ⇒ Boolean
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(serializer, file_operator) ⇒ MatchSnapshot
constructor
convert test values to string for writing to snapshot files.
-
#matches?(actual) ⇒ Boolean
(also: #===, #match)
snapshot contents, false otherwise.
Constructor Details
#initialize(serializer, file_operator) ⇒ MatchSnapshot
convert test values to string for writing to snapshot files. snapshot file contents.
14 15 16 17 |
# File 'lib/rspec/snapshot/matchers/match_snapshot.rb', line 14 def initialize(serializer, file_operator) @serializer = serializer @file_operator = file_operator end |
Instance Attribute Details
#actual ⇒ Object (readonly)
Returns the value of attribute actual.
8 9 10 |
# File 'lib/rspec/snapshot/matchers/match_snapshot.rb', line 8 def actual @actual end |
#expected ⇒ Object (readonly)
Returns the value of attribute expected.
8 9 10 |
# File 'lib/rspec/snapshot/matchers/match_snapshot.rb', line 8 def expected @expected end |
Instance Method Details
#description ⇒ Object
50 51 52 |
# File 'lib/rspec/snapshot/matchers/match_snapshot.rb', line 50 def description "to match a snapshot: '#{@file_operator.snapshot_path}'" end |
#diffable? ⇒ Boolean
54 55 56 |
# File 'lib/rspec/snapshot/matchers/match_snapshot.rb', line 54 def diffable? true end |
#failure_message ⇒ Object
58 59 60 |
# File 'lib/rspec/snapshot/matchers/match_snapshot.rb', line 58 def "\nexpected: #{@expected}\n got: #{@actual}\n" end |
#failure_message_when_negated ⇒ Object
62 63 64 |
# File 'lib/rspec/snapshot/matchers/match_snapshot.rb', line 62 def "\nexpected: #{@expected} not to match #{@actual}\n" end |
#matches?(actual) ⇒ Boolean Also known as: ===, match
snapshot contents, false otherwise.
22 23 24 25 26 27 28 29 30 |
# File 'lib/rspec/snapshot/matchers/match_snapshot.rb', line 22 def matches?(actual) @actual = serialize(actual) write_snapshot(@actual) @expected = read_snapshot @actual == @expected end |