Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fixing up be_routable #9

Closed
wants to merge 1 commit into from

2 participants

@sdhull

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)

@dchelimsky
Owner

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 https://github.com/rspec/rspec-rails/blob/master/README_DEV.md.

@sdhull

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.
View
2  lib/spec/rails/matchers/route_to.rb
@@ -101,7 +101,7 @@ def matches?(path)
false
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
true
end
end
View
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
end
+ 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.