guard-rspec 0.5.5 → 0.5.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,184 +1,185 @@
1
- Guard::RSpec ![travis-ci](http://travis-ci.org/guard/guard-rspec.png)
2
- =============
3
-
4
- RSpec guard allows to automatically & intelligently launch specs when files are modified.
5
-
6
- * Compatible with RSpec 1.x & RSpec 2.x (>= 2.4 needed for the notification feature)
7
- * Tested against Ruby 1.8.7, 1.9.2, REE, JRuby & Rubinius.
8
-
9
- Install
10
- -------
11
-
12
- Please be sure to have [Guard](https://github.com/guard/guard) installed before continue.
13
-
14
- Install the gem:
15
-
16
- $ gem install guard-rspec
17
-
18
- Add it to your Gemfile (inside development group):
19
-
20
- ``` ruby
21
- gem 'guard-rspec'
22
- ```
23
-
24
- Add guard definition to your Guardfile by running this command:
25
-
26
- $ guard init rspec
27
-
28
- Usage
29
- -----
30
-
31
- Please read [Guard usage doc](https://github.com/guard/guard#readme)
32
-
33
- Guardfile
34
- ---------
35
-
36
- RSpec guard can be really adapted to all kind of projects.
37
-
38
- ### Standard RubyGem project
39
-
40
- ``` ruby
41
- guard 'rspec' do
42
- watch(%r{^spec/.+_spec\.rb$})
43
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
44
- watch('spec/spec_helper.rb') { "spec" }
45
- end
46
- ```
47
-
48
- ### Typical Rails app
49
-
50
- ``` ruby
51
- guard 'rspec' do
52
- watch('spec/spec_helper.rb') { "spec" }
53
- watch('config/routes.rb') { "spec/routing" }
54
- watch('app/controllers/application_controller.rb') { "spec/controllers" }
55
- watch(%r{^spec/.+_spec\.rb$})
56
- watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
57
- watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
58
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
59
- 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"] }
60
- end
61
- ```
62
-
63
- Please read [Guard doc](https://github.com/guard/guard#readme) for more information about the Guardfile DSL.
64
-
65
- Options
66
- -------
67
-
68
- 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:
69
-
70
- ``` ruby
71
- guard 'rspec', :version => 2 do
72
- # ...
73
- end
74
- ```
75
-
76
- You can pass any of the standard RSpec CLI options using the `:cli` option:
77
-
78
- ``` ruby
79
- guard 'rspec', :cli => "--color --format nested --fail-fast --drb" do
80
- # ...
81
- end
82
- ```
83
-
84
- By default, Guard::RSpec will only look for spec files within `spec` in your project root. You can configure Guard::RSpec to look in additional paths by using the `:spec_paths` option:
85
-
86
- ``` ruby
87
- guard 'rspec', :spec_paths => ["spec", "vendor/engines/reset/spec"] do
88
- # ...
89
- end
90
- ```
91
- If you have only one path to look, you can configure `:spec_paths` option with a string:
92
-
93
- ``` ruby
94
- guard 'rspec', :spec_paths => "test" do
95
- # ...
96
- end
97
- ```
98
-
99
-
100
- Former `:color`, `:drb`, `:fail_fast` and `:formatter` options are thus deprecated and have no effect anymore.
101
-
102
- ### List of available options:
103
-
104
- ``` ruby
105
- :version => 1 # force use RSpec version 1, default: 2
106
- :cli => "-c -f doc" # pass arbitrary RSpec CLI arguments, default: "-f progress"
107
- :bundler => false # don't use "bundle exec" to run the RSpec command, default: true
108
- :rvm => ['1.8.7', '1.9.2'] # directly run your specs on multiple Rubies, default: nil
109
- :notification => false # display Growl (or Libnotify) notification after the specs are done running, default: true
110
- :all_after_pass => false # run all specs after changed specs pass, default: true
111
- :all_on_start => false # run all the specs at startup, default: true
112
- :keep_failed => false # keep failed specs until they pass, default: true
113
- :run_all => { :cli => "-p" } # override any option when running all specs
114
- :spec_paths => ["spec"] # specify an array of paths that contain spec files
115
- ```
116
-
117
- Notification
118
- ------------
119
-
120
- The notification feature is only available for RSpec < 2, and RSpec >= 2.4 (due to the multiple-formatters feature that was present in RSpec 1, was removed in RSpec 2 and reintroduced in RSpec 2.4). So if you are using a version between 2 and 2.4, you should disable the notification with <tt>:notification => false</tt>. Otherwise, nothing will be displayed in the terminal when your specs will run.
121
-
122
- The best solution is still to update RSpec to the latest version!
123
-
124
- Formatters
125
- ----------
126
-
127
- 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:
128
-
129
- ``` ruby
130
- # in your Gemfile
131
- gem 'rspec-instafail'
132
-
133
- # in your Guardfile
134
- guard 'rspec', :cli => '-r rspec/instafail -f RSpec::Instafail' do
135
- # ...
136
- end
137
- ```
138
-
139
- Default formatter is the `progress` formatter (same as RSpec default).
140
-
141
- Running a subset of all specs
142
- -----------
143
-
144
- The `:all_on_start` and `:all_after_pass` options cause all specs located in the `spec` directory to be run. If there
145
- are some specs you want to skip, you can tag them with RSpec metadata (such as `:slow => true`)
146
- and skip them with the cli `--tag` option (i.e. `--tag ~slow`).
147
-
148
- You can also use option :spec_paths to override paths used when running all specs.
149
- You can use this feature to create multiple groups of guarded specs with distinct paths, and execute each in own process:
150
-
151
- ``` ruby
152
- # in your Guardfile
153
- group 'acceptance-tests' do
154
- guard 'rspec', :spec_paths => ['spec/acceptance'] do
155
- # ...
156
- end
157
- end
158
-
159
- group 'unit-tests' do
160
- guard 'rspec', :spec_paths => ['spec/models', 'spec/controllers', 'spec/routing'] do
161
- # ...
162
- end
163
- end
164
- ```
165
-
166
-
167
- Development
168
- -----------
169
-
170
- * Source hosted at [GitHub](https://github.com/guard/guard-rspec)
171
- * Report issues/Questions/Feature requests on [GitHub Issues](https://github.com/guard/guard-rspec/issues)
172
-
173
- Pull requests are very welcome! Make sure your patches are well tested. Please create a topic branch for every separate change
174
- you make.
175
-
176
- Testing
177
- -------
178
-
179
- Please run `rake spec:prepare_fixtures` once before launching specs.
180
-
181
- Author
182
- ------
183
-
184
- [Thibaud Guillaume-Gentil](https://github.com/thibaudgg)
1
+ Guard::RSpec ![travis-ci](http://travis-ci.org/guard/guard-rspec.png)
2
+ =============
3
+
4
+ RSpec guard allows to automatically & intelligently launch specs when files are modified.
5
+
6
+ * Compatible with RSpec 1.x & RSpec 2.x (>= 2.4 needed for the notification feature)
7
+ * Tested against Ruby 1.8.7, 1.9.2, REE, JRuby & Rubinius.
8
+
9
+ Install
10
+ -------
11
+
12
+ Please be sure to have [Guard](https://github.com/guard/guard) installed before continue.
13
+
14
+ Install the gem:
15
+
16
+ $ gem install guard-rspec
17
+
18
+ Add it to your Gemfile (inside development group):
19
+
20
+ ``` ruby
21
+ gem 'guard-rspec'
22
+ ```
23
+
24
+ Add guard definition to your Guardfile by running this command:
25
+
26
+ $ guard init rspec
27
+
28
+ Usage
29
+ -----
30
+
31
+ Please read [Guard usage doc](https://github.com/guard/guard#readme)
32
+
33
+ Guardfile
34
+ ---------
35
+
36
+ RSpec guard can be really adapted to all kind of projects.
37
+
38
+ ### Standard RubyGem project
39
+
40
+ ``` ruby
41
+ guard 'rspec' do
42
+ watch(%r{^spec/.+_spec\.rb$})
43
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
44
+ watch('spec/spec_helper.rb') { "spec" }
45
+ end
46
+ ```
47
+
48
+ ### Typical Rails app
49
+
50
+ ``` ruby
51
+ guard 'rspec' do
52
+ watch('spec/spec_helper.rb') { "spec" }
53
+ watch('config/routes.rb') { "spec/routing" }
54
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
55
+ watch(%r{^spec/.+_spec\.rb$})
56
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
57
+ watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
58
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
59
+ 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"] }
60
+ end
61
+ ```
62
+
63
+ Please read [Guard doc](https://github.com/guard/guard#readme) for more information about the Guardfile DSL.
64
+
65
+ Options
66
+ -------
67
+
68
+ 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:
69
+
70
+ ``` ruby
71
+ guard 'rspec', :version => 2 do
72
+ # ...
73
+ end
74
+ ```
75
+
76
+ You can pass any of the standard RSpec CLI options using the `:cli` option:
77
+
78
+ ``` ruby
79
+ guard 'rspec', :cli => "--color --format nested --fail-fast --drb" do
80
+ # ...
81
+ end
82
+ ```
83
+
84
+ By default, Guard::RSpec will only look for spec files within `spec` in your project root. You can configure Guard::RSpec to look in additional paths by using the `:spec_paths` option:
85
+
86
+ ``` ruby
87
+ guard 'rspec', :spec_paths => ["spec", "vendor/engines/reset/spec"] do
88
+ # ...
89
+ end
90
+ ```
91
+ If you have only one path to look, you can configure `:spec_paths` option with a string:
92
+
93
+ ``` ruby
94
+ guard 'rspec', :spec_paths => "test" do
95
+ # ...
96
+ end
97
+ ```
98
+
99
+
100
+ Former `:color`, `:drb`, `:fail_fast` and `:formatter` options are thus deprecated and have no effect anymore.
101
+
102
+ ### List of available options:
103
+
104
+ ``` ruby
105
+ :version => 1 # force use RSpec version 1, default: 2
106
+ :cli => "-c -f doc" # pass arbitrary RSpec CLI arguments, default: "-f progress"
107
+ :bundler => false # don't use "bundle exec" to run the RSpec command, default: true
108
+ :binstubs => true # use "bin/rspec" to run the RSpec command (implies :bundler => true), default: false
109
+ :rvm => ['1.8.7', '1.9.2'] # directly run your specs on multiple Rubies, default: nil
110
+ :notification => false # display Growl (or Libnotify) notification after the specs are done running, default: true
111
+ :all_after_pass => false # run all specs after changed specs pass, default: true
112
+ :all_on_start => false # run all the specs at startup, default: true
113
+ :keep_failed => false # keep failed specs until they pass, default: true
114
+ :run_all => { :cli => "-p" } # override any option when running all specs
115
+ :spec_paths => ["spec"] # specify an array of paths that contain spec files
116
+ ```
117
+
118
+ Notification
119
+ ------------
120
+
121
+ The notification feature is only available for RSpec < 2, and RSpec >= 2.4 (due to the multiple-formatters feature that was present in RSpec 1, was removed in RSpec 2 and reintroduced in RSpec 2.4). So if you are using a version between 2 and 2.4, you should disable the notification with <tt>:notification => false</tt>. Otherwise, nothing will be displayed in the terminal when your specs will run.
122
+
123
+ The best solution is still to update RSpec to the latest version!
124
+
125
+ Formatters
126
+ ----------
127
+
128
+ 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:
129
+
130
+ ``` ruby
131
+ # in your Gemfile
132
+ gem 'rspec-instafail'
133
+
134
+ # in your Guardfile
135
+ guard 'rspec', :cli => '-r rspec/instafail -f RSpec::Instafail' do
136
+ # ...
137
+ end
138
+ ```
139
+
140
+ Default formatter is the `progress` formatter (same as RSpec default).
141
+
142
+ Running a subset of all specs
143
+ -----------
144
+
145
+ The `:all_on_start` and `:all_after_pass` options cause all specs located in the `spec` directory to be run. If there
146
+ are some specs you want to skip, you can tag them with RSpec metadata (such as `:slow => true`)
147
+ and skip them with the cli `--tag` option (i.e. `--tag ~slow`).
148
+
149
+ You can also use option :spec_paths to override paths used when running all specs.
150
+ You can use this feature to create multiple groups of guarded specs with distinct paths, and execute each in own process:
151
+
152
+ ``` ruby
153
+ # in your Guardfile
154
+ group 'acceptance-tests' do
155
+ guard 'rspec', :spec_paths => ['spec/acceptance'] do
156
+ # ...
157
+ end
158
+ end
159
+
160
+ group 'unit-tests' do
161
+ guard 'rspec', :spec_paths => ['spec/models', 'spec/controllers', 'spec/routing'] do
162
+ # ...
163
+ end
164
+ end
165
+ ```
166
+
167
+
168
+ Development
169
+ -----------
170
+
171
+ * Source hosted at [GitHub](https://github.com/guard/guard-rspec)
172
+ * Report issues/Questions/Feature requests on [GitHub Issues](https://github.com/guard/guard-rspec/issues)
173
+
174
+ Pull requests are very welcome! Make sure your patches are well tested. Please create a topic branch for every separate change
175
+ you make.
176
+
177
+ Testing
178
+ -------
179
+
180
+ Please run `rake spec:prepare_fixtures` once before launching specs.
181
+
182
+ Author
183
+ ------
184
+
185
+ [Thibaud Guillaume-Gentil](https://github.com/thibaudgg)
@@ -28,11 +28,11 @@ module Guard
28
28
 
29
29
  cmd_parts = []
30
30
  cmd_parts << "rvm #{options[:rvm].join(',')} exec" if options[:rvm].is_a?(Array)
31
- cmd_parts << "bundle exec" if bundler? && options[:bundler] != false
32
- cmd_parts << rspec_exec.downcase
31
+ cmd_parts << "bundle exec" if (bundler? && options[:binstubs] == true && options[:bundler] != false) || (bundler? && options[:bundler] != false)
32
+ cmd_parts << rspec_exec(options)
33
33
  cmd_parts << options[:cli] if options[:cli]
34
34
  cmd_parts << "-f progress" if options[:cli].nil? || !options[:cli].split(' ').any? { |w| %w[-f --format].include?(w) }
35
- cmd_parts << "-r #{File.dirname(__FILE__)}/formatters/notification_#{rspec_exec.downcase}.rb -f Guard::RSpec::Formatter::Notification#{rspec_exec}#{rspec_version == 1 ? ":" : " --out "}/dev/null" if options[:notification] != false
35
+ cmd_parts << "-r #{File.dirname(__FILE__)}/formatters/notification_#{rspec_class.downcase}.rb -f Guard::RSpec::Formatter::Notification#{rspec_class}#{rspec_version == 1 ? ":" : " --out "}/dev/null" if options[:notification] != false
36
36
  cmd_parts << "--failure-exit-code #{failure_exit_code}" if failure_exit_code_supported?(options)
37
37
  cmd_parts << paths.join(' ')
38
38
 
@@ -51,9 +51,11 @@ module Guard
51
51
  return @failure_exit_code_supported if defined?(@failure_exit_code_supported)
52
52
  @failure_exit_code_supported ||= begin
53
53
  cmd_parts = []
54
- cmd_parts << "bundle exec" if bundler? && options[:bundler] != false
55
- cmd_parts << rspec_exec.downcase
54
+ cmd_parts << "bundle exec" if (bundler? && options[:bundler] != false) || (bundler? && options[:binstubs] == true)
55
+ options[:binstubs] = false if options[:binstubs] # failure exit code support is independent of rspec location
56
+ cmd_parts << rspec_exec(options)
56
57
  cmd_parts << "--help"
58
+ $stdout.puts "#{cmd_parts.join(' ')}"
57
59
  `#{cmd_parts.join(' ')}`.include? "--failure-exit-code"
58
60
  end
59
61
  end
@@ -74,7 +76,7 @@ module Guard
74
76
  end
75
77
  end
76
78
 
77
- def rspec_exec
79
+ def rspec_class
78
80
  case rspec_version
79
81
  when 1
80
82
  "Spec"
@@ -83,6 +85,15 @@ module Guard
83
85
  end
84
86
  end
85
87
 
88
+ def rspec_exec(options = {})
89
+ case rspec_version
90
+ when 1
91
+ options[:binstubs] == true && options[:bundler] != false ? "bin/spec" : "spec"
92
+ when 2
93
+ options[:binstubs] == true && options[:bundler] != false ? "bin/rspec" : "rspec"
94
+ end
95
+ end
96
+
86
97
  def warn_deprectation(options={})
87
98
  [:color, :drb, :fail_fast, [:formatter, "format"]].each do |option|
88
99
  key, value = option.is_a?(Array) ? option : [option, option.to_s.gsub('_', '-')]
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module RSpecVersion
3
- VERSION = "0.5.5"
3
+ VERSION = "0.5.6"
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: 0.5.5
4
+ version: 0.5.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-20 00:00:00.000000000Z
12
+ date: 2011-11-25 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: guard
16
- requirement: &70348587279100 !ruby/object:Gem::Requirement
16
+ requirement: &70263691911840 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.8.4
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70348587279100
24
+ version_requirements: *70263691911840
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &70348587278420 !ruby/object:Gem::Requirement
27
+ requirement: &70263691911220 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '1.0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70348587278420
35
+ version_requirements: *70263691911220
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70348587277740 !ruby/object:Gem::Requirement
38
+ requirement: &70263691910540 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '2.7'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70348587277740
46
+ version_requirements: *70263691910540
47
47
  description: Guard::RSpec automatically run your specs (much like autotest).
48
48
  email:
49
49
  - thibaud@thibaud.me
@@ -75,7 +75,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
75
75
  version: '0'
76
76
  segments:
77
77
  - 0
78
- hash: -1754443213103131612
78
+ hash: 103946227407915062
79
79
  required_rubygems_version: !ruby/object:Gem::Requirement
80
80
  none: false
81
81
  requirements: