<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -379,6 +379,7 @@ class Merb::BootLoader::LoadClasses &lt; Merb::BootLoader
     # Reload the router to regenerate all routes.
     def reload_router!
       if File.file?(router_file = Merb.dir_for(:router) / Merb.glob_for(:router))
+        Merb::Router.reset!
         reload router_file
       end
     end</diff>
      <filename>lib/merb-core/bootloader.rb</filename>
    </modified>
    <modified>
      <diff>@@ -31,6 +31,11 @@ module Merb
     cattr_accessor :routes, :named_routes
 
     class &lt;&lt; self
+      
+      # Clear all routes.
+      def reset!
+        self.routes, self.named_routes = [], {}
+      end
 
       # Appends the generated routes to the current routes.
       #
@@ -66,6 +71,18 @@ module Merb
         compile
       end
 
+      # Capture any new routes that have been added within the block.
+      #
+      # This utility method lets you track routes that have been added;
+      # it doesn't affect how/which routes are added.
+      #
+      # &amp;block:: A context in which routes are generated.
+      def capture(&amp;block)
+        routes_before, named_route_keys_before = self.routes.dup, self.named_routes.keys
+        yield
+        [self.routes - routes_before, self.named_routes.except(*named_route_keys_before)]
+      end
+
       # ==== Returns
       # String:: A routing lambda statement generated from the routes.
       def compiled_statement</diff>
      <filename>lib/merb-core/dispatch/router.rb</filename>
    </modified>
    <modified>
      <diff>@@ -14,6 +14,10 @@ describe Merb::Router::Route, &quot;initially&quot; do
     @r5 = Merb::Router.routes[4]
   end
 
+  after :each do
+    Merb::Router.reset!
+  end
+
   it &quot;has reader for conditions&quot; do
     @r1.conditions
   end
@@ -47,7 +51,6 @@ describe Merb::Router::Route, &quot;initially&quot; do
   end
 end
 
-
 describe Merb::Router::Route, &quot;#fixatable&quot; do
   predicate_matchers[:allow_fixation] = :allow_fixation?
 
@@ -60,6 +63,10 @@ describe Merb::Router::Route, &quot;#fixatable&quot; do
 
     @route = Merb::Router.routes[4]
   end
+  
+  after :each do
+    Merb::Router.reset!
+  end
 
   it &quot;allows fixation when called with true&quot; do
     @route.fixatable(true)
@@ -94,6 +101,10 @@ describe Merb::Router::Route, &quot;#to_s&quot; do
 
     @route = Merb::Router.routes[4]
   end
+  
+  after :each do
+    Merb::Router.reset!
+  end
 
   it &quot;concatenates route segments&quot; do
     @route.stub!(:segments).and_return([&quot;continents/&quot;, &quot;new&quot;])
@@ -118,6 +129,10 @@ describe Merb::Router::Route, &quot;#register&quot; do
 
     @route = Merb::Router.routes[4]
   end
+  
+  after :each do
+    Merb::Router.reset!
+  end
 
   it &quot;adds route to Merb routes set&quot; do
     Merb::Router.routes = []
@@ -153,7 +168,7 @@ describe Merb::Router::Route, &quot;#symbol_segments&quot; do
   end
 
   after :each do
-    Merb::Router.routes = []
+    Merb::Router.reset!
   end
 
   it &quot;cherrypicks segments that are Symbols&quot; do
@@ -176,7 +191,7 @@ describe Merb::Router::Route, &quot;#segments_from_path&quot; do
   end
 
   after :each do
-    Merb::Router.routes = []
+    Merb::Router.reset!
   end
 
   it &quot;turns path into string and symbol segments&quot; do
@@ -200,7 +215,7 @@ describe Merb::Router::Route, &quot;#name&quot; do
   end
 
   after :each do
-    Merb::Router.routes = []
+    Merb::Router.reset!
   end
 
   it &quot;places the route into named routes collection&quot; do
@@ -212,10 +227,10 @@ describe Merb::Router::Route, &quot;#name&quot; do
   it &quot;only accepts Symbols&quot; do
     lambda { @route.name(&quot;home&quot;) }.should raise_error(ArgumentError)
   end
+  
 end
 
 
-
 describe Merb::Router::Route, &quot;#regexp?&quot; do
   before :each do
     Merb::Router.prepare do |r|
