teaspoon 0.9.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (214) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +141 -0
  3. data/README.md +9 -19
  4. data/{vendor → app}/assets/javascripts/support/bind-poly.js +0 -0
  5. data/{vendor → app}/assets/javascripts/support/sinon.js +0 -0
  6. data/app/assets/javascripts/teaspoon-filterer.js +55 -0
  7. data/app/assets/javascripts/teaspoon/error.coffee +5 -0
  8. data/app/assets/javascripts/teaspoon/{base/fixture.coffee → fixture.coffee} +15 -15
  9. data/app/assets/javascripts/teaspoon/{base/hook.coffee → hook.coffee} +0 -0
  10. data/app/assets/javascripts/teaspoon/{base/reporters → reporters}/console.coffee +18 -10
  11. data/app/assets/javascripts/teaspoon/{base/reporters → reporters}/html.coffee +43 -40
  12. data/app/assets/javascripts/teaspoon/{base/reporters → reporters}/html/base_view.coffee +0 -0
  13. data/app/assets/javascripts/teaspoon/{base/reporters → reporters}/html/failure_view.coffee +2 -0
  14. data/app/assets/javascripts/teaspoon/reporters/html/progress_view.coffee +18 -0
  15. data/app/assets/javascripts/teaspoon/{base/reporters/html/progress_view.coffee → reporters/html/radial_progress_view.coffee} +1 -34
  16. data/app/assets/javascripts/teaspoon/reporters/html/simple_progress_view.coffee +15 -0
  17. data/app/assets/javascripts/teaspoon/{base/reporters → reporters}/html/spec_view.coffee +5 -3
  18. data/app/assets/javascripts/teaspoon/{base/reporters → reporters}/html/suite_view.coffee +4 -2
  19. data/app/assets/javascripts/teaspoon/{base/reporters → reporters}/html/template.coffee +0 -0
  20. data/app/assets/javascripts/teaspoon/{base/runner.coffee → runner.coffee} +7 -3
  21. data/app/assets/javascripts/teaspoon/teaspoon.coffee +90 -32
  22. data/app/controllers/teaspoon/suite_controller.rb +5 -0
  23. data/app/views/teaspoon/suite/index.html.erb +1 -1
  24. data/lib/generators/teaspoon/install/install_generator.rb +67 -37
  25. data/lib/generators/teaspoon/install/templates/MISSING_FRAMEWORK +14 -0
  26. data/lib/generators/teaspoon/install/{POST_INSTALL → templates/POST_INSTALL} +0 -0
  27. data/lib/generators/teaspoon/install/templates/env.rb.tt +14 -0
  28. data/lib/generators/teaspoon/install/templates/{jasmine/env_comments.rb.tt → env_comments.rb.tt} +34 -43
  29. data/lib/tasks/teaspoon/info.rake +17 -0
  30. data/lib/teaspoon-devkit.rb +61 -0
  31. data/lib/teaspoon.rb +2 -0
  32. data/lib/teaspoon/command_line.rb +19 -14
  33. data/lib/teaspoon/configuration.rb +24 -35
  34. data/lib/teaspoon/console.rb +11 -21
  35. data/lib/teaspoon/coverage.rb +14 -7
  36. data/lib/teaspoon/deprecated.rb +22 -4
  37. data/lib/teaspoon/driver.rb +15 -0
  38. data/lib/teaspoon/driver/base.rb +7 -0
  39. data/lib/teaspoon/{drivers/capybara_webkit_driver.rb → driver/capybara_webkit.rb} +8 -5
  40. data/lib/teaspoon/{drivers/phantomjs_driver.rb → driver/phantomjs.rb} +8 -4
  41. data/lib/teaspoon/{drivers → driver}/phantomjs/runner.js +0 -0
  42. data/lib/teaspoon/{drivers/selenium_driver.rb → driver/selenium.rb} +11 -9
  43. data/lib/teaspoon/engine.rb +38 -25
  44. data/lib/teaspoon/environment.rb +24 -15
  45. data/lib/teaspoon/exceptions.rb +154 -41
  46. data/lib/teaspoon/exporter.rb +2 -2
  47. data/lib/teaspoon/formatter.rb +30 -0
  48. data/lib/teaspoon/{formatters → formatter}/base.rb +2 -36
  49. data/lib/teaspoon/{formatters/clean_formatter.rb → formatter/clean.rb} +4 -2
  50. data/lib/teaspoon/{formatters/documentation_formatter.rb → formatter/documentation.rb} +4 -3
  51. data/lib/teaspoon/{formatters/dot_formatter.rb → formatter/dot.rb} +4 -3
  52. data/lib/teaspoon/{formatters/json_formatter.rb → formatter/json.rb} +4 -2
  53. data/lib/teaspoon/{formatters/junit_formatter.rb → formatter/junit.rb} +3 -2
  54. data/lib/teaspoon/{formatters → formatter}/modules/report_module.rb +1 -1
  55. data/lib/teaspoon/{formatters/pride_formatter.rb → formatter/pride.rb} +4 -2
  56. data/lib/teaspoon/{formatters/rspec_html_formatter.rb → formatter/rspec_html.rb} +3 -2
  57. data/lib/teaspoon/{formatters/snowday_formatter.rb → formatter/snowday.rb} +3 -2
  58. data/lib/teaspoon/formatter/swayze_or_oprah.rb +111 -0
  59. data/lib/teaspoon/{formatters/tap_formatter.rb → formatter/tap.rb} +4 -2
  60. data/lib/teaspoon/{formatters/tap_y_formatter.rb → formatter/tap_y.rb} +3 -2
  61. data/lib/teaspoon/{formatters/teamcity_formatter.rb → formatter/teamcity.rb} +4 -2
  62. data/lib/teaspoon/framework.rb +17 -0
  63. data/lib/teaspoon/framework/base.rb +88 -0
  64. data/lib/teaspoon/instrumentation.rb +12 -2
  65. data/lib/teaspoon/registry.rb +47 -0
  66. data/lib/teaspoon/registry/has_default.rb +11 -0
  67. data/lib/teaspoon/runner.rb +6 -7
  68. data/lib/teaspoon/server.rb +2 -2
  69. data/lib/teaspoon/suite.rb +28 -30
  70. data/lib/teaspoon/utility.rb +5 -0
  71. data/lib/teaspoon/version.rb +1 -1
  72. metadata +52 -276
  73. data/app/assets/javascripts/teaspoon-jasmine.js +0 -1344
  74. data/app/assets/javascripts/teaspoon-mocha.js +0 -1350
  75. data/app/assets/javascripts/teaspoon-qunit.js +0 -1415
  76. data/app/assets/javascripts/teaspoon-teaspoon.js +0 -51
  77. data/app/assets/javascripts/teaspoon/base/teaspoon.coffee +0 -69
  78. data/app/assets/javascripts/teaspoon/jasmine.coffee +0 -119
  79. data/app/assets/javascripts/teaspoon/jasmine/reporters/html.coffee +0 -11
  80. data/app/assets/javascripts/teaspoon/mocha.coffee +0 -90
  81. data/app/assets/javascripts/teaspoon/mocha/reporters/console.coffee +0 -16
  82. data/app/assets/javascripts/teaspoon/mocha/reporters/html.coffee +0 -27
  83. data/app/assets/javascripts/teaspoon/qunit.coffee +0 -81
  84. data/app/assets/javascripts/teaspoon/qunit/reporters/console.coffee +0 -25
  85. data/app/assets/javascripts/teaspoon/qunit/reporters/html.coffee +0 -80
  86. data/lib/generators/teaspoon/install/templates/jasmine/env.rb +0 -11
  87. data/lib/generators/teaspoon/install/templates/jasmine/spec_helper.coffee +0 -31
  88. data/lib/generators/teaspoon/install/templates/jasmine/spec_helper.js +0 -31
  89. data/lib/generators/teaspoon/install/templates/mocha/env.rb +0 -11
  90. data/lib/generators/teaspoon/install/templates/mocha/env_comments.rb.tt +0 -187
  91. data/lib/generators/teaspoon/install/templates/mocha/spec_helper.coffee +0 -40
  92. data/lib/generators/teaspoon/install/templates/mocha/spec_helper.js +0 -40
  93. data/lib/generators/teaspoon/install/templates/qunit/env.rb +0 -11
  94. data/lib/generators/teaspoon/install/templates/qunit/env_comments.rb.tt +0 -187
  95. data/lib/generators/teaspoon/install/templates/qunit/test_helper.coffee +0 -29
  96. data/lib/generators/teaspoon/install/templates/qunit/test_helper.js +0 -30
  97. data/lib/teaspoon/drivers/base.rb +0 -10
  98. data/lib/teaspoon/formatters/description.rb +0 -36
  99. data/lib/teaspoon/formatters/swayze_or_oprah_formatter.rb +0 -101
  100. data/spec/dummy/Rakefile +0 -7
  101. data/spec/dummy/app/assets/javascripts/instrumented1.coffee +0 -1
  102. data/spec/dummy/app/assets/javascripts/instrumented2.coffee +0 -1
  103. data/spec/dummy/app/assets/javascripts/integration/integration.coffee +0 -1
  104. data/spec/dummy/app/assets/javascripts/integration/integration_spec.coffee +0 -32
  105. data/spec/dummy/app/assets/javascripts/integration/spec_helper.coffee +0 -7
  106. data/spec/dummy/app/assets/javascripts/specs/asset_spec.js +0 -11
  107. data/spec/dummy/config.ru +0 -15
  108. data/spec/dummy/config/application.rb +0 -29
  109. data/spec/dummy/config/boot.rb +0 -3
  110. data/spec/dummy/config/environment.rb +0 -5
  111. data/spec/dummy/config/environments/development.rb +0 -41
  112. data/spec/dummy/config/environments/production.rb +0 -79
  113. data/spec/dummy/config/environments/test.rb +0 -42
  114. data/spec/dummy/config/routes.rb +0 -2
  115. data/spec/dummy/config/secrets.yml +0 -22
  116. data/spec/dummy/log/.gitkeep +0 -0
  117. data/spec/dummy/public/favicon.ico +0 -0
  118. data/spec/dummy/script/rails +0 -6
  119. data/spec/features/console_reporter_spec.rb +0 -62
  120. data/spec/features/hooks_spec.rb +0 -60
  121. data/spec/features/html_reporter_spec.rb +0 -81
  122. data/spec/features/install_generator_spec.rb +0 -54
  123. data/spec/features/instrumentation_spec.rb +0 -21
  124. data/spec/fixtures/coverage.json +0 -243
  125. data/spec/javascripts/fixtures/_body.html.erb +0 -1
  126. data/spec/javascripts/fixtures/fixture.html.haml +0 -4
  127. data/spec/javascripts/fixtures/fixture.json +0 -4
  128. data/spec/javascripts/jasmine_helper.coffee +0 -3
  129. data/spec/javascripts/mocha_helper.coffee +0 -4
  130. data/spec/javascripts/spec_helper.coffee +0 -7
  131. data/spec/javascripts/stylesheets/stylesheet.css.scss +0 -0
  132. data/spec/javascripts/support/json2.js +0 -486
  133. data/spec/javascripts/support/support.js.coffee +0 -0
  134. data/spec/javascripts/teaspoon/base/fixture_spec.coffee +0 -93
  135. data/spec/javascripts/teaspoon/base/reporters/console_spec.coffee +0 -162
  136. data/spec/javascripts/teaspoon/base/reporters/html/base_view_spec.coffee +0 -88
  137. data/spec/javascripts/teaspoon/base/reporters/html/failure_view_spec.coffee +0 -28
  138. data/spec/javascripts/teaspoon/base/reporters/html/progress_view_spec.coffee +0 -1
  139. data/spec/javascripts/teaspoon/base/reporters/html/spec_view_spec.coffee +0 -1
  140. data/spec/javascripts/teaspoon/base/reporters/html/suite_view_spec.coffee +0 -1
  141. data/spec/javascripts/teaspoon/base/reporters/html_spec.coffee +0 -372
  142. data/spec/javascripts/teaspoon/base/runner_spec.coffee +0 -58
  143. data/spec/javascripts/teaspoon/base/teaspoon_spec.coffee +0 -47
  144. data/spec/javascripts/teaspoon/jasmine/fixture_jspec.coffee +0 -13
  145. data/spec/javascripts/teaspoon/jasmine/models_jspec.coffee +0 -101
  146. data/spec/javascripts/teaspoon/jasmine/reporters/html_jspec.coffee +0 -17
  147. data/spec/javascripts/teaspoon/jasmine/runner_jspec.coffee +0 -59
  148. data/spec/javascripts/teaspoon/jasmine/spec_jspec.coffee +0 -3
  149. data/spec/javascripts/teaspoon/mocha/fixture_mspec.coffee +0 -12
  150. data/spec/javascripts/teaspoon/mocha/models_mspec.coffee +0 -93
  151. data/spec/javascripts/teaspoon/mocha/reporters/console_mspec.coffee +0 -24
  152. data/spec/javascripts/teaspoon/mocha/reporters/html_mspec.coffee +0 -41
  153. data/spec/javascripts/teaspoon/mocha/runner_mspec.coffee +0 -23
  154. data/spec/javascripts/teaspoon/mocha/spec_mspec.coffee +0 -9
  155. data/spec/javascripts/teaspoon/other/erb_spec.js.coffee.erb +0 -4
  156. data/spec/javascripts/teaspoon/phantomjs/runner_spec.coffee +0 -161
  157. data/spec/javascripts/turbolinks_helper.coffee +0 -2
  158. data/spec/spec_helper.rb +0 -25
  159. data/spec/support/aruba.rb +0 -15
  160. data/spec/teaspoon/command_line_spec.rb +0 -157
  161. data/spec/teaspoon/configuration_spec.rb +0 -236
  162. data/spec/teaspoon/console_spec.rb +0 -224
  163. data/spec/teaspoon/coverage_spec.rb +0 -118
  164. data/spec/teaspoon/drivers/base_spec.rb +0 -5
  165. data/spec/teaspoon/drivers/capybara_webkit_driver_spec.rb +0 -39
  166. data/spec/teaspoon/drivers/phantomjs_driver_spec.rb +0 -66
  167. data/spec/teaspoon/drivers/selenium_driver_spec.rb +0 -68
  168. data/spec/teaspoon/engine_spec.rb +0 -22
  169. data/spec/teaspoon/environment_spec.rb +0 -109
  170. data/spec/teaspoon/exceptions_spec.rb +0 -57
  171. data/spec/teaspoon/exporter_spec.rb +0 -96
  172. data/spec/teaspoon/formatters/base_spec.rb +0 -259
  173. data/spec/teaspoon/formatters/clean_formatter_spec.rb +0 -37
  174. data/spec/teaspoon/formatters/documentation_formatter_spec.rb +0 -127
  175. data/spec/teaspoon/formatters/dot_formatter_spec.rb +0 -116
  176. data/spec/teaspoon/formatters/json_formatter_spec.rb +0 -77
  177. data/spec/teaspoon/formatters/junit_formatter_spec.rb +0 -114
  178. data/spec/teaspoon/formatters/pride_formatter_spec.rb +0 -37
  179. data/spec/teaspoon/formatters/rspec_html_formatter_spec.rb +0 -107
  180. data/spec/teaspoon/formatters/snowday_formatter_spec.rb +0 -35
  181. data/spec/teaspoon/formatters/tap_formatter_spec.rb +0 -72
  182. data/spec/teaspoon/formatters/tap_y_formatter_spec.rb +0 -80
  183. data/spec/teaspoon/formatters/teamcity_formatter_spec.rb +0 -148
  184. data/spec/teaspoon/instrumentation_spec.rb +0 -113
  185. data/spec/teaspoon/result_spec.rb +0 -98
  186. data/spec/teaspoon/runner_spec.rb +0 -116
  187. data/spec/teaspoon/server_spec.rb +0 -105
  188. data/spec/teaspoon/suite_spec.rb +0 -138
  189. data/spec/teaspoon_env.rb +0 -39
  190. data/test/javascripts/qunit_helper.coffee +0 -3
  191. data/test/javascripts/teaspoon/qunit/fixture_test.coffee +0 -10
  192. data/test/javascripts/teaspoon/qunit/models_test.coffee +0 -66
  193. data/test/javascripts/teaspoon/qunit/reporters/console_test.coffee +0 -3
  194. data/test/javascripts/teaspoon/qunit/reporters/html/failure_view_test.coffee +0 -3
  195. data/test/javascripts/teaspoon/qunit/reporters/html/spec_view_test.coffee +0 -3
  196. data/test/javascripts/teaspoon/qunit/reporters/html/suite_view_test.coffee +0 -3
  197. data/test/javascripts/teaspoon/qunit/reporters/html_test.coffee +0 -3
  198. data/test/javascripts/teaspoon/qunit/runner_test.coffee +0 -18
  199. data/vendor/assets/javascripts/jasmine/1.3.1.js +0 -2602
  200. data/vendor/assets/javascripts/jasmine/2.0.0.js +0 -2412
  201. data/vendor/assets/javascripts/jasmine/MIT.LICENSE +0 -20
  202. data/vendor/assets/javascripts/mocha/1.10.0.js +0 -5374
  203. data/vendor/assets/javascripts/mocha/1.17.1.js +0 -5813
  204. data/vendor/assets/javascripts/mocha/MIT.LICENSE +0 -22
  205. data/vendor/assets/javascripts/qunit/1.12.0.js +0 -2212
  206. data/vendor/assets/javascripts/qunit/1.14.0.js +0 -2288
  207. data/vendor/assets/javascripts/qunit/MIT.LICENSE +0 -21
  208. data/vendor/assets/javascripts/support/chai-1.10.0.js +0 -4800
  209. data/vendor/assets/javascripts/support/chai-jq-0.0.7.js +0 -524
  210. data/vendor/assets/javascripts/support/chai.js +0 -4782
  211. data/vendor/assets/javascripts/support/expect.js +0 -1284
  212. data/vendor/assets/javascripts/support/jasmine-jquery-1.7.0.js +0 -720
  213. data/vendor/assets/javascripts/support/jasmine-jquery-2.0.0.js +0 -812
  214. data/vendor/assets/javascripts/support/sinon-chai.js +0 -126
