guard-rspec 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,12 +1,10 @@
1
- Guard::RSpec
1
+ Guard::RSpec ![travis-ci](http://travis-ci.org/guard/guard-rspec.png)
2
2
  =============
3
3
 
4
- ![travis-ci](http://travis-ci.org/guard/guard-rspec.png)
5
-
6
4
  RSpec guard allows to automatically & intelligently launch specs when files are modified.
7
5
 
8
6
  * Compatible with RSpec 1.x & RSpec 2.x (>= 2.4 needed for the notification feature)
9
- * Tested on Ruby 1.8.6, 1.8.7, 1.9.2, JRuby & Rubinius.
7
+ * Tested on Ruby 1.8.7, 1.9.2, JRuby & Rubinius.
10
8
 
11
9
  Install
12
10
  -------
@@ -66,7 +64,7 @@ Please read [Guard doc](https://github.com/guard/guard#readme) for more informat
66
64
  Options
67
65
  -------
68
66
 
69
- By default, Guard::RSpec automatically detect your RSpec version (with the <tt>spec_helper.rb</tt> syntax or with Bundler) but you can force the version with the <tt>:version</tt> option:
67
+ By default, Guard::RSpec automatically detect your RSpec version (with the `spec_helper.rb` syntax or with Bundler) but you can force the version with the `:version` option:
70
68
 
71
69
  ``` ruby
72
70
  guard 'rspec', :version => 2 do
@@ -74,7 +72,7 @@ guard 'rspec', :version => 2 do
74
72
  end
75
73
  ```
76
74
 
77
- You can pass any of the standard RSpec CLI options using the <tt>:cli</tt> option:
75
+ You can pass any of the standard RSpec CLI options using the `:cli` option:
78
76
 
79
77
  ``` ruby
80
78
  guard 'rspec', :cli => "--color --format nested --fail-fast --drb" do
@@ -82,7 +80,7 @@ guard 'rspec', :cli => "--color --format nested --fail-fast --drb" do
82
80
  end
83
81
  ```
84
82
 
85
- Former <tt>:color</tt>, <tt>:drb</tt>, <tt>:fail_fast</tt> and <tt>:formatter</tt> options are thus deprecated and have no effect anymore.
83
+ Former `:color`, `:drb`, `:fail_fast` and `:formatter` options are thus deprecated and have no effect anymore.
86
84
 
87
85
  ### List of available options:
88
86
 
@@ -107,7 +105,7 @@ The best solution is still to update RSpec to the latest version!
107
105
  Formatters
108
106
  ----------
109
107
 
110
- The <tt>:formatter</tt> option has been removed since CLI arguments can be passed through the <tt>:cli</tt> option. If you want to use the former Instafail formatter, you need to use <tt>{rspec-instafail}[http://rubygems.org/gems/rspec-instafail]</tt> gem instead:
108
+ The `:formatter` option has been removed since CLI arguments can be passed through the `:cli` option. If you want to use the former Instafail formatter, you need to use [rspec-instafail](http://rubygems.org/gems/rspec-instafail) gem instead:
111
109
 
112
110
  ``` ruby
113
111
  # in your Gemfile
@@ -119,7 +117,7 @@ guard 'rspec', :cli => '-r rspec/instafail -f RSpec::Instafail' do
119
117
  end
120
118
  ```
121
119
 
122
- Default formatter is the <tt>progress</tt> formatter (same as RSpec default).
120
+ Default formatter is the `progress` formatter (same as RSpec default).
123
121
 
124
122
  Running a subset of all specs
125
123
  -----------
@@ -140,7 +138,7 @@ you make.
140
138
  Testing
141
139
  -------
142
140
 
143
- Please run <tt>rake spec:prepare_fixtures</tt> once before launching specs.
141
+ Please run `rake spec:prepare_fixtures` once before launching specs.
144
142
 
145
143
  Author
146
144
  ------
data/lib/guard/rspec.rb CHANGED
@@ -17,6 +17,7 @@ module Guard
17
17
  @failed_paths = []
18
18
 
19
19
  Runner.set_rspec_version(options)
20
+ Inspector.excluded = options[:exclude]
20
21
  end
21
22
 
22
23
  # Call once when guard starts
@@ -22,8 +22,16 @@ module Formatter
22
22
  end
23
23
  end
24
24
 
25
+ def priority(image)
26
+ { :failed => 2,
27
+ :pending => -1,
28
+ :success => -2
29
+ }[image]
30
+ end
31
+
25
32
  def notify(message, image)
26
- Guard::Notifier.notify(message, :title => "RSpec results", :image => image)
33
+ Guard::Notifier.notify(message, :title => "RSpec results", :image => image,
34
+ :priority => priority(image))
27
35
  end
28
36
 
29
37
  private
@@ -2,18 +2,29 @@ module Guard
2
2
  class RSpec
3
3
  module Inspector
4
4
  class << self
5
+ def excluded
6
+ @excluded || []
7
+ end
8
+
9
+ def excluded=(glob)
10
+ @excluded = Dir[glob.to_s]
11
+ end
5
12
 
6
13
  def clean(paths)
7
14
  paths.uniq!
8
15
  paths.compact!
9
16
  clear_spec_files_list_after do
10
- paths = paths.select { |p| spec_file?(p) || spec_folder?(p) }
17
+ paths = paths.select { |path| should_run_spec_file?(path) }
11
18
  end
12
19
  paths.reject { |p| included_in_other_path?(p, paths) }
13
20
  end
14
21
 
15
22
  private
16
23
 
24
+ def should_run_spec_file?(path)
25
+ (spec_file?(path) || spec_folder?(path)) && !excluded.include?(path)
26
+ end
27
+
17
28
  def spec_file?(path)
18
29
  spec_files.include?(path)
19
30
  end
@@ -1,14 +1,17 @@
1
1
  guard 'rspec', :version => 2 do
2
- watch(%r{^spec/.+_spec\.rb})
3
- watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4
- watch('spec/spec_helper.rb') { "spec" }
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { "spec" }
5
5
 
6
6
  # Rails example
7
- watch('spec/spec_helper.rb') { "spec" }
8
- watch('config/routes.rb') { "spec/routing" }
9
- watch('app/controllers/application_controller.rb') { "spec/controllers" }
10
- watch(%r{^spec/.+_spec\.rb})
11
- watch(%r{^app/(.+)\.rb}) { |m| "spec/#{m[1]}_spec.rb" }
12
- watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
13
- watch(%r{^app/controllers/(.+)_(controller)\.rb}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
7
+ watch(%r{^spec/.+_spec\.rb$})
8
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
9
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
10
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
11
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
12
+ watch('spec/spec_helper.rb') { "spec" }
13
+ watch('config/routes.rb') { "spec/routing" }
14
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
15
+ # Capybara request specs
16
+ watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
14
17
  end
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module RSpecVersion
3
- VERSION = "0.3.1"
3
+ VERSION = "0.4.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: guard-rspec
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.3.1
5
+ version: 0.4.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Thibaud Guillaume-Gentil
@@ -10,8 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-05-04 00:00:00 +02:00
14
- default_executable:
13
+ date: 2011-06-05 00:00:00 Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: guard
@@ -21,7 +20,7 @@ dependencies:
21
20
  requirements:
22
21
  - - ">="
23
22
  - !ruby/object:Gem::Version
24
- version: 0.2.2
23
+ version: 0.4.0
25
24
  type: :runtime
26
25
  version_requirements: *id001
27
26
  - !ruby/object:Gem::Dependency
@@ -43,7 +42,7 @@ dependencies:
43
42
  requirements:
44
43
  - - ~>
45
44
  - !ruby/object:Gem::Version
46
- version: "2.5"
45
+ version: "2.6"
47
46
  type: :development
48
47
  version_requirements: *id003
49
48
  description: Guard::RSpec automatically run your specs (much like autotest).
@@ -65,8 +64,7 @@ files:
65
64
  - lib/guard/rspec/version.rb
66
65
  - lib/guard/rspec.rb
67
66
  - LICENSE
68
- - README.markdown
69
- has_rdoc: true
67
+ - README.md
70
68
  homepage: http://rubygems.org/gems/guard-rspec
71
69
  licenses: []
72
70
 
@@ -90,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
88
  requirements: []
91
89
 
92
90
  rubyforge_project: guard-rspec
93
- rubygems_version: 1.6.2
91
+ rubygems_version: 1.8.1
94
92
  signing_key:
95
93
  specification_version: 3
96
94
  summary: Guard gem for RSpec