guard-rspec 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown ADDED
@@ -0,0 +1,141 @@
1
+ Guard::RSpec
2
+ =============
3
+
4
+ ![travis-ci](http://travis-ci.org/guard/guard-livereload.png)
5
+
6
+ RSpec guard allows to automatically & intelligently launch specs when files are modified.
7
+
8
+ * 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.
10
+
11
+ Install
12
+ -------
13
+
14
+ Please be sure to have [Guard](https://github.com/guard/guard) installed before continue.
15
+
16
+ Install the gem:
17
+
18
+ $ gem install guard-rspec
19
+
20
+ Add it to your Gemfile (inside test group):
21
+
22
+ ``` ruby
23
+ gem 'guard-rspec'
24
+ ```
25
+
26
+ Add guard definition to your Guardfile by running this command:
27
+
28
+ $ guard init rspec
29
+
30
+ Usage
31
+ -----
32
+
33
+ Please read [Guard usage doc](https://github.com/guard/guard#readme)
34
+
35
+ Guardfile
36
+ ---------
37
+
38
+ RSpec guard can be really adapted to all kind of projects.
39
+
40
+ ### Standard RubyGem project
41
+
42
+ ``` ruby
43
+ guard 'rspec' do
44
+ watch(%r{^spec/.+_spec\.rb})
45
+ watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
46
+ watch('spec/spec_helper.rb') { "spec" }
47
+ end
48
+ ```
49
+
50
+ ### Typical Rails app
51
+
52
+ ``` ruby
53
+ guard 'rspec' do
54
+ watch('spec/spec_helper.rb') { "spec" }
55
+ watch('config/routes.rb') { "spec/routing" }
56
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
57
+ watch(%r{^spec/.+_spec\.rb})
58
+ watch(%r{^app/(.+)\.rb}) { |m| "spec/#{m[1]}_spec.rb" }
59
+ watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
60
+ 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"] }
61
+ end
62
+ ```
63
+
64
+ Please read [Guard doc](https://github.com/guard/guard#readme) for more information about the Guardfile DSL.
65
+
66
+ Options
67
+ -------
68
+
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:
70
+
71
+ ``` ruby
72
+ guard 'rspec', :version => 2 do
73
+ # ...
74
+ end
75
+ ```
76
+
77
+ You can pass any of the standard RSpec CLI options using the <tt>:cli</tt> option:
78
+
79
+ ``` ruby
80
+ guard 'rspec', :cli => "--color --format nested --fail-fast --drb" do
81
+ # ...
82
+ end
83
+ ```
84
+
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.
86
+
87
+ ### List of available options:
88
+
89
+ ``` ruby
90
+ :version => 1 # force use RSpec version 1, default: 2
91
+ :cli => "-c -f doc" # pass arbitrary RSpec CLI arguments, default: "-f progress"
92
+ :bundler => false # don't use "bundle exec" to run the RSpec command, default: true
93
+ :rvm => ['1.8.7', '1.9.2'] # directly run your specs on multiple Rubies, default: nil
94
+ :notification => false # don't display Growl (or Libnotify) notification after the specs are done running, default: true
95
+ :all_after_pass => false # don't run all specs after changed specs pass, default: true
96
+ :all_on_start => false # don't run all the specs at startup, default: true
97
+ :keep_failed => false # keep failed specs until them pass, default: true
98
+ ```
99
+
100
+ Notification
101
+ ------------
102
+
103
+ 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.
104
+
105
+ The best solution is still to update RSpec to the latest version!
106
+
107
+ Formatters
108
+ ----------
109
+
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:
111
+
112
+ ``` ruby
113
+ # in your Gemfile
114
+ gem 'rspec-instafail'
115
+
116
+ # in your Guardfile
117
+ guard 'rspec, :cli => "-r rspec/instafail -f RSpec::Instafail" do
118
+ # ...
119
+ end
120
+ ```
121
+
122
+ Default formatter is the <tt>progress</tt> formatter (same as RSpec default).
123
+
124
+ Development
125
+ -----------
126
+
127
+ * Source hosted at [GitHub](https://github.com/guard/guard-rspec)
128
+ * Report issues/Questions/Feature requests on [GitHub Issues](https://github.com/guard/guard-rspec/issues)
129
+
130
+ Pull requests are very welcome! Make sure your patches are well tested. Please create a topic branch for every separate change
131
+ you make.
132
+
133
+ Testing
134
+ -------
135
+
136
+ Please run <tt>rake spec:prepare_fixtures</tt> once before launching specs.
137
+
138
+ Author
139
+ ------
140
+
141
+ [Thibaud Guillaume-Gentil](https://github.com/thibaudgg)
data/lib/guard/rspec.rb CHANGED
@@ -3,23 +3,51 @@ require 'guard/guard'
3
3
 
4
4
  module Guard
5
5
  class RSpec < Guard
6
-
7
6
  autoload :Runner, 'guard/rspec/runner'
8
7
  autoload :Inspector, 'guard/rspec/inspector'
9
8
 
10
9
  def initialize(watchers=[], options={})
11
10
  super
12
- UI.info "Guard::RSpec is running!"
11
+ @options = {
12
+ :all_after_pass => true,
13
+ :all_on_start => true,
14
+ :keep_failed => true
15
+ }.update(options)
16
+ @last_failed = false
17
+ @failed_paths = []
18
+
13
19
  Runner.set_rspec_version(options)
14
20
  end
15
21
 
22
+ # Call once when guard starts
23
+ def start
24
+ UI.info "Guard::RSpec is running, with RSpec #{Runner.rspec_version}!"
25
+ run_all if @options[:all_on_start]
26
+ end
27
+
16
28
  def run_all
17
- Runner.run(["spec"], options.merge(:message => "Running all specs"))
29
+ passed = Runner.run(["spec"], options.merge(:message => "Running all specs"))
30
+
31
+ @failed_paths = [] if passed
32
+ @last_failed = !passed
18
33
  end
19
34
 
20
35
  def run_on_change(paths)
21
- paths = Inspector.clean(paths)
22
- Runner.run(paths, options) unless paths.empty?
36
+ paths = Inspector.clean(paths)
37
+ paths += @failed_paths if @options[:keep_failed]
38
+ passed = Runner.run(paths.uniq, options)
39
+
40
+ if passed
41
+ # clean failed paths memory
42
+ @failed_paths -= paths if @options[:keep_failed]
43
+ # run all the specs if the changed specs failed, like autotest
44
+ run_all if @last_failed && @options[:all_after_pass]
45
+ else
46
+ # remember failed paths for the next change
47
+ @failed_paths += paths if @options[:keep_failed]
48
+ # track whether the changed specs failed for the next change
49
+ @last_failed = true
50
+ end
23
51
  end
24
52
 
25
53
  end
@@ -5,6 +5,7 @@ module Guard
5
5
  attr_reader :rspec_version
6
6
 
7
7
  def run(paths, options={})
8
+ return false if paths.empty?
8
9
  message = options[:message] || "Running: #{paths.join(' ')}"
9
10
  UI.info(message, :reset => true)
10
11
  system(rspec_command(paths, options))
@@ -24,7 +25,7 @@ module Guard
24
25
  cmd_parts << "bundle exec" if bundler? && options[:bundler] != false
25
26
  cmd_parts << rspec_exec.downcase
26
27
  cmd_parts << options[:cli] if options[:cli]
27
- cmd_parts << "-f progress" unless options[:cli] && options[:cli].split(' ').any? { |w| %w[-f --format].include?(w) }
28
+ cmd_parts << "-f progress" if options[:cli].nil? || !options[:cli].split(' ').any? { |w| %w[-f --format].include?(w) }
28
29
  cmd_parts << "-r #{File.dirname(__FILE__)}/formatters/notification_#{rspec_exec.downcase}.rb -f Notification#{rspec_exec}#{rspec_version == 1 ? ":" : " --out "}/dev/null" if options[:notification] != false
29
30
  cmd_parts << paths.join(' ')
30
31
 
@@ -36,7 +37,6 @@ module Guard
36
37
  end
37
38
 
38
39
  def determine_rspec_version
39
- UI.info "Determine rspec_version... (can be forced with Guard::RSpec version option)"
40
40
  if File.exist?("#{Dir.pwd}/spec/spec_helper.rb")
41
41
  File.new("#{Dir.pwd}/spec/spec_helper.rb").read.include?("Spec::Runner") ? 1 : 2
42
42
  elsif bundler?
@@ -1,8 +1,8 @@
1
- guard 'rspec' do
1
+ guard 'rspec', :version => 2 do
2
2
  watch(%r{^spec/.+_spec\.rb})
3
3
  watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4
4
  watch('spec/spec_helper.rb') { "spec" }
5
-
5
+
6
6
  # Rails example
7
7
  watch('spec/spec_helper.rb') { "spec" }
8
8
  watch('config/routes.rb') { "spec/routing" }
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module RSpecVersion
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,79 +1,54 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-rspec
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 2
8
- - 0
9
- version: 0.2.0
4
+ prerelease:
5
+ version: 0.3.0
10
6
  platform: ruby
11
7
  authors:
12
- - Thibaud Guillaume-Gentil
8
+ - Thibaud Guillaume-Gentil
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2011-03-01 00:00:00 +01:00
13
+ date: 2011-04-23 00:00:00 +02:00
18
14
  default_executable:
19
15
  dependencies:
20
- - !ruby/object:Gem::Dependency
21
- name: guard
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- segments:
28
- - 0
29
- - 2
30
- - 2
31
- version: 0.2.2
32
- type: :runtime
33
- version_requirements: *id001
34
- - !ruby/object:Gem::Dependency
35
- name: bundler
36
- prerelease: false
37
- requirement: &id002 !ruby/object:Gem::Requirement
38
- requirements:
39
- - - ~>
40
- - !ruby/object:Gem::Version
41
- segments:
42
- - 1
43
- - 0
44
- - 10
45
- version: 1.0.10
46
- type: :development
47
- version_requirements: *id002
48
- - !ruby/object:Gem::Dependency
49
- name: rspec
50
- prerelease: false
51
- requirement: &id003 !ruby/object:Gem::Requirement
52
- requirements:
53
- - - ~>
54
- - !ruby/object:Gem::Version
55
- segments:
56
- - 2
57
- - 4
58
- - 0
59
- version: 2.4.0
60
- type: :development
61
- version_requirements: *id003
62
- - !ruby/object:Gem::Dependency
63
- name: rspec-instafail
64
- prerelease: false
65
- requirement: &id004 !ruby/object:Gem::Requirement
66
- requirements:
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- segments:
70
- - 0
71
- version: "0"
72
- type: :development
73
- version_requirements: *id004
74
- description: Guard::RSpec automatically run your specs (much like autotest)
16
+ - !ruby/object:Gem::Dependency
17
+ name: guard
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: 0.2.2
25
+ type: :runtime
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ~>
34
+ - !ruby/object:Gem::Version
35
+ version: "1.0"
36
+ type: :development
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: rspec
40
+ prerelease: false
41
+ requirement: &id003 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: "2.5"
47
+ type: :development
48
+ version_requirements: *id003
49
+ description: Guard::RSpec automatically run your specs (much like autotest).
75
50
  email:
76
- - thibaud@thibaud.me
51
+ - thibaud@thibaud.me
77
52
  executables: []
78
53
 
79
54
  extensions: []
@@ -81,20 +56,16 @@ extensions: []
81
56
  extra_rdoc_files: []
82
57
 
83
58
  files:
84
- - lib/guard/rspec.rb
85
- - lib/guard/rspec.rbc
86
- - lib/guard/rspec/formatter.rb
87
- - lib/guard/rspec/inspector.rb
88
- - lib/guard/rspec/inspector.rbc
89
- - lib/guard/rspec/runner.rb
90
- - lib/guard/rspec/runner.rbc
91
- - lib/guard/rspec/version.rb
92
- - lib/guard/rspec/version.rbc
93
- - lib/guard/rspec/formatters/notification_rspec.rb
94
- - lib/guard/rspec/formatters/notification_spec.rb
95
- - lib/guard/rspec/templates/Guardfile
96
- - LICENSE
97
- - README.rdoc
59
+ - lib/guard/rspec/formatter.rb
60
+ - lib/guard/rspec/formatters/notification_rspec.rb
61
+ - lib/guard/rspec/formatters/notification_spec.rb
62
+ - lib/guard/rspec/inspector.rb
63
+ - lib/guard/rspec/runner.rb
64
+ - lib/guard/rspec/templates/Guardfile
65
+ - lib/guard/rspec/version.rb
66
+ - lib/guard/rspec.rb
67
+ - LICENSE
68
+ - README.markdown
98
69
  has_rdoc: true
99
70
  homepage: http://rubygems.org/gems/guard-rspec
100
71
  licenses: []
@@ -103,27 +74,23 @@ post_install_message:
103
74
  rdoc_options: []
104
75
 
105
76
  require_paths:
106
- - lib
77
+ - lib
107
78
  required_ruby_version: !ruby/object:Gem::Requirement
79
+ none: false
108
80
  requirements:
109
- - - ">="
110
- - !ruby/object:Gem::Version
111
- segments:
112
- - 0
113
- version: "0"
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: "0"
114
84
  required_rubygems_version: !ruby/object:Gem::Requirement
85
+ none: false
115
86
  requirements:
116
- - - ">="
117
- - !ruby/object:Gem::Version
118
- segments:
119
- - 1
120
- - 3
121
- - 6
122
- version: 1.3.6
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 1.3.6
123
90
  requirements: []
124
91
 
125
92
  rubyforge_project: guard-rspec
126
- rubygems_version: 1.3.6
93
+ rubygems_version: 1.6.2
127
94
  signing_key:
128
95
  specification_version: 3
129
96
  summary: Guard gem for RSpec
data/README.rdoc DELETED
@@ -1,106 +0,0 @@
1
- = Guard::RSpec
2
-
3
- RSpec guard allows to automatically & intelligently launch specs when files are modified.
4
-
5
- - Compatible with RSpec 1.x & RSpec 2.x (>= 2.4 needed for notification formatter)
6
- - Tested on Ruby 1.8.6, 1.8.7, 1.9.2, JRuby & Rubinius.
7
-
8
- == Install
9
-
10
- Please be sure to have {Guard}[https://github.com/guard/guard] installed before continue.
11
-
12
- Install the gem:
13
-
14
- $ gem install guard-rspec
15
-
16
- Add it to your Gemfile (inside test group):
17
-
18
- gem 'guard-rspec'
19
-
20
- Add guard definition to your Guardfile by running this command:
21
-
22
- $ guard init rspec
23
-
24
- == Usage
25
-
26
- Please read {Guard usage doc}[https://github.com/guard/guard#readme]
27
-
28
- == Guardfile
29
-
30
- RSpec guard can be really adapted to all kind of projects.
31
-
32
- === Standard RubyGem project
33
-
34
- guard 'rspec' do
35
- watch(%r{^spec/.+_spec\.rb})
36
- watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
37
- watch('spec/spec_helper.rb') { "spec" }
38
- end
39
-
40
- === Typical Rails app
41
-
42
- guard 'rspec' do
43
- watch('spec/spec_helper.rb') { "spec" }
44
- watch('config/routes.rb') { "spec/routing" }
45
- watch('app/controllers/application_controller.rb') { "spec/controllers" }
46
- watch(%r{^spec/.+_spec\.rb})
47
- watch(%r{^app/(.+)\.rb}) { |m| "spec/#{m[1]}_spec.rb" }
48
- watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
49
- 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"] }
50
- end
51
-
52
- Please read {Guard doc}[https://github.com/guard/guard#readme] for more information about the Guardfile DSL.
53
-
54
- == Options
55
-
56
- 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:
57
-
58
- guard 'rspec', :version => 2 do
59
- ...
60
- end
61
-
62
- You can pass any of the standard RSpec CLI options using the <tt>:cli</tt> option:
63
-
64
- guard 'rspec', :cli => "--color --format nested --fail-fast --drb" do
65
- ...
66
- end
67
-
68
- Former <tt>:color</tt>, <tt>:drb</tt>, <tt>:fail_fast</tt> and <tt>:formatter</tt> options are thus deprecated and have no effect anymore.
69
-
70
- === List of available options:
71
-
72
- :version => 1 # force use RSpec version 1, default: 2
73
- :cli => "-c -f doc" # pass arbitrary RSpec CLI arguments, default: "-f progress"
74
- :bundler => false # don't use "bundle exec" to run the RSpec command, default: true
75
- :rvm => ['1.8.7', '1.9.2'] # directly run your specs on multiple Rubies, default: nil
76
- :notification => false # don't display Growl (or Libnotify) notification after the specs are done running, default: true
77
-
78
- == Formatters
79
-
80
- 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</tt> gem instead:
81
-
82
- # in your Gemfile
83
- gem 'rspec-instafail'
84
-
85
- # in your Guardfile
86
- guard 'rspec, :cli => "-r rspec/instafail -f RSpec::Instafail" do
87
- ...
88
- end
89
-
90
- Default formatter is the <tt>progress</tt> formatter (same as RSpec default).
91
-
92
- == Development
93
-
94
- - Source hosted at {GitHub}[https://github.com/guard/guard-rspec]
95
- - Report issues/Questions/Feature requests on {GitHub Issues}[https://github.com/guard/guard-rspec/issues]
96
-
97
- Pull requests are very welcome! Make sure your patches are well tested. Please create a topic branch for every separate change
98
- you make.
99
-
100
- === Testing
101
-
102
- Please run <tt>rake spec:prepare_fixtures</tt> once before launching specs.
103
-
104
- == Authors
105
-
106
- {Thibaud Guillaume-Gentil}[https://github.com/thibaudgg]