This project is archived and is in readonly mode.

#3102 ✓resolved
Jeffrey Hardy

Correct Regexp extension un/optionalize assertions and fix failures masked by false positives

Reported by Jeffrey Hardy | August 26th, 2009 @ 07:41 PM | in 2.3.4

This patch corrects the Regexp extension un/optionalize test assertions. Previously, assert was being used instead of assert_equal, producing false positives.

-  assert "", Regexp.optionalize("")
+  assert_equal "", Regexp.optionalize("")

The first will always pass since "" evaluates to true. It's clear that the original author intended assert_equal.

Fixing the assertions uncovered a failure which this patch also fixes:

    [./test/core_ext/regexp_ext_test.rb:18:in `test_optionalize'
<""> expected but was

Since the previous return value of /(?:)?/ will still match an empty string, behavior is unchanged (all Action Pack tests continue to pass), but based on the tests, "" was the return value the author intended.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>

People watching this ticket