guard-rspec 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,72 +1,92 @@
1
- module Guard
2
- class RSpec
3
- module Runner
4
- class << self
5
- attr_reader :rspec_version
6
-
7
- def run(paths, options={})
8
- return false if paths.empty?
9
- message = options[:message] || "Running: #{paths.join(' ')}"
10
- UI.info(message, :reset => true)
11
- system(rspec_command(paths, options))
12
- end
13
-
14
- def set_rspec_version(options={})
15
- @rspec_version = options[:version] || determine_rspec_version
16
- end
17
-
18
- private
19
-
20
- def rspec_command(paths, options={})
21
- warn_deprectation(options)
22
-
23
- cmd_parts = []
24
- cmd_parts << "rvm #{options[:rvm].join(',')} exec" if options[:rvm].is_a?(Array)
25
- cmd_parts << "bundle exec" if bundler? && options[:bundler] != false
26
- cmd_parts << rspec_exec.downcase
27
- cmd_parts << options[:cli] if options[:cli]
28
- cmd_parts << "-f progress" if options[:cli].nil? || !options[:cli].split(' ').any? { |w| %w[-f --format].include?(w) }
29
- 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
30
- cmd_parts << paths.join(' ')
31
-
32
- cmd_parts.join(' ')
33
- end
34
-
35
- def bundler?
36
- @bundler ||= File.exist?("#{Dir.pwd}/Gemfile")
37
- end
38
-
39
- def determine_rspec_version
40
- if File.exist?("#{Dir.pwd}/spec/spec_helper.rb")
41
- File.new("#{Dir.pwd}/spec/spec_helper.rb").read.include?("Spec::Runner") ? 1 : 2
42
- elsif bundler?
43
- # Allow RSpactor to be tested with RSpactor (bundle show inside a bundle exec)
44
- ENV['BUNDLE_GEMFILE'] = "#{Dir.pwd}/Gemfile"
45
- `bundle show rspec`.include?("/rspec-1.") ? 1 : 2
46
- else
47
- 2
48
- end
49
- end
50
-
51
- def rspec_exec
52
- case rspec_version
53
- when 1
54
- "Spec"
55
- when 2
56
- "RSpec"
57
- end
58
- end
59
-
60
- def warn_deprectation(options={})
61
- [:color, :drb, :fail_fast, [:formatter, "format"]].each do |option|
62
- key, value = option.is_a?(Array) ? option : [option, option.to_s.gsub('_', '-')]
63
- if options.key?(key)
64
- UI.info %{DEPRECATION WARNING: The :#{key} option is deprecated. Pass standard command line argument "--#{value}" to RSpec with the :cli option.}
65
- end
66
- end
67
- end
68
-
69
- end
70
- end
71
- end
72
- end
1
+ module Guard
2
+ class RSpec
3
+ module Runner
4
+ class << self
5
+ attr_reader :rspec_version
6
+
7
+ def run(paths, options={})
8
+ return false if paths.empty?
9
+ message = options[:message] || "Running: #{paths.join(' ')}"
10
+ UI.info(message, :reset => true)
11
+ system(rspec_command(paths, options))
12
+
13
+ if options[:notification] != false && failure_exit_code_supported?(options) && $? && !$?.success? && $?.exitstatus != failure_exit_code
14
+ Notifier.notify("Failed", :title => "RSpec results", :image => :failed, :priority => 2)
15
+ end
16
+ end
17
+
18
+ def set_rspec_version(options={})
19
+ @rspec_version = options[:version] || determine_rspec_version
20
+ end
21
+
22
+ private
23
+
24
+ def rspec_command(paths, options={})
25
+ warn_deprectation(options)
26
+
27
+ cmd_parts = []
28
+ cmd_parts << "rvm #{options[:rvm].join(',')} exec" if options[:rvm].is_a?(Array)
29
+ cmd_parts << "bundle exec" if bundler? && options[:bundler] != false
30
+ cmd_parts << rspec_exec.downcase
31
+ cmd_parts << options[:cli] if options[:cli]
32
+ cmd_parts << "-f progress" if options[:cli].nil? || !options[:cli].split(' ').any? { |w| %w[-f --format].include?(w) }
33
+ 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
34
+ cmd_parts << "--failure-exit-code #{failure_exit_code}" if failure_exit_code_supported?(options)
35
+ cmd_parts << paths.join(' ')
36
+
37
+ cmd_parts.join(' ')
38
+ end
39
+
40
+ def bundler?
41
+ @bundler ||= File.exist?("#{Dir.pwd}/Gemfile")
42
+ end
43
+
44
+ def failure_exit_code_supported?(options={})
45
+ return @failure_exit_code_supported if defined?(@failure_exit_code_supported)
46
+ @failure_exit_code_supported ||= begin
47
+ cmd_parts = []
48
+ cmd_parts << "bundle exec" if bundler? && options[:bundler] != false
49
+ cmd_parts << rspec_exec.downcase
50
+ cmd_parts << "--help"
51
+ `#{cmd_parts.join(' ')}`.include? "--failure-exit-code"
52
+ end
53
+ end
54
+
55
+ def failure_exit_code
56
+ 2
57
+ end
58
+
59
+ def determine_rspec_version
60
+ if File.exist?("#{Dir.pwd}/spec/spec_helper.rb")
61
+ File.new("#{Dir.pwd}/spec/spec_helper.rb").read.include?("Spec::Runner") ? 1 : 2
62
+ elsif bundler?
63
+ # Allow RSpactor to be tested with RSpactor (bundle show inside a bundle exec)
64
+ ENV['BUNDLE_GEMFILE'] = "#{Dir.pwd}/Gemfile"
65
+ `bundle show rspec`.include?("/rspec-1.") ? 1 : 2
66
+ else
67
+ 2
68
+ end
69
+ end
70
+
71
+ def rspec_exec
72
+ case rspec_version
73
+ when 1
74
+ "Spec"
75
+ when 2
76
+ "RSpec"
77
+ end
78
+ end
79
+
80
+ def warn_deprectation(options={})
81
+ [:color, :drb, :fail_fast, [:formatter, "format"]].each do |option|
82
+ key, value = option.is_a?(Array) ? option : [option, option.to_s.gsub('_', '-')]
83
+ if options.key?(key)
84
+ UI.info %{DEPRECATION WARNING: The :#{key} option is deprecated. Pass standard command line argument "--#{value}" to RSpec with the :cli option.}
85
+ end
86
+ end
87
+ end
88
+
89
+ end
90
+ end
91
+ end
92
+ end
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module RSpecVersion
3
- VERSION = "0.5.2"
3
+ VERSION = "0.5.3"
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.2
4
+ version: 0.5.3
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-03 00:00:00.000000000Z
12
+ date: 2011-11-11 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: guard
16
- requirement: &70330372160140 !ruby/object:Gem::Requirement
16
+ requirement: &70109266071340 !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: *70330372160140
24
+ version_requirements: *70109266071340
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &70330372159640 !ruby/object:Gem::Requirement
27
+ requirement: &70109266070620 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,18 +32,18 @@ dependencies:
32
32
  version: '1.0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70330372159640
35
+ version_requirements: *70109266070620
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70330372159180 !ruby/object:Gem::Requirement
38
+ requirement: &70109266069960 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
42
42
  - !ruby/object:Gem::Version
43
- version: '2.6'
43
+ version: '2.7'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70330372159180
46
+ version_requirements: *70109266069960
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: 1372171811730105322
78
+ hash: 3258196998992283106
79
79
  required_rubygems_version: !ruby/object:Gem::Requirement
80
80
  none: false
81
81
  requirements: