From 3b0a11edeab0da9dae06ba9905aed517d320f0a4 Mon Sep 17 00:00:00 2001
From: John Bintz <john@coswellproductions.com>
Date: Fri, 2 Dec 2011 18:37:14 -0500
Subject: [PATCH] fix spec filtering

---
 lib/jasmine/headless/files_list.rb | 7 ++++++-
 lib/jasmine/headless/runner.rb     | 8 +++++++-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/lib/jasmine/headless/files_list.rb b/lib/jasmine/headless/files_list.rb
index bfafd89..403a4e4 100644
--- a/lib/jasmine/headless/files_list.rb
+++ b/lib/jasmine/headless/files_list.rb
@@ -118,7 +118,12 @@ module Jasmine::Headless
       if is_outside_scope = !spec_filter.empty?
         is_outside_scope = spec_dir.any? do |dir|
           spec_file_searches.any? do |search|
-            !spec_files.any? { |file| File.fnmatch?(File.join(dir, search), file) }
+            !spec_files.any? do |file|
+              target = File.join(dir, search)
+              p target
+
+              File.fnmatch?(target, file) || File.fnmatch?(target.gsub(%{^**/}, '').tap { |o| p o }, file)
+            end
           end
         end
       end
diff --git a/lib/jasmine/headless/runner.rb b/lib/jasmine/headless/runner.rb
index df95b89..1337123 100644
--- a/lib/jasmine/headless/runner.rb
+++ b/lib/jasmine/headless/runner.rb
@@ -78,8 +78,14 @@ module Jasmine
         )
 
         @_targets = template_writer.write!(files_list)
+
         run_targets = @_targets.dup
-        run_targets.pop if (!@options[:full_run] && files_list.filtered?) || files_list.has_spec_outside_scope?
+
+        if run_targets.length == 2
+          if (!@options[:full_run] && files_list.filtered?) || files_list.has_spec_outside_scope?
+            run_targets.pop
+          end
+        end
 
         system jasmine_command(run_targets)