@@ -251,7 +266,7 @@ describe Merb::Router::Route, &quot;#regexp?&quot; do
   end
 
   after :each do
-    Merb::Router.routes = []
+    Merb::Router.reset!
   end
 end
 
@@ -267,6 +282,10 @@ describe Merb::Router::Route, &quot;#generate&quot; do
     @regexp_route   = Merb::Router.named_routes[:regexpy]
     @non_regexp_route = Merb::Router.named_routes[:non_regexpy]
   end
+  
+  after :each do
+    Merb::Router.reset!
+  end
 
   it &quot;does not work for regexp routes&quot; do
     lambda { @regexp_route.generate({ :token =&gt; &quot;apitoken&quot; }) }.should raise_error(RuntimeError, /regexp/)
@@ -304,6 +323,10 @@ describe Merb::Router::Route, &quot;#if_conditions&quot; do
     @non_regexp_route = Merb::Router.named_routes[:non_regexpy]
     @two_symbol_route = Merb::Router.named_routes[:two_symbol_segments]
   end
+  
+  after :each do
+    Merb::Router.reset!
+  end
 
   it &quot;returns array with =~ statements&quot; do
     # just to show you what it looks like
@@ -328,8 +351,6 @@ describe Merb::Router::Route, &quot;#if_conditions&quot; do
   end
 end
 
-
-
 describe Merb::Router::Route, &quot;#if_conditions&quot; do
   before :each do
     Merb::Router.prepare do |r|
@@ -342,6 +363,10 @@ describe Merb::Router::Route, &quot;#if_conditions&quot; do
     @non_regexp_route = Merb::Router.named_routes[:non_regexpy]
     @two_symbol_route = Merb::Router.named_routes[:two_symbol_segments]
   end
+  
+  after :each do
+    Merb::Router.reset!
+  end
 
   it &quot;uses if in compiled statement when argument is false&quot; do
     @regexp_route.compile(false).should =~ /\s*elsif/
@@ -355,3 +380,35 @@ describe Merb::Router::Route, &quot;#if_conditions&quot; do
     @regexp_route.compile.should =~ /\s*elsif/
   end
 end
+
+describe &quot;Merb::Router::Route.capture&quot; do
+  
+  after :each do
+    Merb::Router.reset!
+  end  
+  
+  it &quot;should capture routes that have been added in the block context&quot; do
+    routes, named, route = [], {}, nil
+    Merb::Router.prepare do |r|
+      routes, named = Merb::Router.capture do
+        route = r.match(&quot;/overview&quot;).to(:controller =&gt; &quot;home&quot;, :action =&gt; 'overview')
+      end
+      r.match(&quot;/&quot;).to(:controller =&gt; &quot;home&quot;).name(:home)
+    end
+    routes.should include(route)
+    named.should_not include(route)
+  end
+  
+  it &quot;should capture named routes that have been added in the block context&quot; do
+    routes, named, route = [], {}, nil
+    Merb::Router.prepare do |r|
+      r.match(&quot;/overview&quot;).to(:controller =&gt; &quot;home&quot;, :action =&gt; 'overview')
+      routes, named = Merb::Router.capture do
+        route = r.match(&quot;/&quot;).to(:controller =&gt; &quot;home&quot;).name(:home)
+      end
+    end
+    routes.should include(route)
+    named[:home].should == route
+  end
+  
+end</diff>
      <filename>spec/private/router/route_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>74d24639f8d7158d4b5ba2457596fbc3dad90c56</id>
    </parent>
  </parents>
  <author>
    <name>Fabien Franzen</name>
    <email>info@atelierfabien.be</email>
  </author>
  <url>http://github.com/wycats/merb-core/commit/e8c05531659c45f918f17b7627886bf3e9a40556</url>
  <id>e8c05531659c45f918f17b7627886bf3e9a40556</id>
  <committed-date>2008-06-09T01:40:33-07:00</committed-date>
  <authored-date>2008-06-09T01:40:33-07:00</authored-date>
  <message>Added Merb::Router.reset! and Merb::Router.capture</message>
  <tree>58d06c4e3d2611057804ffea0fb3562a38d8057b</tree>
  <committer>
    <name>Fabien Franzen</name>
    <email>info@atelierfabien.be</email>
  </committer>
</commit>
