mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Mimic RSpec behavior of match
matcher
The code: expect(/foo/).to match("food") would normally evaluate: "food" === /foo/ which is false. However, in RSpec, this expectation is true.
This commit is contained in:
parent
b433511201
commit
f11b548f4e
1 changed files with 6 additions and 0 deletions
|
@ -16,6 +16,12 @@ module Spectator::Matchers
|
||||||
expected.value === actual.value
|
expected.value === actual.value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Overload that takes a regex so that the operands are flipped.
|
||||||
|
# This mimics RSpec's behavior.
|
||||||
|
private def match?(actual : TestExpression(Regex)) : Bool forall T
|
||||||
|
actual.value === expected.value
|
||||||
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed.
|
# Message displayed when the matcher isn't satisifed.
|
||||||
#
|
#
|
||||||
# This is only called when `#match?` returns false.
|
# This is only called when `#match?` returns false.
|
||||||
|
|
Loading…
Reference in a new issue