@@ -1,46 +1,159 @@
1
1
  module Teaspoon
2
- class Error < Exception; end
3
- class EnvironmentNotFound < Teaspoon::Error; end
4
- class MissingDependency < Teaspoon::Error; end
5
- class ServerException < Teaspoon::Error; end
6
- class RunnerException < Teaspoon::Error; end
7
- class ExporterException < Teaspoon::Error; end
8
- class UnknownFramework < Teaspoon::Error; end
9
- class UnknownCoverage < Teaspoon::Error; end
10
- class UnknownDriver < Teaspoon::Error; end
11
- class UnknownDriverOptions < Teaspoon::Error; end
12
- class UnknownFormatter < Teaspoon::Error; end
13
- class UnknownSuite < Teaspoon::Error; end
14
- class AssetNotServable < Teaspoon::Error; end
15
- class Failure < Teaspoon::Error; end
16
- class DependencyFailure < Teaspoon::Error; end
17
- class ThresholdNotMet < Teaspoon::Error; end
18
- class FileNotWritable < Teaspoon::Error; end
19
-
20
- module ExceptionHandling
21
- def self.add_rails_handling
22
- return unless Teaspoon.configuration.driver == "phantomjs"
23
-
24
- # debugging should be off to display errors in the suite_controller
25
- # Rails.application.config.assets.debug = false
26
-
27
- # we want rails to display exceptions
28
- Rails.application.config.action_dispatch.show_exceptions = true
29
-
30
- # override the render exception method in ActionDispatch to raise a javascript exception
31
- render_exceptions_with_javascript
32
- end
33
-
34
- private
35
-
36
- def self.render_exceptions_with_javascript
37
- ActionDispatch::DebugExceptions.class_eval do
38
- def render_exception(_env, exception)
39
- message = "#{exception.class.name}: #{exception.message}"
40
- body = "<script>throw Error(#{[message, exception.backtrace].join("\n").inspect})</script>"
41
- [200, { "Content-Type" => "text/html;", "Content-Length" => body.bytesize.to_s }, [body]]
42
- end
2
+ class Error < StandardError
3
+ end
4
+
5
+ class Failure < Teaspoon::Error
6
+ end
7
+
8
+ class EnvironmentNotFound < Teaspoon::Error
9
+ def initialize(msg = nil, searched:)
10
+ msg ||= "Unable to locate environment; searched in [#{searched}]. Have you run the installer?"
11
+ super(msg)
12
+ end
13
+ end
14
+
15
+ # loading / configuration errors
16
+
17
+ class UnknownFramework < Teaspoon::Error
18
+ def initialize(msg = nil, name:, available:)
19
+ msg ||= "Unknown framework: expected \"#{name}\" to be a registered framework. Available frameworks are #{available}."
20
+ if available.blank?
21
+ msg += " Do you need to update your Gemfile to use the teaspoon-#{name} gem? If you are upgrading, please see https://github.com/modeset/teaspoon/blob/master/CHANGELOG.md"
43
22
  end
23
+ super(msg)
24
+ end
25
+
26
+ def available
27
+ end
28
+ end
29
+
30
+ class UnknownFrameworkVersion < Teaspoon::Error
31
+ def initialize(msg = nil, name:, version:)
32
+ msg ||= "Unknown framework version: expected \"#{name}\" to have version #{version}."
33
+ super(msg)
34
+ end
35
+
36
+ def available
37
+ end
38
+ end
39
+
40
+ class UnknownDriver < Teaspoon::Error
41
+ def initialize(msg = nil, name:, available:)
42
+ msg ||= "Unknown driver: expected \"#{name}\" to be a registered driver. Available drivers are #{available}"
43
+ super(msg)
44
+ end
45
+
46
+ def available
47
+ end
48
+ end
49
+
50
+ class UnknownFormatter < Teaspoon::Error
51
+ def initialize(msg = nil, name:, available:)
52
+ msg ||= "Unknown formatter: expected \"#{name}\" to be a registered formatter. Available formatters are #{available}"
53
+ super(msg)
54
+ end
55
+
56
+ def available
57
+ end
58
+ end
59
+
60
+ class UnspecifiedFramework < Teaspoon::Error
61
+ def initialize(msg = nil, name:)
62
+ msg ||= "Missing framework: expected \"#{name}\" suite to configure one using `suite.use_framework`."
63
+ super(msg)
64
+ end
65
+
66
+ def available
67
+ end
68
+ end
69
+
70
+ class UnspecifiedDependencies < Teaspoon::Error
71
+ def initialize(msg = nil, framework:, version:)
72
+ msg ||= "Missing dependencies: expected framework \"#{framework}\" (#{version}) to specify the `dependencies` option when registering."
73
+ super(msg)
74
+ end
75
+
76
+ def available
77
+ end
78
+ end
79
+
80
+ class UnknownSuite < Teaspoon::Error
81
+ def initialize(msg = nil, name:)
82
+ msg ||= "Unknown suite configuration: expected \"#{name}\" to be a configured suite."
83
+ super(msg)
84
+ end
85
+
86
+ def available
87
+ end
88
+ end
89
+
90
+ class UnknownCoverage < Teaspoon::Error
91
+ def initialize(msg = nil, name:)
92
+ msg ||= "Unknown coverage configuration: expected \"#{name}\" to be a configured coverage."
93
+ super(msg)
94
+ end
95
+
96
+ def available
97
+ end
98
+ end
99
+
100
+ class NotFoundInRegistry < Teaspoon::Error
101
+ def initialize(msg = nil, name:, available:)
102
+ msg ||= "Unknown configuration: expected \"#{name}\" to be registered. Available options are #{available}"
103
+ super(msg)
104
+ end
105
+
106
+ def available
107
+ end
108
+ end
109
+
110
+ # general running errors
111
+
112
+ class RunnerError < Teaspoon::Error
113
+ end
114
+
115
+ class FileWriteError < Teaspoon::Error
116
+ end
117
+
118
+ class MissingDependencyError < Teaspoon::Error
119
+ def initialize(msg = nil)
120
+ msg ||= "Unable to locate a required external dependency."
121
+ super(msg)
122
+ end
123
+ end
124
+
125
+ class DependencyError < Teaspoon::Error
126
+ def initialize(msg = nil)
127
+ msg ||= "Problem calling out to an external dependency."
128
+ super(msg)
129
+ end
130
+ end
131
+
132
+ class ServerError < Teaspoon::Error
133
+ def initialize(msg = nil, desc: nil)
134
+ msg ||= "Unable to start teaspoon server; #{desc || 'for an unknown reason'}."
135
+ super(msg)
136
+ end
137
+ end
138
+
139
+ class DriverOptionsError < Teaspoon::Error
140
+ def initialize(msg = nil, types: nil)
141
+ msg ||= "Malformed driver options#{types ? ": expected a valid #{types}." : '.'}"
142
+ super(msg)
143
+ end
144
+ end
145
+
146
+ class AssetNotServableError < Teaspoon::Error
147
+ def initialize(msg = nil, filename: nil)
148
+ msg ||= "Unable to serve asset: expected \"#{filename || 'unknown file'}\" to be within a registered asset path."
149
+ super(msg)
150
+ end
151
+ end
152
+
153
+ class IstanbulNotFoundError < Teaspoon::Error
154
+ def initialize(msg = nil)
155
+ msg ||= "You requested coverage reports, but Teaspoon cannot find the istanbul binary. Run: npm install -g istanbul"
156
+ super(msg)
44
157
  end
45
158
  end
46
159
  end
@@ -12,7 +12,7 @@ module Teaspoon
12
12
  Dir.mktmpdir do |temp_path|
13
13
  Dir.chdir(temp_path) do
14
14
  %x{#{executable} --convert-links --adjust-extension --page-requisites --span-hosts #{@url.shellescape} 2>&1}
15
- raise Teaspoon::ExporterException, "Unable to export #{@suite} suite." unless $?.exitstatus == 0
15
+ raise Teaspoon::DependencyError.new("Unable to export #{@suite} suite.") unless $?.exitstatus == 0
16
16
  create_export(File.join(temp_path, @url.match(/^http:\/\/([^\/]+).*/)[1]))
17
17
  end
18
18
  end
@@ -24,7 +24,7 @@ module Teaspoon
24
24
  return @executable if @executable
25
25
  @executable = which("wget")
26
26
  return @executable unless @executable.blank?
27
- raise Teaspoon::MissingDependency, "Could not find wget for exporting."
27
+ raise Teaspoon::MissingDependencyError.new("Unable to locate `wget` for exporter.")
28
28
  end
29
29
 
30
30
  def create_export(path)
@@ -0,0 +1,30 @@
1
+ require "teaspoon/registry"
2
+ require "teaspoon/registry/has_default"
3
+
4
+ module Teaspoon
5
+ module Formatter
6
+ extend Teaspoon::Registry
7
+ extend Teaspoon::Registry::HasDefault
8
+
9
+ not_found_in_registry Teaspoon::UnknownFormatter
10
+ end
11
+ end
12
+
13
+ # CONTRIBUTORS:
14
+ # If you add a formatter you should do the following before it will be considered for merging.
15
+ # - add it to this list so it can be autoloaded
16
+ # - write specs for it
17
+ # - add it to the readme so it's documented
18
+
19
+ Teaspoon::Formatter.register(:dot, "Teaspoon::Formatter::Dot", "teaspoon/formatter/dot", description: "dots", default: true)
20
+ Teaspoon::Formatter.register(:clean, "Teaspoon::Formatter::Clean", "teaspoon/formatter/clean", description: "like dots but doesn't log re-run commands")
21
+ Teaspoon::Formatter.register(:documentation, "Teaspoon::Formatter::Documentation", "teaspoon/formatter/documentation", description: "descriptive documentation")
22
+ Teaspoon::Formatter.register(:json, "Teaspoon::Formatter::Json", "teaspoon/formatter/json", description: "json formatter (raw teaspoon)")
23
+ Teaspoon::Formatter.register(:junit, "Teaspoon::Formatter::Junit", "teaspoon/formatter/junit", description: "junit compatible formatter")
24
+ Teaspoon::Formatter.register(:pride, "Teaspoon::Formatter::Pride", "teaspoon/formatter/pride", description: "yay rainbows!")
25
+ Teaspoon::Formatter.register(:rspec_html, "Teaspoon::Formatter::RspecHtml", "teaspoon/formatter/rspec_html", description: "RSpec inspired HTML format")
26
+ Teaspoon::Formatter.register(:snowday, "Teaspoon::Formatter::Snowday", "teaspoon/formatter/snowday", description: "makes you feel all warm inside")
27
+ Teaspoon::Formatter.register(:swayze_or_oprah, "Teaspoon::Formatter::SwayzeOrOprah", "teaspoon/formatter/swayze_or_oprah", description: "quote from either Patrick Swayze or Oprah Winfrey")
28
+ Teaspoon::Formatter.register(:tap, "Teaspoon::Formatter::Tap", "teaspoon/formatter/tap", description: "test anything protocol formatter")
29
+ Teaspoon::Formatter.register(:tap_y, "Teaspoon::Formatter::TapY", "teaspoon/formatter/tap_y", description: "tap_yaml, format used by tapout")
30
+ Teaspoon::Formatter.register(:teamcity, "Teaspoon::Formatter::Teamcity", "teaspoon/formatter/teamcity", description: "teamcity compatible formatter")
@@ -1,39 +1,5 @@
1
- require "set"
2
- require "teaspoon/formatters/description"
3
-
4
1
  module Teaspoon
5
- module Formatters
6
- @@known_formatters = SortedSet.new
7
-
8
- def self.known_formatters
9
- @@known_formatters
10
- end
11
-
12
- def self.register(name, details)
13
- description = Description.new(name, details)
14
- @@known_formatters << description
15
- autoload description.class_name, description.require_path
16
- end
17
-
18
- # CONTRIBUTORS:
19
- # If you add a formatter you should do the following before it will be considered for merging.
20
- # - add it to this list so it can be autoloaded
21
- # - write specs for it
22
- # - add it to the readme so it's documented
23
-
24
- register :clean, description: "like dots but doesn't log re-run commands"
25
- register :documentation, description: "descriptive documentation"
26
- register :dot, description: "dots", default: true
27
- register :json, description: "json formatter (raw teaspoon)"
28
- register :junit, description: "junit compatible formatter"
29
- register :pride, description: "yay rainbows!"
30
- register :rspec_html, description: "RSpec inspired HTML format"
31
- register :snowday, description: "makes you feel warm inside"
32
- register :swayze_or_oprah, description: "quote from either Patrick Swayze or Oprah Winfrey"
33
- register :tap, description: "test anything protocol formatter"
34
- register :tap_y, description: "tap_yaml, format used by tapout"
35
- register :teamcity, description: "teamcity compatible formatter"
36
-
2
+ module Formatter
37
3
  class Base
38
4
  attr_accessor :total_count, :run_count, :passes, :pendings, :failures, :errors
39
5
 
@@ -163,7 +129,7 @@ module Teaspoon
163
129
  def log_to_file(str, output_file)
164
130
  @_output_file = File.open(output_file, "a") { |f| f.write(str) }
165
131
  rescue IOError => e
166
- raise Teaspoon::FileNotWritable, e.message
132
+ raise Teaspoon::FileWriteError.new(e.message)
167
133
  end
168
134
 
169
135
  def colorize(str, color_code)
@@ -1,6 +1,8 @@
1
+ require "teaspoon/formatter/dot"
2
+
1
3
  module Teaspoon
2
- module Formatters
3
- class CleanFormatter < DotFormatter
4
+ module Formatter
5
+ class Clean < Dot
4
6
  private
5
7
 
6
8
  def log_failed_examples
@@ -1,8 +1,9 @@
1
- require "teaspoon/formatters/modules/report_module"
1
+ require "teaspoon/formatter/base"
2
+ require "teaspoon/formatter/modules/report_module"
2
3
 
3
4
  module Teaspoon
4
- module Formatters
5
- class DocumentationFormatter < Base
5
+ module Formatter
6
+ class Documentation < Base
6
7
  include ReportModule
7
8
 
8
9
  protected
@@ -1,8 +1,9 @@
1
- require "teaspoon/formatters/modules/report_module"
1
+ require "teaspoon/formatter/base"
2
+ require "teaspoon/formatter/modules/report_module"
2
3
 
3
4
  module Teaspoon
4
- module Formatters
5
- class DotFormatter < Base
5
+ module Formatter
6
+ class Dot < Base
6
7
  include ReportModule
7
8
 
8
9
  protected
@@ -1,6 +1,8 @@
1
+ require "teaspoon/formatter/base"
2
+
1
3
  module Teaspoon
2
- module Formatters
3
- class JsonFormatter < Base
4
+ module Formatter
5
+ class Json < Base
4
6
  protected
5
7
 
6
8
  def log_runner(result)
@@ -1,8 +1,9 @@
1
+ require "teaspoon/formatter/base"
1
2
  require "cgi"
2
3
 
3
4
  module Teaspoon
4
- module Formatters
5
- class JunitFormatter < Base
5
+ module Formatter
6
+ class Junit < Base
6
7
  protected
7
8
 
8
9
  def log_runner(result)
@@ -1,5 +1,5 @@
1
1
  module Teaspoon
2
- module Formatters
2
+ module Formatter
3
3
  module ReportModule
4
4
  RED = 31
5
5
  GREEN = 32
@@ -1,6 +1,8 @@
1
+ require "teaspoon/formatter/dot"
2
+
1
3
  module Teaspoon
2
- module Formatters
3
- class PrideFormatter < DotFormatter
4
+ module Formatter
5
+ class Pride < Dot
4
6
  PI_3 = Math::PI / 3
5
7
 
6
8
  def initialize(*args)
@@ -1,8 +1,9 @@
1
1
  require "erb"
2
+ require "teaspoon/formatter/base"
2
3
 
3
4
  module Teaspoon
4
- module Formatters
5
- class RspecHtmlFormatter < Base
5
+ module Formatter
6
+ class RspecHtml < Base
6
7
  def initialize(*args)
7
8
  super
8
9
  @suite_start_template = template Templates::SUITE_START
@@ -1,8 +1,9 @@
1
1
  # encoding: utf-8
2
+ require "teaspoon/formatter/dot"
2
3
 
3
4
  module Teaspoon
4
- module Formatters
5
- class SnowdayFormatter < DotFormatter
5
+ module Formatter
6
+ class Snowday < Dot
6
7
  protected
7
8
 
8
9
  def log_spec(result)
@@ -0,0 +1,111 @@
1
+ require "teaspoon/formatter/base"
2
+
3
+ module Teaspoon
4
+ module Formatter
5
+ class SwayzeOrOprah < Base
6
+ protected
7
+
8
+ def log_result(_result)
9
+ return log_str("\nNo quote for you.") if failures.size > 0
10
+ names, quote = random_quote
11
+ log_line("\n#{quote.inspect} -- Oprah Winfrey or Patrick Swayze?")
12
+ process_response(names)
13
+ end
14
+
15
+ private
16
+
17
+ DATA = [
18
+ {
19
+ author: ["patrick swayze", "patrick", "swayze", "ps", "p"],
20
+ quotes: <<-QUOTES.strip_heredoc.split("|").strip
21
+ When those you love die, the best you can do is honor their spirit for as long as you live. You make a \
22
+ commitment that you're going to take whatever lesson that person or animal was trying to teach you, and \
23
+ you make it true in your own life... it's a positive way to keep their spirit alive in the world, by \
24
+ keeping it alive in yourself.|The way to screw up somebody's life is to give them what they want. There's \
25
+ just something about dance ... It's like a primal thing in all of us.|Pain don't hurt.|What winning is to \
26
+ me is not giving up, is no matter what's thrown at me, I can take it. And I can keep going.|Good-looking \
27
+ people turn me off. Myself included.|One thing I'm not going to do is chase staying alive. You spend so \
28
+ much time chasing staying alive, you won't live.|The way to screw up somebody's life is to give them what \
29
+ they want.|There's just something about dance. It's like a primal thing in all of us.|As always, I \
30
+ appreciate all the love and support people have sent and continue to send my way.|Everything is designed \
31
+ to help you sell out.|How do you nurture a positive attitude when all the statistics say you're a dead \
32
+ man? You go to work.|I am very, very clear on how difficult it is for a young kid out there to go into the \
33
+ arts without taking a lot of heat from his peers.|I don't know how many hills and valleys I've had, how \
34
+ many times I've had to refocus my world and my life and my career. I don't know what's on the other \
35
+ side.|I don't want to be a poster child for cancer.|I don't want to be Mr. Romantic Leading Man. I don't \
36
+ want to be the Dance Dude. I don't want to be the Action Guy. If I had to do any one of those all my life, \
37
+ it'd drive me crazy.|I dropped about 20 pounds in the blink of an eye. And then when you see it in the \
38
+ mirror, when all of a sudden you pull your eyes down, and the bottom of your eyes go yellow and jaundice \
39
+ sets in - then you know something's wrong.|I got completely fed up with that Hollywood blockbuster \
40
+ mentality. I couldn't take it seriously any longer.|I had a lot of anger because I wasn't happy with the \
41
+ way I had been raised.|I just love to work hard.|I keep dreaming of a future, a future with a long and \
42
+ healthy life, not lived in the shadow of cancer but in the light.|I keep my heart and my soul and my \
43
+ spirit open to miracles.|I like to believe that I've got a lot of guardian warriors sittin' on my shoulder \
44
+ including my dad.|I took after my father.|I wanna live.|I will go so far as to say probably smoking had \
45
+ something to do with my pancreatic cancer.|I'm trying to shut up and let my angels speak to me and tell me \
46
+ what I'm supposed to do.|I've had so many injuries.
47
+ QUOTES
48
+ },
49
+
50
+ {
51
+ author: ["oprah winfrey", "oprah", "winfrey", "ow", "o"],
52
+ quotes: <<-QUOTES.strip_heredoc.split("|").strip
53
+ Lots of people want to ride with you in the limo, but what you want is someone who will take the bus with \
54
+ you when the limo breaks down.|Be thankful for what you have; you'll end up having more. If you \
55
+ concentrate on what you don't have, you will never, ever have enough.|The more you praise and celebrate \
56
+ your life, the more there is in life to celebrate.|Surround yourself with only people who are going to \
57
+ lift you higher.|Breathe. Let go. And remind yourself that this very moment is the only one you know you \
58
+ have for sure.|As you become more clear about who you really are, you'll be better able to decide what is \
59
+ best for you - the first time around.|It isn't until you come to a spiritual understanding of who you are \
60
+ - not necessarily a religious feeling, but deep down, the spirit within - that you can begin to take \
61
+ control.|I am a woman in process. I'm just trying like everybody else. I try to take every conflict, every \
62
+ experience, and learn from it. Life is never dull.|Turn your wounds into wisdom.|Doing the best at this \
63
+ moment puts you in the best place for the next moment.|Where there is no struggle, there is no \
64
+ strength.|Do the one thing you think you cannot do. Fail at it. Try again. Do better the second time. The \
65
+ only people who never tumble are those who never mount the high wire. This is your moment. Own it.|Passion \
66
+ is energy. Feel the power that comes from focusing on what excites you.|I don't think of myself as a poor \
67
+ deprived ghetto girl who made good. I think of myself as somebody who from an early age knew I was \
68
+ responsible for myself, and I had to make good.|Think like a queen. A queen is not afraid to fail. Failure \
69
+ is another steppingstone to greatness.|I believe that every single event in life happens in an opportunity \
70
+ to choose love over fear.|The greatest discovery of all time is that a person can change his future by \
71
+ merely changing his attitude.|I don't believe in failure. It is not failure if you enjoyed the process.|I \
72
+ don't think you ever stop giving. I really don't. I think it's an on-going process. And it's not just \
73
+ about being able to write a check. It's being able to touch somebody's life.|The struggle of my life \
74
+ created empathy - I could relate to pain, being abandoned, having people not love me.|What material \
75
+ success does is provide you with the ability to concentrate on other things that really matter. And that \
76
+ is being able to make a difference, not only in your own life, but in other people's lives.|Books were my \
77
+ pass to personal freedom. I learned to read at age three, and soon discovered there was a whole world to \
78
+ conquer that went beyond our farm in Mississippi.|Biology is the least of what makes someone a \
79
+ mother.|Real integrity is doing the right thing, knowing that nobody's going to know whether you did it or \
80
+ not.|I have a lot of things to prove to myself. One is that I can live my life fearlessly.
81
+ QUOTES
82
+ }
83
+ ]
84
+
85
+ def process_response(names)
86
+ log_str("Will your run be successful? [swayze or oprah]: ")
87
+ if names.include?(gets.chomp)
88
+ log_line("\nYou got it right!\n")
89
+ else
90
+ log_line("\nWrong, too bad!\n")
91
+ raise the roof, YO && "Let's get busy"
92
+ end
93
+ end
94
+
95
+ def random_quote
96
+ set = DATA[rand(DATA.size)]
97
+ [set[:author], set[:quotes][rand(set[:quotes].size)]]
98
+ end
99
+
100
+ def the(*_)
101
+ Exception.new("poorly answered question")
102
+ end
103
+
104
+ def roof
105
+ 0
106
+ end
107
+
108
+ YO = 0
109
+ end
110
+ end
111
+ end