Permalink
Browse files

remove last-modified

  • Loading branch information...
1 parent d1a554b commit 6d93fe82b39ec37c4001e02b02f9448d7edec47a @joshbuddy committed Sep 10, 2011
Showing with 32 additions and 25 deletions.
  1. +6 −4 Rakefile
  2. +2 −2 lib/http_router.rb
  3. +1 −1 lib/http_router/route.rb
  4. +3 −3 lib/http_router/route_proxy.rb
  5. +20 −15 test/helper.rb
View
@@ -96,10 +96,12 @@ namespace :test do
c = $1
raise "out was nil" if out.nil?
test = out.shift
- c.gsub!(/Last-Modified:.*?[\r\n]*/)
- test.gsub!(/Last-Modified:.*?[\r\n]*/)
- raise "expected #{c.inspect}, received #{test.inspect}" unless c.strip == test.strip
- assertion_count += 1
+ if c['Last-Modified'] == test['Last-Modified']
+ assertion_count += 1
+ else
+ raise "expected #{c.inspect}, received #{test.inspect}" unless c.strip == test.strip
+ assertion_count += 1
+ end
end
end
raise "no assertions were raised in #{example}" if assertion_count.zero?
View
@@ -36,7 +36,7 @@ class HttpRouter
# * :known_methods -- Array of http methods tested for 405s.
def initialize(*args, &blk)
default_app, options = args.first.is_a?(Hash) ? [nil, args.first] : [args.first, args[1]]
- @options = options
+ @options = options
@default_app = default_app || options && options[:default_app] || proc{|env| ::Rack::Response.new("Not Found", 404, {'X-Cascade' => 'pass'}).finish }
@ignore_trailing_slash = options && options.key?(:ignore_trailing_slash) ? options[:ignore_trailing_slash] : true
@redirect_trailing_slash = options && options.key?(:redirect_trailing_slash) ? options[:redirect_trailing_slash] : false
@@ -67,7 +67,7 @@ def add(*args, &app)
path = args.first
route = route_class.new
add_route route
- proxy = RouteProxy.new(self, route)
+ proxy = RouteProxy.new(route)
proxy.path = path if path
proxy.process_opts(opts) if opts
path.to(app) if app
View
@@ -7,7 +7,7 @@ class Route
attr_reader :default_values, :router, :match_partially, :other_hosts, :paths, :request_methods, :path, :schemes
attr_accessor :match_partially, :router, :host,
:user_agent, :name, :ignore_trailing_slash, :significant_variable_names,
- :path_for_generation, :path_validation_regex, :proxy
+ :path_for_generation, :path_validation_regex
def add_default_values(hash)
@default_values ||= {}
@@ -2,9 +2,9 @@ class HttpRouter
class RouteProxy
attr_reader :route
- def initialize(router, route)
- @router, @route = router, route
- @route.proxy = self
+ def initialize(route)
+ @route = route
+ @router = route.router
end
def method_missing(name, *args, &blk)
View
@@ -2,20 +2,20 @@
require 'minitest/autorun'
require 'phocus'
-class MiniTest::Unit::TestCase
+class HttpRouter
+ class RouteProxy
+ def default_destination
+ @route.dest = proc {|env| ::Rack::Response.new("Routing to #{@route.object_id}").finish}
+ self
+ end
+ end
+end
+class MiniTest::Unit::TestCase
def router(opts = nil, &blk)
- @router ||= HttpRouter.new(opts) {
- extend_route do
- def default_destination
- @dest = proc {|env| Rack::Response.new("Routing to #{to_s}").finish}
- proxy
- end
- end
- instance_eval(&blk) if blk
- }
+ @router ||= HttpRouter.new(opts, &blk)
if blk
- @router.routes.each { |route| route.default_destination if route.dest.nil? }
+ @router.routes.each { |route| route.dest ||= proc {|env| Rack::Response.new("Routing to #{route.object_id}").finish} }
@router.routes.size > 1 ? @router.routes : @router.routes.first
else
@router
@@ -46,15 +46,20 @@ def assert_status(status, response)
end
def assert_route(route, request, params = nil, &blk)
- if route.is_a?(String)
+ route = case route
+ when String
router.reset!
- route = router.add(route)
+ router.add(route)
+ when HttpRouter::RouteProxy
+ route.route
+ else
+ route
end
- route.default_destination if route && route.dest.nil?
+ HttpRouter::RouteProxy.new(route).default_destination if route && route.dest.nil?
request = Rack::MockRequest.env_for(request) if request.is_a?(String)
response = @router.call(request)
if route
- dest = "Routing to #{route.route.to_s rescue route.to_s}"
+ dest = "Routing to #{route.object_id}"
assert_equal [dest], response.last.body
if params
raise "Params was nil, but you expected params" if request['router.params'].nil?

0 comments on commit 6d93fe8

Please sign in to comment.