Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Fixing up be_routable #9

wants to merge 1 commit into from

2 participants


Making be_routable matcher a bit more robust (will match through linebreaks).

I had run into this issue where the regex used to match the error message from assert_recognizes failed to match because the portion of the message that is normally of the format "{:controller => :foo, :action => :bar}" sometimes has line breaks in it, causing actual routable paths to fail the check.

This simply enables multiline matching on that regex.

linked issue: #8 (not sure how to actually link to that issue so this pull request shows up in that thread)


Wow, that was fun! But got the rspec-rails-1 build running again and merged your patch with no problem.

As for running rspec-rails-2 build without installing the rspec-dev stack, see


Awesome! Thank you! I'll look into patching rspec-rails-2 in a similar way in the next couple of days.

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
2  lib/spec/rails/matchers/route_to.rb
@@ -101,7 +101,7 @@ def matches?(path)
rescue ::Test::Unit::AssertionFailedError => e
# the second thingy will always be "<{}>" becaues of the way we called assert_recognizes({}...) above.
- e.to_s =~ /<(.*)> did not match <\{\}>/ and @actual_place = $1 or raise
+ e.to_s =~ /<(.*)> did not match <\{\}>/m and @actual_place = $1 or raise
4 spec/spec/rails/example/shared_routing_example_group_examples.rb
@@ -114,6 +114,10 @@ class RspecOnRailsSpecsController < ActionController::Base; end
self.stub!( :assert_recognizes ).and_return { raise ::Test::Unit::AssertionFailedError, "<{a}> did not match <{}>" }
{ :get => "/rspec_on_rails_spec/arguably_bad_route" }.should be_routable
+ it "should be_routable even when Test::Unit::AssertionFailedError has line breaks in the message" do
+ self.stub!( :assert_recognizes ).and_return { raise ::Test::Unit::AssertionFailedError, "<{a => b,\nc => d}> did not match <{}>" }
+ { :get => "/rspec_on_rails_spec/arguably_bad_route" }.should be_routable
+ end
it "should re-raise on unusual Test::Unit::AssertionFailedError" do
self.stub!( :assert_recognizes ).and_return { raise ::Test::Unit::AssertionFailedError, "some other message" }
expect { { :get => "/rspec_on_rails_spec/weird_case_route/" }.should be_routable }.
Something went wrong with that request. Please try again.