Skip to content

Commit

Permalink
fail the spec whenever we write a snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelglass committed Dec 8, 2022
1 parent dc6c2c3 commit 14004e4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/rspec/snapshot/matchers/match_snapshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ def matches?(actual)

@expected = read_snapshot

@actual == @expected
if should_write?
false
else
@actual == @expected
end
end

# === is the method called when matching an argument
Expand Down Expand Up @@ -98,7 +102,11 @@ def diffable?
end

def failure_message
"\nexpected: #{@expected}\n got: #{@actual}\n"
if should_write?
"failing because we wrote a snapshot"
else
"\nexpected: #{@expected}\n got: #{@actual}\n"
end
end

def failure_message_when_negated
Expand Down

0 comments on commit 14004e4

Please sign in to comment.