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.
- data/lib/guard/rspec/runner.rb +92 -72
- data/lib/guard/rspec/version.rb +1 -1
- metadata +10 -10
data/lib/guard/rspec/runner.rb
CHANGED
@@ -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
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
cmd_parts
|
28
|
-
cmd_parts << "
|
29
|
-
cmd_parts << "
|
30
|
-
cmd_parts <<
|
31
|
-
|
32
|
-
cmd_parts.
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
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
|
data/lib/guard/rspec/version.rb
CHANGED
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
|
+
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-
|
12
|
+
date: 2011-11-11 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: guard
|
16
|
-
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: *
|
24
|
+
version_requirements: *70109266071340
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bundler
|
27
|
-
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: *
|
35
|
+
version_requirements: *70109266070620
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
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.
|
43
|
+
version: '2.7'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
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:
|
78
|
+
hash: 3258196998992283106
|
79
79
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
80
|
none: false
|
81
81
|
requirements:
|