teaspoon 0.7.9 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +382 -260
- data/app/assets/javascripts/teaspoon-angular.js +108 -26241
- data/app/assets/javascripts/teaspoon-jasmine.js +103 -2642
- data/app/assets/javascripts/teaspoon-mocha.js +109 -5416
- data/app/assets/javascripts/teaspoon-qunit.js +107 -2255
- data/app/assets/javascripts/teaspoon-teaspoon.js +0 -1
- data/app/assets/javascripts/teaspoon/angular.coffee +3 -1
- data/app/assets/javascripts/teaspoon/base/hook.coffee +21 -0
- data/app/assets/javascripts/teaspoon/base/reporters/html.coffee +26 -14
- data/app/assets/javascripts/teaspoon/base/reporters/html/progress_view.coffee +1 -1
- data/app/assets/javascripts/teaspoon/base/reporters/html/template.coffee +3 -3
- data/app/assets/javascripts/teaspoon/base/teaspoon.coffee +10 -1
- data/app/assets/javascripts/teaspoon/jasmine.coffee +3 -1
- data/app/assets/javascripts/teaspoon/mocha.coffee +3 -1
- data/app/assets/javascripts/teaspoon/mocha/reporters/html.coffee +1 -1
- data/app/assets/javascripts/teaspoon/qunit.coffee +3 -1
- data/app/assets/javascripts/teaspoon/qunit/reporters/html.coffee +1 -1
- data/app/assets/javascripts/teaspoon/teaspoon.coffee +0 -1
- data/app/assets/stylesheets/teaspoon.css +12 -8
- data/app/controllers/teaspoon/suite_controller.rb +32 -0
- data/app/views/teaspoon/suite/_body.html.erb +0 -0
- data/app/views/teaspoon/suite/_boot.html.erb +4 -0
- data/app/views/teaspoon/suite/_boot_require_js.html.erb +19 -0
- data/app/views/teaspoon/{spec/suites.html.erb → suite/index.html.erb} +6 -7
- data/app/views/teaspoon/suite/show.html.erb +19 -0
- data/bin/teaspoon +1 -1
- data/config/routes.rb +14 -4
- data/lib/generators/teaspoon/install/POST_INSTALL +2 -2
- data/lib/generators/teaspoon/install/install_generator.rb +22 -11
- data/lib/generators/teaspoon/install/templates/_body.html.erb +0 -0
- data/lib/generators/teaspoon/install/templates/_boot.html.erb +4 -0
- data/lib/generators/teaspoon/install/templates/jasmine/env.rb +11 -0
- data/lib/generators/teaspoon/install/templates/jasmine/env_comments.rb +182 -0
- data/lib/generators/teaspoon/install/templates/jasmine/spec_helper.coffee +8 -6
- data/lib/generators/teaspoon/install/templates/jasmine/spec_helper.js +8 -7
- data/lib/generators/teaspoon/install/templates/mocha/env.rb +11 -0
- data/lib/generators/teaspoon/install/templates/mocha/env_comments.rb +182 -0
- data/lib/generators/teaspoon/install/templates/mocha/spec_helper.coffee +13 -13
- data/lib/generators/teaspoon/install/templates/mocha/spec_helper.js +13 -13
- data/lib/generators/teaspoon/install/templates/qunit/env.rb +11 -0
- data/lib/generators/teaspoon/install/templates/qunit/env_comments.rb +182 -0
- data/lib/generators/teaspoon/install/templates/qunit/test_helper.coffee +6 -5
- data/lib/generators/teaspoon/install/templates/qunit/test_helper.js +6 -5
- data/lib/tasks/teaspoon.rake +9 -2
- data/lib/teaspoon.rb +4 -6
- data/lib/teaspoon/command_line.rb +116 -134
- data/lib/teaspoon/configuration.rb +144 -66
- data/lib/teaspoon/console.rb +70 -37
- data/lib/teaspoon/coverage.rb +42 -15
- data/lib/teaspoon/deprecated.rb +65 -0
- data/lib/teaspoon/drivers/base.rb +10 -0
- data/lib/teaspoon/drivers/phantomjs/runner.js +9 -11
- data/lib/teaspoon/drivers/phantomjs_driver.rb +21 -21
- data/lib/teaspoon/drivers/selenium_driver.rb +32 -13
- data/lib/teaspoon/engine.rb +32 -12
- data/lib/teaspoon/environment.rb +16 -12
- data/lib/teaspoon/exceptions.rb +41 -5
- data/lib/teaspoon/exporter.rb +52 -0
- data/lib/teaspoon/formatters/base.rb +171 -0
- data/lib/teaspoon/formatters/clean_formatter.rb +2 -4
- data/lib/teaspoon/formatters/documentation_formatter.rb +60 -0
- data/lib/teaspoon/formatters/dot_formatter.rb +12 -90
- data/lib/teaspoon/formatters/json_formatter.rb +36 -0
- data/lib/teaspoon/formatters/junit_formatter.rb +51 -32
- data/lib/teaspoon/formatters/modules/report_module.rb +76 -0
- data/lib/teaspoon/formatters/pride_formatter.rb +23 -27
- data/lib/teaspoon/formatters/snowday_formatter.rb +7 -11
- data/lib/teaspoon/formatters/swayze_or_oprah_formatter.rb +88 -64
- data/lib/teaspoon/formatters/tap_formatter.rb +18 -27
- data/lib/teaspoon/formatters/tap_y_formatter.rb +35 -45
- data/lib/teaspoon/formatters/teamcity_formatter.rb +69 -31
- data/lib/teaspoon/instrumentation.rb +33 -33
- data/lib/teaspoon/result.rb +2 -1
- data/lib/teaspoon/runner.rb +40 -28
- data/lib/teaspoon/server.rb +23 -25
- data/lib/teaspoon/suite.rb +52 -72
- data/lib/teaspoon/utility.rb +3 -14
- data/lib/teaspoon/version.rb +1 -1
- data/spec/dummy/app/assets/javascripts/integration/integration_spec.coffee +3 -0
- data/spec/dummy/app/assets/javascripts/integration/spec_helper.coffee +2 -0
- data/spec/dummy/config/application.rb +3 -0
- data/spec/features/console_reporter_spec.rb +48 -18
- data/spec/features/hooks_spec.rb +23 -41
- data/spec/features/html_reporter_spec.rb +38 -21
- data/spec/features/install_generator_spec.rb +34 -20
- data/spec/features/instrumentation_spec.rb +3 -2
- data/spec/fixtures/coverage.json +243 -0
- data/spec/javascripts/fixtures/_body.html.erb +1 -0
- data/spec/javascripts/jasmine_helper.coffee +1 -1
- data/spec/javascripts/teaspoon/base/fixture_spec.coffee +4 -4
- data/spec/javascripts/teaspoon/base/reporters/html_spec.coffee +9 -10
- data/spec/javascripts/teaspoon/mocha/reporters/html_mspec.coffee +0 -6
- data/spec/javascripts/teaspoon/phantomjs/runner_spec.coffee +5 -6
- data/spec/javascripts/turbolinks_helper.coffee +1 -1
- data/spec/spec_helper.rb +3 -4
- data/spec/teaspoon/command_line_spec.rb +139 -23
- data/spec/teaspoon/configuration_spec.rb +164 -46
- data/spec/teaspoon/console_spec.rb +142 -47
- data/spec/teaspoon/coverage_spec.rb +98 -28
- data/spec/teaspoon/drivers/base_spec.rb +5 -0
- data/spec/teaspoon/drivers/phantomjs_driver_spec.rb +32 -14
- data/spec/teaspoon/drivers/selenium_driver_spec.rb +32 -24
- data/spec/teaspoon/engine_spec.rb +8 -5
- data/spec/teaspoon/environment_spec.rb +56 -33
- data/spec/teaspoon/exceptions_spec.rb +57 -0
- data/spec/teaspoon/exporter_spec.rb +96 -0
- data/spec/teaspoon/formatters/base_spec.rb +259 -0
- data/spec/teaspoon/formatters/clean_formatter_spec.rb +37 -0
- data/spec/teaspoon/formatters/documentation_formatter_spec.rb +127 -0
- data/spec/teaspoon/formatters/dot_formatter_spec.rb +52 -56
- data/spec/teaspoon/formatters/json_formatter_spec.rb +77 -0
- data/spec/teaspoon/formatters/junit_formatter_spec.rb +72 -35
- data/spec/teaspoon/formatters/pride_formatter_spec.rb +37 -0
- data/spec/teaspoon/formatters/snowday_formatter_spec.rb +35 -0
- data/spec/teaspoon/formatters/tap_formatter_spec.rb +29 -81
- data/spec/teaspoon/formatters/tap_y_formatter_spec.rb +31 -141
- data/spec/teaspoon/formatters/teamcity_formatter_spec.rb +99 -42
- data/spec/teaspoon/instrumentation_spec.rb +44 -44
- data/spec/teaspoon/result_spec.rb +37 -0
- data/spec/teaspoon/runner_spec.rb +70 -59
- data/spec/teaspoon/server_spec.rb +34 -52
- data/spec/teaspoon/suite_spec.rb +42 -188
- data/spec/teaspoon_env.rb +39 -28
- data/vendor/assets/javascripts/{angular-scenario-1.0.5.js → angular/1.0.5.js} +0 -0
- data/vendor/assets/javascripts/{angular-scenario-1.0.5.MIT-LICENSE → angular/MIT-LICENSE} +0 -0
- data/vendor/assets/javascripts/{jasmine-1.3.1.js → jasmine/1.3.1.js} +0 -0
- data/vendor/assets/javascripts/jasmine/2.0.0.js +2412 -0
- data/vendor/assets/javascripts/{jasmine-1.3.1.MIT.LICENSE → jasmine/MIT.LICENSE} +0 -0
- data/vendor/assets/javascripts/{mocha-1.10.0.js → mocha/1.10.0.js} +1 -0
- data/vendor/assets/javascripts/mocha/1.17.1.js +5813 -0
- data/vendor/assets/javascripts/{mocha-1.10.1.MIT.LICENSE → mocha/MIT.LICENSE} +0 -0
- data/vendor/assets/javascripts/{qunit-1.12.0.js → qunit/1.12.0.js} +1 -1
- data/vendor/assets/javascripts/qunit/1.14.0.js +2288 -0
- data/vendor/assets/javascripts/{qunit-1.12.0.MIT.LICENSE → qunit/MIT.LICENSE} +0 -0
- data/vendor/assets/javascripts/support/chai.js +827 -385
- data/vendor/assets/javascripts/support/jasmine-jquery-1.7.0.js +720 -0
- data/vendor/assets/javascripts/support/jasmine-jquery-2.0.0.js +812 -0
- data/vendor/assets/javascripts/support/sinon-chai.js +17 -0
- data/vendor/assets/javascripts/support/sinon.js +1138 -643
- metadata +57 -36
- data/app/controllers/teaspoon/spec_controller.rb +0 -38
- data/app/helpers/teaspoon/spec_helper.rb +0 -36
- data/app/views/teaspoon/spec/_require_js.html.erb +0 -21
- data/app/views/teaspoon/spec/_standard.html.erb +0 -4
- data/app/views/teaspoon/spec/runner.html.erb +0 -19
- data/lib/generators/teaspoon/install/templates/env.rb +0 -38
- data/lib/generators/teaspoon/install/templates/jasmine/initializer.rb +0 -64
- data/lib/generators/teaspoon/install/templates/mocha/initializer.rb +0 -64
- data/lib/generators/teaspoon/install/templates/qunit/initializer.rb +0 -64
- data/lib/teaspoon/check_coverage.rb +0 -33
- data/lib/teaspoon/drivers/base_driver.rb +0 -10
- data/lib/teaspoon/exception_handling.rb +0 -18
- data/lib/teaspoon/formatters/base_formatter.rb +0 -63
- data/spec/dummy/config/initializers/teaspoon.rb +0 -41
- data/spec/teaspoon/check_coverage_spec.rb +0 -50
- data/spec/teaspoon/formatters/base_formatter_spec.rb +0 -45
- data/vendor/assets/javascripts/support/chai.MIT.LICENSE +0 -22
- data/vendor/assets/javascripts/support/expect.MIT.LICENSE +0 -22
- data/vendor/assets/javascripts/support/jasmine-jquery.MIT.LICENSE +0 -20
- data/vendor/assets/javascripts/support/jasmine-jquery.js +0 -659
- data/vendor/assets/javascripts/support/sinon-chai.MIT-ISH.LICENSE +0 -13
- data/vendor/assets/javascripts/support/sinon.BSD.LICENSE +0 -27
@@ -0,0 +1,171 @@
|
|
1
|
+
module Teaspoon
|
2
|
+
module Formatters
|
3
|
+
|
4
|
+
# CONTRIBUTORS:
|
5
|
+
# If you add a formatter you should do the following before it will be considered for merging.
|
6
|
+
# - add it to this list so it can be autoloaded
|
7
|
+
# - write specs for it
|
8
|
+
# - add it to the readme so it's documented
|
9
|
+
# - add it to the list in command_line.rb so others know it's available
|
10
|
+
# - add it to the initializers in /lib/generators/install/templates so it's documented there as well
|
11
|
+
|
12
|
+
autoload :CleanFormatter, "teaspoon/formatters/clean_formatter"
|
13
|
+
autoload :DocumentationFormatter, "teaspoon/formatters/documentation_formatter"
|
14
|
+
autoload :DotFormatter, "teaspoon/formatters/dot_formatter"
|
15
|
+
autoload :JsonFormatter, "teaspoon/formatters/json_formatter"
|
16
|
+
autoload :JunitFormatter, "teaspoon/formatters/junit_formatter"
|
17
|
+
autoload :PrideFormatter, "teaspoon/formatters/pride_formatter"
|
18
|
+
autoload :SnowdayFormatter, "teaspoon/formatters/snowday_formatter"
|
19
|
+
autoload :SwayzeOrOprahFormatter, "teaspoon/formatters/swayze_or_oprah_formatter"
|
20
|
+
autoload :TapFormatter, "teaspoon/formatters/tap_formatter"
|
21
|
+
autoload :TapYFormatter, "teaspoon/formatters/tap_y_formatter"
|
22
|
+
autoload :TeamcityFormatter, "teaspoon/formatters/teamcity_formatter"
|
23
|
+
|
24
|
+
class Base
|
25
|
+
|
26
|
+
attr_accessor :total_count, :run_count, :passes, :pendings, :failures, :errors
|
27
|
+
|
28
|
+
def initialize(suite_name = :default, output_file = nil)
|
29
|
+
@suite_name = suite_name.to_s
|
30
|
+
@output_file = output_file
|
31
|
+
@stdout = ""
|
32
|
+
@suite = nil
|
33
|
+
@last_suite = nil
|
34
|
+
|
35
|
+
@total_count = 0
|
36
|
+
@run_count = 0
|
37
|
+
@passes = []
|
38
|
+
@pendings = []
|
39
|
+
@failures = []
|
40
|
+
@errors = []
|
41
|
+
File.open(@output_file, "w") { |f| f.write("") } if @output_file
|
42
|
+
end
|
43
|
+
|
44
|
+
# beginning of the run
|
45
|
+
def runner(result, log = true)
|
46
|
+
@total_count = result.total
|
47
|
+
log_runner(result) if log
|
48
|
+
end
|
49
|
+
|
50
|
+
# each suite, before any specs
|
51
|
+
def suite(result, log = true)
|
52
|
+
@suite = result
|
53
|
+
log_suite(result) if log
|
54
|
+
@last_suite = result
|
55
|
+
end
|
56
|
+
|
57
|
+
# each spec, after the spec has reported to the client runner
|
58
|
+
def spec(result, log = true)
|
59
|
+
@run_count += 1
|
60
|
+
if result.passing?
|
61
|
+
@passes << result
|
62
|
+
elsif result.pending?
|
63
|
+
@pendings << result
|
64
|
+
else
|
65
|
+
@failures << result
|
66
|
+
end
|
67
|
+
log_spec(result) if log
|
68
|
+
@stdout = ""
|
69
|
+
end
|
70
|
+
|
71
|
+
# errors are reported from the onError handler in phantomjs, so they're not linked to a result
|
72
|
+
def error(result, log = true)
|
73
|
+
@errors << result
|
74
|
+
log_error(result) if log
|
75
|
+
end
|
76
|
+
|
77
|
+
# exception came from startup errors in the server (will exit after logging)
|
78
|
+
def exception(result = {}, log = true)
|
79
|
+
log_exception(result) if log
|
80
|
+
end
|
81
|
+
|
82
|
+
# console message come from console.log/debug/error
|
83
|
+
def console(message, log = true)
|
84
|
+
@stdout << message
|
85
|
+
log_console(message) if log
|
86
|
+
end
|
87
|
+
|
88
|
+
# final report
|
89
|
+
def result(result, log = true)
|
90
|
+
log_result(result) if log
|
91
|
+
end
|
92
|
+
|
93
|
+
# called with the text versions of coverage if configured to do so
|
94
|
+
def coverage(message, log = true)
|
95
|
+
log_coverage(message) if log
|
96
|
+
end
|
97
|
+
|
98
|
+
# called with an array of strings which explain which coverage thresholds failed
|
99
|
+
def threshold_failure(message, log = true)
|
100
|
+
log_threshold_failure(message) if log
|
101
|
+
end
|
102
|
+
|
103
|
+
def complete(failure_count, log = true)
|
104
|
+
log_complete(failure_count) if log
|
105
|
+
end
|
106
|
+
|
107
|
+
protected
|
108
|
+
|
109
|
+
def log_runner(result); end
|
110
|
+
|
111
|
+
def log_suite(result); end
|
112
|
+
|
113
|
+
def log_spec(result)
|
114
|
+
return log_passing_spec(result) if result.passing?
|
115
|
+
return log_pending_spec(result) if result.pending?
|
116
|
+
log_failing_spec(result)
|
117
|
+
end
|
118
|
+
|
119
|
+
def log_passing_spec(result); end
|
120
|
+
|
121
|
+
def log_pending_spec(result); end
|
122
|
+
|
123
|
+
def log_failing_spec(result); end
|
124
|
+
|
125
|
+
def log_error(result); end
|
126
|
+
|
127
|
+
def log_exception(result); end
|
128
|
+
|
129
|
+
def log_console(message); end
|
130
|
+
|
131
|
+
def log_result(result); end
|
132
|
+
|
133
|
+
def log_coverage(message); end
|
134
|
+
|
135
|
+
def log_threshold_failure(message); end
|
136
|
+
|
137
|
+
def log_complete(failure_count); end
|
138
|
+
|
139
|
+
private
|
140
|
+
|
141
|
+
def log_str(str, color_code = nil)
|
142
|
+
return log_to_file(str, @output_file) if @output_file
|
143
|
+
STDOUT.print(color_code ? colorize(str, color_code) : str)
|
144
|
+
end
|
145
|
+
|
146
|
+
def log_line(str = "", color_code = nil)
|
147
|
+
return log_to_file("#{str}\n", @output_file) if @output_file
|
148
|
+
STDOUT.print("#{color_code ? colorize(str, color_code) : str}\n")
|
149
|
+
end
|
150
|
+
|
151
|
+
def log_to_file(str, output_file)
|
152
|
+
@_output_file = File.open(output_file, "a") { |f| f.write(str) }
|
153
|
+
rescue IOError => e
|
154
|
+
raise Teaspoon::FileNotWritable, e.message
|
155
|
+
end
|
156
|
+
|
157
|
+
def colorize(str, color_code)
|
158
|
+
return str unless Teaspoon.configuration.color || @output_file
|
159
|
+
"\e[#{color_code}m#{str}\e[0m"
|
160
|
+
end
|
161
|
+
|
162
|
+
def pluralize(str, value)
|
163
|
+
value == 1 ? "#{value} #{str}" : "#{value} #{str}s"
|
164
|
+
end
|
165
|
+
|
166
|
+
def filename(file)
|
167
|
+
file.gsub(%r(^http://127.0.0.1:\d+/assets/), "").gsub(/[\?|&]?body=1/, "")
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require "teaspoon/formatters/modules/report_module"
|
2
|
+
|
3
|
+
module Teaspoon
|
4
|
+
module Formatters
|
5
|
+
class DocumentationFormatter < Base
|
6
|
+
include ReportModule
|
7
|
+
|
8
|
+
protected
|
9
|
+
|
10
|
+
def initialize(*args)
|
11
|
+
@level = 0
|
12
|
+
super
|
13
|
+
end
|
14
|
+
|
15
|
+
def log_suite(result)
|
16
|
+
log_indent_line(result.label, result.level)
|
17
|
+
@level = result.level
|
18
|
+
end
|
19
|
+
|
20
|
+
def log_passing_spec(result)
|
21
|
+
log_indent_spec(result.label, GREEN)
|
22
|
+
end
|
23
|
+
|
24
|
+
def log_pending_spec(result)
|
25
|
+
log_indent_spec("#{result.label} (PENDING)", YELLOW)
|
26
|
+
end
|
27
|
+
|
28
|
+
def log_failing_spec(result)
|
29
|
+
log_indent_spec("#{result.label} (FAILED - #{@failures.length})", RED)
|
30
|
+
end
|
31
|
+
|
32
|
+
def log_result(result)
|
33
|
+
log_line
|
34
|
+
super
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def log_indent_spec(str, color)
|
40
|
+
log_indent_line(str, level = (@last_suite ? @level + 1 : 0), color)
|
41
|
+
log_intent_stdout(level + 1)
|
42
|
+
end
|
43
|
+
|
44
|
+
def log_intent_stdout(level)
|
45
|
+
return if @stdout.blank?
|
46
|
+
log_indent_line("# #{@stdout.gsub(/\n$/, "").gsub("\n", "\n# ")}", level, CYAN)
|
47
|
+
end
|
48
|
+
|
49
|
+
def log_indent_line(str = "", level = nil, color = nil)
|
50
|
+
log_line(indent(str, level || @level), color)
|
51
|
+
end
|
52
|
+
|
53
|
+
def indent(str = "", level = nil)
|
54
|
+
indent = "#{" " * level}"
|
55
|
+
str.gsub!("\n", "\n#{indent}")
|
56
|
+
"#{indent}#{str}"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -1,103 +1,25 @@
|
|
1
|
-
require
|
1
|
+
require "teaspoon/formatters/modules/report_module"
|
2
2
|
|
3
3
|
module Teaspoon
|
4
4
|
module Formatters
|
5
|
-
class DotFormatter <
|
6
|
-
|
7
|
-
RED = 31
|
8
|
-
GREEN = 32
|
9
|
-
YELLOW = 33
|
10
|
-
CYAN = 36
|
11
|
-
|
12
|
-
def spec(result, logged = false)
|
13
|
-
super(result)
|
14
|
-
return if logged
|
15
|
-
if result.passing?
|
16
|
-
log ".", GREEN
|
17
|
-
elsif result.pending?
|
18
|
-
log "*", YELLOW
|
19
|
-
else
|
20
|
-
log "F", RED
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
# Errors are reported from the onError handler in Phantom, so they're not linked to a result
|
25
|
-
def error(error)
|
26
|
-
log "#{error["message"]}\n", RED
|
27
|
-
for trace in error["trace"] || []
|
28
|
-
log " # #{filename(trace["file"])}:#{trace["line"]}#{trace["function"].present? ? " -- #{trace["function"]}" : ""}\n", CYAN
|
29
|
-
end
|
30
|
-
log "\n"
|
31
|
-
end
|
32
|
-
|
33
|
-
def result(results)
|
34
|
-
log "\n\n"
|
35
|
-
log_information
|
36
|
-
log_stats(results)
|
37
|
-
log_failed_examples
|
38
|
-
super
|
39
|
-
end
|
5
|
+
class DotFormatter < Base
|
6
|
+
include ReportModule
|
40
7
|
|
41
8
|
protected
|
42
9
|
|
43
|
-
def
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
def log_pending
|
49
|
-
log "Pending:\n"
|
50
|
-
pendings.each do |result|
|
51
|
-
log " #{result.description}\n", YELLOW
|
52
|
-
log " # Not yet implemented\n\n", CYAN
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def log_failures
|
57
|
-
log "Failures:\n\n"
|
58
|
-
failures.each_with_index do |failure, index|
|
59
|
-
log " #{index + 1}) #{failure.description}\n"
|
60
|
-
log " Failure/Error: #{failure.message}\n\n", RED
|
61
|
-
end
|
10
|
+
def log_spec(result)
|
11
|
+
return log_str(".", GREEN) if result.passing?
|
12
|
+
return log_str("*", YELLOW) if result.pending?
|
13
|
+
log_str("F", RED)
|
62
14
|
end
|
63
15
|
|
64
|
-
def
|
65
|
-
|
66
|
-
stats = "#{pluralize("example", total)}, #{pluralize("failure", failures.size)}"
|
67
|
-
stats << ", #{pendings.size} pending" if pendings.size > 0
|
68
|
-
log "#{stats}\n", stats_color
|
69
|
-
log "\n" unless failures.size == 0
|
16
|
+
def log_console(message)
|
17
|
+
log_str(message)
|
70
18
|
end
|
71
19
|
|
72
|
-
def
|
73
|
-
|
74
|
-
|
75
|
-
failures.each do |failure|
|
76
|
-
log "teaspoon -s #{@suite_name} --filter=\"#{failure.link}\"\n", RED
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
private
|
81
|
-
|
82
|
-
def log(str, color_code = nil)
|
83
|
-
STDOUT.print(color_code ? colorize(str, color_code) : str)
|
84
|
-
end
|
85
|
-
|
86
|
-
def colorize(str, color_code)
|
87
|
-
return str unless Teaspoon.configuration.color
|
88
|
-
"\e[#{color_code}m#{str}\e[0m"
|
89
|
-
end
|
90
|
-
|
91
|
-
def pluralize(str, value)
|
92
|
-
value == 1 ? "#{value} #{str}" : "#{value} #{str}s"
|
93
|
-
end
|
94
|
-
|
95
|
-
def stats_color
|
96
|
-
failures.size > 0 ? RED : pendings.size > 0 ? YELLOW : GREEN
|
97
|
-
end
|
98
|
-
|
99
|
-
def filename(file)
|
100
|
-
file.gsub(%r(^http://127.0.0.1:\d+/assets/), "").gsub(/[\?|&]?body=1/, "")
|
20
|
+
def log_result(result)
|
21
|
+
log_line("\n")
|
22
|
+
super
|
101
23
|
end
|
102
24
|
end
|
103
25
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Teaspoon
|
2
|
+
module Formatters
|
3
|
+
class JsonFormatter < Base
|
4
|
+
|
5
|
+
protected
|
6
|
+
|
7
|
+
def log_runner(result)
|
8
|
+
log_result(result)
|
9
|
+
end
|
10
|
+
|
11
|
+
def log_suite(result)
|
12
|
+
log_result(result)
|
13
|
+
end
|
14
|
+
|
15
|
+
def log_spec(result)
|
16
|
+
log_result(result)
|
17
|
+
end
|
18
|
+
|
19
|
+
def log_error(result)
|
20
|
+
log_result(result)
|
21
|
+
end
|
22
|
+
|
23
|
+
def log_exception(result)
|
24
|
+
log_result(result)
|
25
|
+
end
|
26
|
+
|
27
|
+
def log_console(message)
|
28
|
+
log_line(%Q{{"type":"console","log":"#{message.gsub(/\n$/, "").gsub("\n", "\\n")}"}})
|
29
|
+
end
|
30
|
+
|
31
|
+
def log_result(result)
|
32
|
+
log_str(result.original_json)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -1,59 +1,78 @@
|
|
1
|
-
require
|
1
|
+
require "cgi"
|
2
2
|
|
3
3
|
module Teaspoon
|
4
4
|
module Formatters
|
5
|
-
class JunitFormatter <
|
5
|
+
class JunitFormatter < Base
|
6
6
|
|
7
|
-
|
8
|
-
@count = result.total;
|
7
|
+
protected
|
9
8
|
|
10
|
-
|
11
|
-
|
9
|
+
def log_runner(result)
|
10
|
+
log_line(%Q{<?xml version="1.0" encoding="UTF-8"?>})
|
11
|
+
log_line(%Q{<testsuites name="Teaspoon">})
|
12
|
+
log_line(%Q{<testsuite name="#{@suite_name}" tests="#{@total_count}" time="#{result.start}">})
|
12
13
|
end
|
13
14
|
|
14
|
-
def
|
15
|
-
|
16
|
-
|
17
|
-
return passing_spec if result.passing?
|
18
|
-
return pending_spec if result.pending?
|
19
|
-
failing_spec
|
15
|
+
def log_suite(result)
|
16
|
+
log_end_suite
|
17
|
+
log_line(%Q{<testsuite name="#{result.label}">})
|
20
18
|
end
|
21
19
|
|
22
|
-
def
|
23
|
-
|
20
|
+
def log_passing_spec(result)
|
21
|
+
log_junit_spec(suite: result.suite, label: result.label)
|
24
22
|
end
|
25
23
|
|
26
|
-
def
|
27
|
-
|
24
|
+
def log_pending_spec(result)
|
25
|
+
log_junit_spec(suite: result.suite, label: result.label) do
|
26
|
+
log_line(%Q{ <skipped/>})
|
27
|
+
end
|
28
28
|
end
|
29
29
|
|
30
|
-
def
|
31
|
-
|
30
|
+
def log_failing_spec(result)
|
31
|
+
log_junit_spec(suite: result.suite, label: result.label) do
|
32
|
+
log_line(%Q{ <failure type="AssertionFailed">#{cdata(result.message)}</failure>})
|
33
|
+
end
|
32
34
|
end
|
33
35
|
|
34
|
-
|
36
|
+
def log_result(result)
|
37
|
+
log_end_suite
|
38
|
+
end
|
35
39
|
|
36
|
-
def
|
37
|
-
|
40
|
+
def log_coverage(message)
|
41
|
+
log_line(%Q{<testsuite name="Coverage summary" tests="0">\n<properties>#{cdata(message)}<properties>\n</testsuite>})
|
38
42
|
end
|
39
43
|
|
40
|
-
def
|
41
|
-
|
44
|
+
def log_threshold_failure(message)
|
45
|
+
log_line(%Q{<testsuite name="Coverage thresholds" tests="1">})
|
46
|
+
log_junit_spec(suite: "Coverage thresholds", label: "were not met") do
|
47
|
+
log_line(%Q{ <failure type="AssertionFailed">#{cdata(message)}</failure>})
|
48
|
+
end
|
49
|
+
log_line(%Q{</testsuite>})
|
42
50
|
end
|
43
51
|
|
44
|
-
def
|
45
|
-
|
46
|
-
<testcase classname="#{@result.suite}" name="#{@result.label}">
|
47
|
-
<failure type="AssertionFailed">#{@result.message}</failure>
|
48
|
-
</testcase>\n
|
49
|
-
EOL
|
50
|
-
log str
|
52
|
+
def log_complete(failure_count)
|
53
|
+
log_line(%Q{</testsuite>\n</testsuites>})
|
51
54
|
end
|
52
55
|
|
53
|
-
|
54
|
-
|
56
|
+
private
|
57
|
+
|
58
|
+
def log_end_suite
|
59
|
+
log_line(%Q{</testsuite>}) if @last_suite
|
55
60
|
end
|
56
61
|
|
62
|
+
def log_junit_spec(opts, &block)
|
63
|
+
log_line(%Q{<testcase classname="#{escape(opts[:suite])}" name="#{escape(opts[:label])}">})
|
64
|
+
yield if block_given?
|
65
|
+
log_line(%Q{<system-out>#{cdata(@stdout)}</system-out>}) unless @stdout.blank?
|
66
|
+
log_line(%Q{</testcase>})
|
67
|
+
end
|
68
|
+
|
69
|
+
def escape(str)
|
70
|
+
CGI::escapeHTML(str)
|
71
|
+
end
|
72
|
+
|
73
|
+
def cdata(str)
|
74
|
+
"\n<![CDATA[\n#{str.gsub(/\n$/, "")}\n]]>\n"
|
75
|
+
end
|
57
76
|
end
|
58
77
|
end
|
59
78
|
end
|