<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -16,7 +16,11 @@ Monarch.module(&quot;Screw.Interface&quot;, {
   },
 
   get_location: function() {
-    return window.location.toString();
+    return window.location;
+  },
+
+  base_location: function() {
+    return this.get_location().href.split('?')[0];
   },
 
   examples_to_run: function() {</diff>
      <filename>client/lib/screw/interface.js</filename>
    </modified>
    <modified>
      <diff>@@ -60,7 +60,7 @@ Monarch.constructor(&quot;Screw.Interface.Description&quot;, Monarch.View.Template, {
     },
 
     focus: function() {
-      throw new Error(&quot;Not yet implemented&quot;);
+      Screw.Interface.set_location(Screw.Interface.base_location() + &quot;?&quot; + JSON.stringify([this.description.path()]));
     }
   }
 });</diff>
      <filename>client/lib/screw/interface/description.js</filename>
    </modified>
    <modified>
      <diff>@@ -33,7 +33,7 @@ Monarch.constructor(&quot;Screw.Interface.Example&quot;, Monarch.View.Template, {
     },
 
     focus: function() {
-      throw new Error(&quot;Not implemented yet&quot;);
+      Screw.Interface.set_location(Screw.Interface.base_location() + &quot;?&quot; + JSON.stringify([this.example.path()]));
     }
   }
 });</diff>
      <filename>client/lib/screw/interface/example.js</filename>
    </modified>
    <modified>
      <diff>@@ -11,12 +11,9 @@ Monarch.constructor(&quot;Screw.Interface.ProgressBar&quot;, Monarch.View.Template, {
   view_properties: {
     initialize: function() {
       var self = this;
-      this.total_examples = 0;
-      Screw.each(this.examples_to_run, function() {
-        self.total_examples += this.total_examples();
-        this.on_example_completed(function(example) {
-          self.update_progress(example);
-        });
+      this.total_examples = this.root.total_examples();
+      this.root.on_example_completed(function(example) {
+        self.update_progress(example);
       });
 
 </diff>
      <filename>client/lib/screw/interface/progress_bar.js</filename>
    </modified>
    <modified>
      <diff>@@ -3,6 +3,7 @@
 Monarch.constructor(&quot;Screw.Interface.Runner&quot;, Monarch.View.Template, {
   constructor_properties: {
     run_specs_on_page_load: function() {
+      var self = this;
       jQuery(function() {
         var root_description = Screw.root_description();
         var completed_example_count = 0;
@@ -18,16 +19,26 @@ Monarch.constructor(&quot;Screw.Interface.Runner&quot;, Monarch.View.Template, {
         var queue = new Monarch.Queue();
         var runner;
         queue.add(function() {
-          runner = Screw.Interface.Runner.to_view({root: Screw.root_description(), show: jQuery.cookie(&quot;__screw_unit__show&quot;) || &quot;all&quot;});
+          var show = jQuery.cookie(&quot;__screw_unit__show&quot;) || &quot;all&quot;;
+          runner = Screw.Interface.Runner.to_view({root: Screw.root_description(), show: show});
         });
         queue.add(function() {
           Screw.$('body').html(runner);
         });
         queue.add(function() {
-          runner.run();
+          runner.run(self.run_paths());
         })
         queue.start();
       });
+    },
+
+    run_paths: function() {
+      var after_hash = Screw.Interface.get_location().href.split(&quot;?&quot;)[1];
+      if (after_hash) {
+        return JSON.parse(after_hash);
+      } else {
+        return null;
+      }
     }
   },
 
@@ -51,7 +62,7 @@ Monarch.constructor(&quot;Screw.Interface.Runner&quot;, Monarch.View.Template, {
               });
             });
             td(function() {
-              subview('progress_bar', Screw.Interface.ProgressBar, {examples_to_run: Screw.Interface.examples_to_run()});
+              subview('progress_bar', Screw.Interface.ProgressBar, {root: initial_attributes.root});
             });
           })
         })
@@ -72,37 +83,55 @@ Monarch.constructor(&quot;Screw.Interface.Runner&quot;, Monarch.View.Template, {
     },
 
     show_failed: function() {
-      jQuery.cookie(&quot;__screw_unit__show&quot;, &quot;failed&quot;);
+      jQuery.cookie(&quot;__screw_unit__show&quot;, &quot;failed&quot;, {path: &quot;/&quot;});
       this.addClass('show_failed');
       this.removeClass('show_all');
     },
 
     show_all: function() {
-      jQuery.cookie(&quot;__screw_unit__show&quot;, &quot;all&quot;);
+      jQuery.cookie(&quot;__screw_unit__show&quot;, &quot;all&quot;, {path: &quot;/&quot;});
       this.addClass('show_all');
       this.removeClass('show_failed');
     },
 
     rerun_failed: function() {
-      throw new Error(&quot;not implemented&quot;);
+      var failing_paths = Monarch.Util.map(this.root.failed_examples(), function(example) { return example.path() });
+
+      
+      Screw.Interface.set_location(Screw.Interface.base_location() + '?' + JSON.stringify(failing_paths));
     },
 
     rerun_all: function() {
-      throw new Error(&quot;not implemented&quot;);
+      Screw.Interface.set_location(Screw.Interface.base_location());
     },
 
-    run: function() {
+    run: function(run_paths) {
       var self = this;
+      var objects_to_run = [];
+      if (run_paths) {
+        Monarch.Util.each(run_paths, function(path) {
+          var runnable = self.root.runnable_at_path(path);
+          if (runnable) {
+            objects_to_run.push(runnable);
+          } else {
+            throw new Error(&quot;No runnable at path &quot; + path);
+          }
+        });
+      } else {
+        objects_to_run.push(self.root);
+      }
+
       this.completed_example_count = 0;
       this.total_examples = Screw.root_description().total_examples();
 
       var queue = new Monarch.Queue();
+      this.root.on_example_completed(function() { self.update() } );
 
-      Screw.root_description().on_example_completed(function() { self.update() } );
-      Monarch.Util.each(Screw.Interface.examples_to_run(), function(example) {
+
+      Monarch.Util.each(objects_to_run, function(runnable) {
         queue.add(function() {
-          example.run();
-        })
+          runnable.run();
+        });
       });
 
       queue.start();</diff>
      <filename>client/lib/screw/interface/runner.js</filename>
    </modified>
    <modified>
      <diff>@@ -8,8 +8,6 @@ Monarch.module(&quot;Screw.Require&quot;, {
   use_cache_buster: true,
 
   require: function(javascript_path, onload) {
-    console.debug(javascript_path);
-
     if (Screw.Require.required_paths[javascript_path]) return;
     var full_path = javascript_path + &quot;.js&quot;;
 </diff>
      <filename>client/lib/screw/require.js</filename>
    </modified>
    <modified>
      <diff>@@ -167,7 +167,6 @@ Screw.Unit(function(c) { with(c) {
 
         it(&quot;returns the a message including the example's name and the error message&quot;, function() {
           example.run();
-          console.debug(example.failure_message);
           expect(example.failure_message).to(match, &quot;sad times&quot;);
         });
       });</diff>
      <filename>client/spec/example_spec.js</filename>
    </modified>
    <modified>
      <diff>@@ -7,6 +7,19 @@ Screw.Unit(function(c) { with(c) {
       parent_description.add_description(description);
     });
 
+    describe(&quot;#focus&quot;, function() {
+      it(&quot;sets window.location to match the path of the view's Description&quot;, function() {
+        view = Screw.Interface.Description.to_view({description: description, build_immediately: true});
+        mock(Screw.Interface, 'get_location', function() {
+          return { href: &quot;http://localhost:8080/specs?[[0]]&quot;};
+        });
+
+        mock(Screw.Interface, 'set_location');
+        view.focus();
+        expect(Screw.Interface.set_location).to(have_been_called, with_args(&quot;http://localhost:8080/specs?&quot; + JSON.stringify([description.path()])));
+      });
+    });
+
     describe(&quot;#content&quot;, function() {
       context(&quot;when the view is instantiated without the build_immediately option&quot;, function() {
         var example_1, example_2, set_timeout_callback;</diff>
      <filename>client/spec/interface/description_spec.js</filename>
    </modified>
    <modified>
      <diff>@@ -18,6 +18,18 @@ Screw.Unit(function(c) { with(c) {
       });
     });
 
+    describe(&quot;#focus&quot;, function() {
+      it(&quot;sets window.location to match the path of the view's Example&quot;, function() {
+        mock(Screw.Interface, 'get_location', function() {
+          return { href: &quot;http://localhost:8080/specs?[[0]]&quot;};
+        });
+
+        mock(Screw.Interface, 'set_location');
+        view.focus();
+        expect(Screw.Interface.set_location).to(have_been_called, with_args(&quot;http://localhost:8080/specs?&quot; + JSON.stringify([example.path()])));
+      });
+    });
+
     describe(&quot;when span.name is clicked&quot;, function() {
       it(&quot;calls #focus on the view&quot;, function() {
         mock(view, 'focus');</diff>
      <filename>client/spec/interface/example_spec.js</filename>
    </modified>
    <modified>
      <diff>@@ -23,10 +23,14 @@ Screw.Unit(function(c) { with(c) {
       description_2.add_example(example_3);
       description_2.add_example(example_4);
 
-      view = Screw.Interface.ProgressBar.to_view({examples_to_run: [description_1, description_2]});
+      root = new Screw.Description('root');
+      root.add_description(description_1);
+      root.add_description(description_2);
+
+      view = Screw.Interface.ProgressBar.to_view({root: root});
     });
 
-    describe(&quot;when an example within one of the associated examples to run is completed&quot;, function() {
+    describe(&quot;when an example within the given root is completed&quot;, function() {
       it(&quot;updates the width of the progress bar to the proportion of completed examples and updates the 'n of m completed' text&quot;, function() {
         expect(view.find('div#screw_unit_progress').css('width')).to(equal, '0%');
         expect(view.html()).to(match, &quot;0 of 4&quot;);
@@ -39,7 +43,7 @@ Screw.Unit(function(c) { with(c) {
       });
     });
 
-    describe(&quot;when an example within the associated runnable fails&quot;, function() {
+    describe(&quot;when an example within the given root fails&quot;, function() {
       before(function() {
         should_fail = true;
       });</diff>
      <filename>client/spec/interface/progress_bar_spec.js</filename>
    </modified>
    <modified>
      <diff>@@ -1,31 +1,82 @@
 Screw.Unit(function(c) { with(c) {
   describe(&quot;Screw.Interface.Runner&quot;, function() {
-    var root, child_description_1, child_description_2, view, show;
+    var root, child_description_1, child_description_1_example, child_description_2, view, show;
 
     before(function() {
+      Screw.Monarch.Queue.synchronous = true;
+
       root = new Screw.Description(&quot;all specs&quot;);
       child_description_1 = new Screw.Description(&quot;child description 1&quot;);
       child_description_2 = new Screw.Description(&quot;child description 2&quot;);
+      child_description_1_example = new Screw.Example(&quot;child description 1 example&quot;, function() {  });
+      child_description_1.add_example(child_description_1_example);
+
       root.add_description(child_description_1);
       root.add_description(child_description_2);
+
       view = Screw.Interface.Runner.to_view({root: root, build_immediately: true, show: show});
       mock(Screw.jQuery, 'cookie');
       mock(Screw.jQuery, 'ajax');
     });
 
-    context(&quot;when passed the show: 'all' option&quot;, function() {
-      it(&quot;renders itself with the 'show_all' class and not the 'show_failed' class&quot;, function() {
-        view = Screw.Interface.Runner.to_view({root: root, build_immediately: true, show: 'all'});
-        expect(view.hasClass(&quot;show_all&quot;)).to(be_true);
-        expect(view.hasClass(&quot;show_failed&quot;)).to(be_false);
+    init(function() {
+      show = 'all'
+    });
+
+
+    describe(&quot;.run_paths&quot;, function() {
+      it(&quot;returns the string following # parsed as JSON&quot;, function() {
+        mock(Screw.Interface, 'get_location', function() {
+          return {
+            href: &quot;http://localhost:8080/specs?[[1], [2,0,0]]&quot;
+          }
+        });
+        expect(Screw.Interface.Runner.run_paths()).to(equal, [[1], [2,0,0]]);
       });
     });
 
-    context(&quot;when passed the show: 'failed' option'&quot;, function() {
-      it(&quot;renders itself with the 'show_failed' class and not the 'show_all' class&quot;, function() {
-        view = Screw.Interface.Runner.to_view({root: root, build_immediately: true, show: 'failed'});
-        expect(view.hasClass(&quot;show_failed&quot;)).to(be_true);
-        expect(view.hasClass(&quot;show_all&quot;)).to(be_false);
+    describe(&quot;.to_view&quot;, function() {
+      context(&quot;when passed the show: 'all' option&quot;, function() {
+        it(&quot;renders itself with the 'show_all' class and not the 'show_failed' class&quot;, function() {
+          expect(view.hasClass(&quot;show_all&quot;)).to(be_true);
+          expect(view.hasClass(&quot;show_failed&quot;)).to(be_false);
+        });
+      });
+
+      context(&quot;when passed the show: 'failed' option'&quot;, function() {
+        init(function() {
+          show = 'failed';
+        });
+
+        it(&quot;renders itself with the 'show_failed' class and not the 'show_all' class&quot;, function() {
+          expect(view.hasClass(&quot;show_failed&quot;)).to(be_true);
+          expect(view.hasClass(&quot;show_all&quot;)).to(be_false);
+        });
+      });
+    });
+
+
+    describe(&quot;#run&quot;, function() {
+      context(&quot;when passed an array of paths as the run_paths: option&quot;, function() {
+        it(&quot;calls run on the examples or descriptions corresponding to the paths&quot;, function() {
+          mock(child_description_1, 'run');
+          mock(child_description_1_example, 'run');
+          mock(child_description_2, 'run');
+
+          view.run([[0, 0], [1]]);
+
+          expect(child_description_1.run).to_not(have_been_called);
+          expect(child_description_1_example.run).to(have_been_called, once);
+          expect(child_description_2.run).to(have_been_called, once);
+        });
+      });
+
+      context(&quot;when passed no run_paths&quot;, function() {
+        it(&quot;calls #run on root&quot;, function() {
+          mock(root, 'run');
+          view.run();
+          expect(root.run).to(have_been_called);
+        });
       });
     });
 
@@ -70,7 +121,7 @@ Screw.Unit(function(c) { with(c) {
 
         it(&quot;stores a cookie to retain the setting across refreshes&quot;, function() {
           view.find(&quot;button#show_failed&quot;).click();
-          expect(Screw.jQuery.cookie).to(have_been_called, with_args(&quot;__screw_unit__show&quot;, &quot;failed&quot;));
+          expect(Screw.jQuery.cookie).to(have_been_called, with_args(&quot;__screw_unit__show&quot;, &quot;failed&quot;, {path: &quot;/&quot;}));
         });
       });
 
@@ -98,7 +149,34 @@ Screw.Unit(function(c) { with(c) {
 
         it(&quot;stores a cookie to retain the setting across refreshes&quot;, function() {
           view.find(&quot;button#show_all&quot;).click();
-          expect(Screw.jQuery.cookie).to(have_been_called, with_args(&quot;__screw_unit__show&quot;, &quot;all&quot;));
+          expect(Screw.jQuery.cookie).to(have_been_called, with_args(&quot;__screw_unit__show&quot;, &quot;all&quot;, {path: &quot;/&quot;}));
+        });
+      });
+
+      describe(&quot;when the Rerun All button is clicked&quot;, function() {
+        it(&quot;sets window.location to the current path, without any path specifier&quot;, function() {
+          mock(Screw.Interface, 'get_location', function() {
+            return { href: &quot;http://localhost:8080/specs?[[0]]&quot;};
+          });
+
+          mock(Screw.Interface, 'set_location');
+          view.find(&quot;button#rerun_all&quot;).click();
+          expect(Screw.Interface.set_location).to(have_been_called, with_args(&quot;http://localhost:8080/specs&quot;));
+        });
+      });
+
+      describe(&quot;when the Rerun Failed button is clicked&quot;, function() {
+        it(&quot;sets window.location to the paths of all currently failing examples&quot;, function() {
+          view.run();
+          mock(Screw.Interface, 'get_location', function() {
+            return { href: &quot;http://localhost:8080/specs?[[0]]&quot;};
+          });
+          mock(Screw.Interface, 'set_location');
+
+          view.find(&quot;button#rerun_failed&quot;).click();
+
+          expect(Screw.Interface.set_location).to(have_been_called);
+          expect(Screw.Interface.set_location).to(have_been_called, with_args(&quot;http://localhost:8080/specs?&quot; + JSON.stringify([failing_example_1.path(), failing_example_2.path()])));
         });
       });
     });
@@ -132,11 +210,10 @@ Screw.Unit(function(c) { with(c) {
             mock(Screw.root_description(), &quot;failed_examples&quot;, function() { return []; });
           });
 
-
           it(&quot;adds the .passed class to the root description&quot;, function() {
-              view.update();
-              expect(Screw.root_description().failed_examples).to(have_been_called, once);
-              expect(view.find(&quot;ul.descriptions&quot;).hasClass(&quot;passed&quot;)).to(be_true);
+            view.update();
+            expect(Screw.root_description().failed_examples).to(have_been_called, once);
+            expect(view.find(&quot;ul.descriptions&quot;).hasClass(&quot;passed&quot;)).to(be_true);
           });
         });
       });</diff>
      <filename>client/spec/interface/runner_spec.js</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>858f427814647731da3f87ed1a982423078d7f06</id>
    </parent>
  </parents>
  <author>
    <name>Grockit</name>
    <email>grockit@grok-a.local</email>
  </author>
  <url>http://github.com/nathansobo/screw-unit/commit/a3e5530a276282eda8469fd58398fd5c6c0eea3c</url>
  <id>a3e5530a276282eda8469fd58398fd5c6c0eea3c</id>
  <committed-date>2009-10-13T16:04:11-07:00</committed-date>
  <authored-date>2009-10-13T16:04:11-07:00</authored-date>
  <message>Restored focused spec running capability</message>
  <tree>53ffe7628e16326fc56a57be718363e5217c19ed</tree>
  <committer>
    <name>Grockit</name>
    <email>grockit@grok-a.local</email>
  </committer>
</commit>
