jtrupiano / rack-rewrite

A web server agnostic rack middleware for defining and applying rewrite rules. In many cases you can get away with Rack::Rewrite instead of writing Apache mod_rewrite rules.
http://github.com/jtrupiano/rack-rewrite
MIT License
836 stars 80 forks source link

Pattern matching fix #72

Open frasermince opened 9 years ago

frasermince commented 9 years ago

I have discovered that in some odd cases the rewrite will fail to occur despite the fact that it matched the pattern. I then discovered that sometimes Rule#string_matches? returns an Fixnum. This works just fine if the integer is not zero. If the integer is zero it causes Rule#matches to fail and the rewrite will not occur.

I wondered how this was missed in the test suite, and I further discovered that assert(0) comes back as true. I can think of no case where assert(0) succeeding would be a good idea. So I overrided assert in test_helper to have assert(0) fail. This revealed 14 failures which I then fixed. The only thing that might still need changing is the name of the class that inherits from Test::Unit::TestCase.