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.
- data/lib/guard/rspec/runner.rb +98 -96
- data/lib/guard/rspec/version.rb +1 -1
- metadata +9 -9
data/lib/guard/rspec/runner.rb
CHANGED
@@ -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
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
cmd_parts
|
30
|
-
cmd_parts <<
|
31
|
-
cmd_parts <<
|
32
|
-
cmd_parts <<
|
33
|
-
cmd_parts <<
|
34
|
-
cmd_parts << "
|
35
|
-
cmd_parts <<
|
36
|
-
|
37
|
-
cmd_parts.join(' ')
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
cmd_parts
|
54
|
-
cmd_parts << "
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
#
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
2
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
when
|
80
|
-
"
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
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
|
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.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-
|
12
|
+
date: 2011-11-20 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: guard
|
16
|
-
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: *
|
24
|
+
version_requirements: *70348587279100
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bundler
|
27
|
-
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: *
|
35
|
+
version_requirements: *70348587278420
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
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: *
|
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:
|
78
|
+
hash: -1754443213103131612
|
79
79
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
80
|
none: false
|
81
81
|
requirements:
|