You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So we came across an issue where we have two defwhen, and both their regex matches on with the feature we are writing.
Reproduce
Specifically we have something like this:
Example text
selection 1 is marked as won
Case 1
defwhen ~r/^selection (?<index>\d+) is (marked as )?(?<result_name>pending|won|lost|voided|pushed|cashed out|win-push)$/,
Case 2
defwhen ~r/^selection (?<cname>[^ ]+) is (marked as )?(?<result_name>pending|won|lost|voided|pushed|cashed out|win-push)$/,
The defwhens are written in this exact order, case 1 first then case 2.
So we actually intend it to match the first case, hence \d+, but for some reason the example text matches the second case instead. We can confirm that if we comment out the second clause, Cabbage matches the first case just fine.
For our solution, we have updated our second case clause's regex to be more specific instead, and it works:
^selection (?<cname>\D\w+) is (marked as )?(<result_name>pending|won|lost|voided|pushed|cashed out|win-push)$
Question
But we're just wondering, when there are two cases that can both match a feature, which one would Cabbage pick? Is the current behaviour expected, and is it documented somewhere? I would've thought the order of defwhen matters, but it looks like it isn't?
To add, we're not entirely sure if this is always 100% reproducible, because our tests are usually green too, so it could be intermittent?
The text was updated successfully, but these errors were encountered:
So we came across an issue where we have two
defwhen
, and both their regex matches on with the feature we are writing.Reproduce
Specifically we have something like this:
Example text
selection 1 is marked as won
Case 1
Case 2
The
defwhens
are written in this exact order, case 1 first then case 2.So we actually intend it to match the first case, hence
\d+
, but for some reason the example text matches the second case instead. We can confirm that if we comment out the second clause, Cabbage matches the first case just fine.For our solution, we have updated our second case clause's regex to be more specific instead, and it works:
Question
But we're just wondering, when there are two cases that can both match a feature, which one would Cabbage pick? Is the current behaviour expected, and is it documented somewhere? I would've thought the order of
defwhen
matters, but it looks like it isn't?To add, we're not entirely sure if this is always 100% reproducible, because our tests are usually green too, so it could be intermittent?
The text was updated successfully, but these errors were encountered: