guard-rspec 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/guard/rspec/formatters/default_rspec.rb +14 -0
- data/lib/guard/rspec/formatters/default_spec.rb +12 -0
- data/lib/guard/rspec/formatters/instafail_rspec.rb +32 -0
- data/lib/guard/rspec/formatters/instafail_spec.rb +35 -0
- data/lib/guard/rspec/runner.rb +3 -3
- data/lib/guard/rspec/version.rb +1 -1
- metadata +8 -6
- data/lib/guard/rspec/formatters/default.rb +0 -29
- data/lib/guard/rspec/formatters/instafail.rb +0 -69
@@ -0,0 +1,14 @@
|
|
1
|
+
require "#{File.dirname(__FILE__)}/../formatter"
|
2
|
+
require 'rspec/core/formatters/progress_formatter'
|
3
|
+
|
4
|
+
class DefaultRSpec < RSpec::Core::Formatters::ProgressFormatter
|
5
|
+
include Formatter
|
6
|
+
|
7
|
+
def dump_summary(duration, total, failures, pending)
|
8
|
+
super # needed to keep progress formatter
|
9
|
+
|
10
|
+
message = guard_message(total, failures, pending, duration)
|
11
|
+
image = guard_image(failures, pending)
|
12
|
+
notify(message, image)
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require "#{File.dirname(__FILE__)}/../formatter"
|
2
|
+
require 'spec/runner/formatter/progress_bar_formatter'
|
3
|
+
|
4
|
+
class DefaultSpec < Spec::Runner::Formatter::ProgressBarFormatter
|
5
|
+
include Formatter
|
6
|
+
|
7
|
+
def dump_summary(duration, total, failures, pending)
|
8
|
+
message = guard_message(total, failures, pending, duration)
|
9
|
+
image = guard_image(failures, pending)
|
10
|
+
notify(message, image)
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# Inspired from https://github.com/grosser/rspec-instafail/blob/master/lib/rspec/instafail.rb
|
2
|
+
require "#{File.dirname(__FILE__)}/../formatter"
|
3
|
+
require 'rspec/core/formatters/progress_formatter'
|
4
|
+
|
5
|
+
class InstafailRSpec < RSpec::Core::Formatters::ProgressFormatter
|
6
|
+
include Formatter
|
7
|
+
|
8
|
+
def dump_summary(duration, total, failures, pending)
|
9
|
+
super # needed to keep progress formatter
|
10
|
+
|
11
|
+
message = guard_message(total, failures, pending, duration)
|
12
|
+
image = guard_image(failures, pending)
|
13
|
+
notify(message, image)
|
14
|
+
end
|
15
|
+
|
16
|
+
def example_failed(example)
|
17
|
+
@counter ||= 0
|
18
|
+
@counter += 1
|
19
|
+
exception = example.metadata[:execution_result][:exception_encountered]
|
20
|
+
short_padding = ' '
|
21
|
+
padding = ' '
|
22
|
+
output.puts
|
23
|
+
output.puts "#{short_padding}#{@counter}) #{example.full_description}"
|
24
|
+
output.puts "#{padding}#{red("Failure/Error:")} #{red(read_failed_line(exception, example).strip)}"
|
25
|
+
output.puts "#{padding}#{red(exception)}"
|
26
|
+
format_backtrace(exception.backtrace, example).each do |backtrace_info|
|
27
|
+
output.puts grey("#{padding}# #{backtrace_info}")
|
28
|
+
end
|
29
|
+
output.flush
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# Inspired from https://github.com/grosser/rspec-instafail/blob/master/lib/rspec/instafail.rb
|
2
|
+
require "#{File.dirname(__FILE__)}/../formatter"
|
3
|
+
require 'spec/runner/formatter/progress_bar_formatter'
|
4
|
+
|
5
|
+
class InstafailSpec < Spec::Runner::Formatter::ProgressBarFormatter
|
6
|
+
include Formatter
|
7
|
+
|
8
|
+
def dump_summary(duration, total, failures, pending)
|
9
|
+
message = guard_message(total, failures, pending, duration)
|
10
|
+
image = guard_image(failures, pending)
|
11
|
+
notify(message, image)
|
12
|
+
end
|
13
|
+
|
14
|
+
def example_failed(example, counter, failure)
|
15
|
+
short_padding = ' '
|
16
|
+
padding = ' '
|
17
|
+
|
18
|
+
output.puts
|
19
|
+
output.puts red("#{short_padding}#{counter}) #{example_group.description} #{example.description}")
|
20
|
+
output.puts "#{padding}#{red(failure.exception)}"
|
21
|
+
|
22
|
+
format_backtrace(failure.exception.backtrace).each do |backtrace_info|
|
23
|
+
output.puts insta_gray("#{padding}# #{backtrace_info.strip}")
|
24
|
+
end
|
25
|
+
|
26
|
+
output.flush
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
# there is a gray() that returns nil, so we use our own...
|
32
|
+
def insta_gray(text)
|
33
|
+
colour(text, "\e[90m")
|
34
|
+
end
|
35
|
+
end
|
data/lib/guard/rspec/runner.rb
CHANGED
@@ -21,16 +21,16 @@ module Guard
|
|
21
21
|
cmd_parts << "rvm #{options[:rvm].join(',')} exec" if options[:rvm].is_a?(Array)
|
22
22
|
cmd_parts << "bundle exec" if bundler? && options[:bundler] != false
|
23
23
|
|
24
|
+
formatter = options[:formatter] || "default"
|
24
25
|
case rspec_version
|
25
26
|
when 1
|
26
27
|
cmd_parts << "spec"
|
28
|
+
cmd_parts << "--require #{File.dirname(__FILE__)}/formatters/#{formatter}_spec.rb --format #{formatter.capitalize}Spec"
|
27
29
|
when 2
|
28
30
|
cmd_parts << "rspec"
|
31
|
+
cmd_parts << "--require #{File.dirname(__FILE__)}/formatters/#{formatter}_rspec.rb --format #{formatter.capitalize}RSpec"
|
29
32
|
end
|
30
33
|
|
31
|
-
formatter = options[:formatter] || "default"
|
32
|
-
cmd_parts << "--require #{File.dirname(__FILE__)}/formatters/#{formatter}.rb --format #{formatter.capitalize}"
|
33
|
-
|
34
34
|
cmd_parts << "--drb" if options[:drb] == true
|
35
35
|
cmd_parts << "--color" if options[:color] != false
|
36
36
|
cmd_parts << "--fail-fast" if options[:fail_fast] == true
|
data/lib/guard/rspec/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 8
|
10
|
+
version: 0.1.8
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Thibaud Guillaume-Gentil
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-11-
|
18
|
+
date: 2010-11-10 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -77,8 +77,10 @@ extra_rdoc_files: []
|
|
77
77
|
|
78
78
|
files:
|
79
79
|
- lib/guard/rspec/formatter.rb
|
80
|
-
- lib/guard/rspec/formatters/
|
81
|
-
- lib/guard/rspec/formatters/
|
80
|
+
- lib/guard/rspec/formatters/default_rspec.rb
|
81
|
+
- lib/guard/rspec/formatters/default_spec.rb
|
82
|
+
- lib/guard/rspec/formatters/instafail_rspec.rb
|
83
|
+
- lib/guard/rspec/formatters/instafail_spec.rb
|
82
84
|
- lib/guard/rspec/inspector.rb
|
83
85
|
- lib/guard/rspec/runner.rb
|
84
86
|
- lib/guard/rspec/templates/Guardfile
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require "#{File.dirname(__FILE__)}/../formatter"
|
2
|
-
|
3
|
-
if defined?(Spec)
|
4
|
-
# RSpec 1.x
|
5
|
-
require 'spec/runner/formatter/progress_bar_formatter'
|
6
|
-
class Default < Spec::Runner::Formatter::ProgressBarFormatter
|
7
|
-
include Formatter
|
8
|
-
|
9
|
-
def dump_summary(duration, total, failures, pending)
|
10
|
-
message = guard_message(total, failures, pending, duration)
|
11
|
-
image = guard_image(failures, pending)
|
12
|
-
notify(message, image)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
else
|
16
|
-
# RSpec 2.x
|
17
|
-
require 'rspec/core/formatters/progress_formatter'
|
18
|
-
class Default < RSpec::Core::Formatters::ProgressFormatter
|
19
|
-
include Formatter
|
20
|
-
|
21
|
-
def dump_summary(duration, total, failures, pending)
|
22
|
-
super # needed to keep progress formatter
|
23
|
-
|
24
|
-
message = guard_message(total, failures, pending, duration)
|
25
|
-
image = guard_image(failures, pending)
|
26
|
-
notify(message, image)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,69 +0,0 @@
|
|
1
|
-
# Inspired from https://github.com/grosser/rspec-instafail/blob/master/lib/rspec/instafail.rb
|
2
|
-
require "#{File.dirname(__FILE__)}/../formatter"
|
3
|
-
|
4
|
-
if defined?(Spec)
|
5
|
-
# RSpec 1.x
|
6
|
-
require 'spec/runner/formatter/progress_bar_formatter'
|
7
|
-
class Instafail < Spec::Runner::Formatter::ProgressBarFormatter
|
8
|
-
include Formatter
|
9
|
-
|
10
|
-
def dump_summary(duration, total, failures, pending)
|
11
|
-
message = guard_message(total, failures, pending, duration)
|
12
|
-
image = guard_image(failures, pending)
|
13
|
-
notify(message, image)
|
14
|
-
end
|
15
|
-
|
16
|
-
def example_failed(example, counter, failure)
|
17
|
-
short_padding = ' '
|
18
|
-
padding = ' '
|
19
|
-
|
20
|
-
output.puts
|
21
|
-
output.puts red("#{short_padding}#{counter}) #{example_group.description} #{example.description}")
|
22
|
-
output.puts "#{padding}#{red(failure.exception)}"
|
23
|
-
|
24
|
-
format_backtrace(failure.exception.backtrace).each do |backtrace_info|
|
25
|
-
output.puts insta_gray("#{padding}# #{backtrace_info.strip}")
|
26
|
-
end
|
27
|
-
|
28
|
-
output.flush
|
29
|
-
end
|
30
|
-
|
31
|
-
private
|
32
|
-
|
33
|
-
# there is a gray() that returns nil, so we use our own...
|
34
|
-
def insta_gray(text)
|
35
|
-
colour(text, "\e[90m")
|
36
|
-
end
|
37
|
-
end
|
38
|
-
else
|
39
|
-
# RSpec 2.x
|
40
|
-
require 'rspec/core/formatters/progress_formatter'
|
41
|
-
class Instafail < RSpec::Core::Formatters::ProgressFormatter
|
42
|
-
include Formatter
|
43
|
-
|
44
|
-
def dump_summary(duration, total, failures, pending)
|
45
|
-
super # needed to keep progress formatter
|
46
|
-
|
47
|
-
message = guard_message(total, failures, pending, duration)
|
48
|
-
image = guard_image(failures, pending)
|
49
|
-
notify(message, image)
|
50
|
-
end
|
51
|
-
|
52
|
-
def example_failed(example)
|
53
|
-
@counter ||= 0
|
54
|
-
@counter += 1
|
55
|
-
exception = example.metadata[:execution_result][:exception_encountered]
|
56
|
-
short_padding = ' '
|
57
|
-
padding = ' '
|
58
|
-
output.puts
|
59
|
-
output.puts "#{short_padding}#{@counter}) #{example.full_description}"
|
60
|
-
output.puts "#{padding}#{red("Failure/Error:")} #{red(read_failed_line(exception, example).strip)}"
|
61
|
-
output.puts "#{padding}#{red(exception)}"
|
62
|
-
format_backtrace(exception.backtrace, example).each do |backtrace_info|
|
63
|
-
output.puts grey("#{padding}# #{backtrace_info}")
|
64
|
-
end
|
65
|
-
output.flush
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|
69
|
-
end
|