Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #473 from jwulff/add_description_to_route_to_matcher

Add description method to route_to matcher
  • Loading branch information...
commit d5d3dfbb3f0e1bfe8961805578e8480e087f61f5 2 parents 7fa15c4 + cd57e56
@dchelimsky dchelimsky authored
View
5 lib/rspec/rails/matchers/routing_matchers.rb
@@ -15,9 +15,14 @@ def initialize(scope, *expected)
@expected_options.merge!(:controller => controller, :action => action)
end
end
+
+ def description
+ "route #{@verb_to_path_map} to #{@expected_options}"
+ end
# @api private
def matches?(verb_to_path_map)
+ @verb_to_path_map = verb_to_path_map
match_unless_raises ActiveSupport::TestCase::Assertion do
path, query = *verb_to_path_map.values.first.split('?')
@scope.assert_recognizes(
View
6 spec/rspec/rails/matchers/route_to_spec.rb
@@ -4,6 +4,12 @@
include RSpec::Rails::Matchers::RoutingMatchers
include RSpec::Rails::Matchers::RoutingMatchers::RouteHelpers
+ it "provides a description" do
+ matcher = route_to 'these' => 'options'
+ matcher.instance_variable_set(:@verb_to_path_map, { :get => 'path' })
+ matcher.description.should == "route {:get=>\"path\"} to {\"these\"=>\"options\"}"
+ end
+
it "delegates to assert_recognizes" do
self.should_receive(:assert_recognizes).with({ "these" => "options" }, { :method=> :get, :path=>"path" }, {})
{:get => "path"}.should route_to("these" => "options")
Please sign in to comment.
Something went wrong with that request. Please try again.