guard-rspec 2.2.0 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/guard/rspec.rb CHANGED
@@ -47,20 +47,36 @@ module Guard
47
47
 
48
48
  def run_on_changes(paths)
49
49
 
50
+ focused = false
50
51
  if @last_failed && @options[:focus_on_failed]
51
52
  path = './tmp/rspec_guard_result'
52
53
  if File.exist?(path)
53
- paths = File.open(path) { |file| file.read.split("\n") }
54
+ single_spec = paths && paths.length == 1 && paths[0].include?("_spec") ? paths[0] : nil
55
+ failed_specs = File.open(path) { |file| file.read.split("\n") }
54
56
  File.delete(path)
55
-
56
- # some sane limit, stuff will explode if all tests fail ... cap at 10
57
- paths = paths[0..10]
57
+
58
+ if single_spec
59
+ failed_specs = failed_specs.select{|p| p.include? single_spec}
60
+ end
61
+
62
+ if failed_specs.any?
63
+ # some sane limit, stuff will explode if all tests fail ... cap at 10
64
+ paths = failed_specs[0..10]
65
+ focused = true
66
+ end
67
+
68
+ # switch focus to the single spec
69
+ if single_spec
70
+ focused = true
71
+ end
58
72
  end
59
- else
73
+ end
74
+
75
+ unless focused
60
76
  paths += failed_paths if @options[:keep_failed]
61
77
  paths = @inspector.clean(paths)
62
78
  end
63
-
79
+
64
80
  if passed = @runner.run(paths)
65
81
  remove_failed(paths)
66
82
 
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module RSpecVersion
3
- VERSION = "2.2.0"
3
+ VERSION = "2.2.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-26 00:00:00.000000000 Z
12
+ date: 2012-11-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: guard