guard-rspec 0.5.4 → 0.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,96 +1,98 @@
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 && !drb?(options) && 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 drb?(options)
41
- !options[:cli].nil? && options[:cli].include?('--drb')
42
- end
43
-
44
- def bundler?
45
- @bundler ||= File.exist?("#{Dir.pwd}/Gemfile")
46
- end
47
-
48
- def failure_exit_code_supported?(options={})
49
- return @failure_exit_code_supported if defined?(@failure_exit_code_supported)
50
- @failure_exit_code_supported ||= begin
51
- cmd_parts = []
52
- cmd_parts << "bundle exec" if bundler? && options[:bundler] != false
53
- cmd_parts << rspec_exec.downcase
54
- cmd_parts << "--help"
55
- `#{cmd_parts.join(' ')}`.include? "--failure-exit-code"
56
- end
57
- end
58
-
59
- def failure_exit_code
60
- 2
61
- end
62
-
63
- def determine_rspec_version
64
- if File.exist?("#{Dir.pwd}/spec/spec_helper.rb")
65
- File.new("#{Dir.pwd}/spec/spec_helper.rb").read.include?("Spec::Runner") ? 1 : 2
66
- elsif bundler?
67
- # Allow RSpactor to be tested with RSpactor (bundle show inside a bundle exec)
68
- ENV['BUNDLE_GEMFILE'] = "#{Dir.pwd}/Gemfile"
69
- `bundle show rspec`.include?("/rspec-1.") ? 1 : 2
70
- else
71
- 2
72
- end
73
- end
74
-
75
- def rspec_exec
76
- case rspec_version
77
- when 1
78
- "Spec"
79
- when 2
80
- "RSpec"
81
- end
82
- end
83
-
84
- def warn_deprectation(options={})
85
- [:color, :drb, :fail_fast, [:formatter, "format"]].each do |option|
86
- key, value = option.is_a?(Array) ? option : [option, option.to_s.gsub('_', '-')]
87
- if options.key?(key)
88
- UI.info %{DEPRECATION WARNING: The :#{key} option is deprecated. Pass standard command line argument "--#{value}" to RSpec with the :cli option.}
89
- end
90
- end
91
- end
92
-
93
- end
94
- end
95
- end
96
- 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 && !drb?(options) && failure_exit_code_supported?(options) && $? && !$?.success? && $?.exitstatus != failure_exit_code
14
+ Notifier.notify("Failed", :title => "RSpec results", :image => :failed, :priority => 2)
15
+ end
16
+
17
+ $?.success?
18
+ end
19
+
20
+ def set_rspec_version(options={})
21
+ @rspec_version = options[:version] || determine_rspec_version
22
+ end
23
+
24
+ private
25
+
26
+ def rspec_command(paths, options={})
27
+ warn_deprectation(options)
28
+
29
+ cmd_parts = []
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
33
+ cmd_parts << options[:cli] if options[:cli]
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
36
+ cmd_parts << "--failure-exit-code #{failure_exit_code}" if failure_exit_code_supported?(options)
37
+ cmd_parts << paths.join(' ')
38
+
39
+ cmd_parts.join(' ')
40
+ end
41
+
42
+ def drb?(options)
43
+ !options[:cli].nil? && options[:cli].include?('--drb')
44
+ end
45
+
46
+ def bundler?
47
+ @bundler ||= File.exist?("#{Dir.pwd}/Gemfile")
48
+ end
49
+
50
+ def failure_exit_code_supported?(options={})
51
+ return @failure_exit_code_supported if defined?(@failure_exit_code_supported)
52
+ @failure_exit_code_supported ||= begin
53
+ cmd_parts = []
54
+ cmd_parts << "bundle exec" if bundler? && options[:bundler] != false
55
+ cmd_parts << rspec_exec.downcase
56
+ cmd_parts << "--help"
57
+ `#{cmd_parts.join(' ')}`.include? "--failure-exit-code"
58
+ end
59
+ end
60
+
61
+ def failure_exit_code
62
+ 2
63
+ end
64
+
65
+ def determine_rspec_version
66
+ if File.exist?("#{Dir.pwd}/spec/spec_helper.rb")
67
+ File.new("#{Dir.pwd}/spec/spec_helper.rb").read.include?("Spec::Runner") ? 1 : 2
68
+ elsif bundler?
69
+ # Allow RSpactor to be tested with RSpactor (bundle show inside a bundle exec)
70
+ ENV['BUNDLE_GEMFILE'] = "#{Dir.pwd}/Gemfile"
71
+ `bundle show rspec`.include?("/rspec-1.") ? 1 : 2
72
+ else
73
+ 2
74
+ end
75
+ end
76
+
77
+ def rspec_exec
78
+ case rspec_version
79
+ when 1
80
+ "Spec"
81
+ when 2
82
+ "RSpec"
83
+ end
84
+ end
85
+
86
+ def warn_deprectation(options={})
87
+ [:color, :drb, :fail_fast, [:formatter, "format"]].each do |option|
88
+ key, value = option.is_a?(Array) ? option : [option, option.to_s.gsub('_', '-')]
89
+ if options.key?(key)
90
+ UI.info %{DEPRECATION WARNING: The :#{key} option is deprecated. Pass standard command line argument "--#{value}" to RSpec with the :cli option.}
91
+ end
92
+ end
93
+ end
94
+
95
+ end
96
+ end
97
+ end
98
+ end
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module RSpecVersion
3
- VERSION = "0.5.4"
3
+ VERSION = "0.5.5"
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.4
4
+ version: 0.5.5
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-14 00:00:00.000000000Z
12
+ date: 2011-11-20 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: guard
16
- requirement: &70212535935480 !ruby/object:Gem::Requirement
16
+ requirement: &70348587279100 !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: *70212535935480
24
+ version_requirements: *70348587279100
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &70212535934860 !ruby/object:Gem::Requirement
27
+ requirement: &70348587278420 !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: *70212535934860
35
+ version_requirements: *70348587278420
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70212535934380 !ruby/object:Gem::Requirement
38
+ requirement: &70348587277740 !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: *70212535934380
46
+ version_requirements: *70348587277740
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: 1789026864584824679
78
+ hash: -1754443213103131612
79
79
  required_rubygems_version: !ruby/object:Gem::Requirement
80
80
  none: false
81
81
  requirements: