Class Spec::Rails::Example::RoutingHelpers::RouteFor

  1. lib/spec/rails/example/routing_helpers.rb
Parent: Object

Methods

public class

  1. new

public instance

  1. ==

Public class methods

new (example, options)
[show source]
# File lib/spec/rails/example/routing_helpers.rb, line 9
          def initialize(example, options)
            @example, @options = example, options
          end

Public instance methods

== (expected)
[show source]
# File lib/spec/rails/example/routing_helpers.rb, line 13
          def ==(expected)
            if Hash === expected
              path, querystring = expected[:path].split('?')
              path_string = path
              path = expected.merge(:path => path)
            else
              path, querystring = expected.split('?')
              path_string = path
              path = { :path => path, :method => :get }
            end
            params = querystring.blank? ? {} : Rack::Utils.parse_query(querystring).symbolize_keys!
            begin
              @example.assert_routing(path, @options, {}, params)
              true
            rescue ActionController::RoutingError, ::Test::Unit::AssertionFailedError => e
              raise e.class, "#{e}\nIf you're expecting this failure, we suggest {:#{path[:method]}=>\"#{path[:path]}\"}.should_not be_routable"
            end
          end