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,3 +1,5 @@
1
+ #= require teaspoon/reporters/html/base_view
2
+
1
3
  class Teaspoon.Reporters.HTML.FailureView extends Teaspoon.Reporters.BaseView
2
4
 
3
5
  constructor: (@spec) ->
@@ -0,0 +1,18 @@
1
+ #= require teaspoon/reporters/html/base_view
2
+
3
+ class Teaspoon.Reporters.HTML.ProgressView extends Teaspoon.Reporters.BaseView
4
+
5
+ @create: (displayProgress = true) ->
6
+ return new Teaspoon.Reporters.HTML.ProgressView() unless displayProgress
7
+ if Teaspoon.Reporters.HTML.RadialProgressView.supported
8
+ new Teaspoon.Reporters.HTML.RadialProgressView()
9
+ else
10
+ new Teaspoon.Reporters.HTML.SimpleProgressView()
11
+
12
+
13
+ build: ->
14
+ @el = @createEl("div", "teaspoon-indicator teaspoon-logo")
15
+
16
+
17
+ update: ->
18
+ # do nothing
@@ -1,37 +1,4 @@
1
- class Teaspoon.Reporters.HTML.ProgressView extends Teaspoon.Reporters.BaseView
2
-
3
- @create: (displayProgress = true) ->
4
- return new Teaspoon.Reporters.HTML.ProgressView() unless displayProgress
5
- if Teaspoon.Reporters.HTML.RadialProgressView.supported
6
- new Teaspoon.Reporters.HTML.RadialProgressView()
7
- else
8
- new Teaspoon.Reporters.HTML.SimpleProgressView()
9
-
10
-
11
- build: ->
12
- @el = @createEl("div", "teaspoon-indicator teaspoon-logo")
13
-
14
-
15
- update: ->
16
- # do nothing
17
-
18
-
19
-
20
- class Teaspoon.Reporters.HTML.SimpleProgressView extends Teaspoon.Reporters.HTML.ProgressView
21
-
22
- build: ->
23
- @el = @createEl("div", "simple-progress")
24
- @el.innerHTML = """
25
- <em id="teaspoon-progress-percent">0%</em>
26
- <span id="teaspoon-progress-span" class="teaspoon-indicator"></span>
27
- """
28
-
29
-
30
- update: (total, run) ->
31
- percent = if total then Math.ceil((run * 100) / total) else 0
32
- @setHtml("progress-percent", "#{percent}%")
33
-
34
-
1
+ #= require teaspoon/reporters/html/progress_view
35
2
 
36
3
  class Teaspoon.Reporters.HTML.RadialProgressView extends Teaspoon.Reporters.HTML.ProgressView
37
4
 
@@ -0,0 +1,15 @@
1
+ #= require teaspoon/reporters/html/progress_view
2
+
3
+ class Teaspoon.Reporters.HTML.SimpleProgressView extends Teaspoon.Reporters.HTML.ProgressView
4
+
5
+ build: ->
6
+ @el = @createEl("div", "simple-progress")
7
+ @el.innerHTML = """
8
+ <em id="teaspoon-progress-percent">0%</em>
9
+ <span id="teaspoon-progress-span" class="teaspoon-indicator"></span>
10
+ """
11
+
12
+
13
+ update: (total, run) ->
14
+ percent = if total then Math.ceil((run * 100) / total) else 0
15
+ @setHtml("progress-percent", "#{percent}%")
@@ -1,3 +1,5 @@
1
+ #= require teaspoon/reporters/html/base_view
2
+
1
3
  class Teaspoon.Reporters.HTML.SpecView extends Teaspoon.Reporters.BaseView
2
4
 
3
5
  viewId = 0
@@ -23,7 +25,7 @@ class Teaspoon.Reporters.HTML.SpecView extends Teaspoon.Reporters.BaseView
23
25
  if parent.viewId
24
26
  @views.suites[parent.viewId]
25
27
  else
26
- view = new Teaspoon.Reporters.HTML.SuiteView(parent, @reporter)
28
+ view = new (Teaspoon.resolveClass("Reporters.HTML.SuiteView"))(parent, @reporter)
27
29
  @views.suites[view.suite.viewId] = view
28
30
 
29
31
 
@@ -40,7 +42,7 @@ class Teaspoon.Reporters.HTML.SpecView extends Teaspoon.Reporters.BaseView
40
42
  result = @spec.result()
41
43
  classes = ["state-#{state}"]
42
44
  classes.push("slow") if elapsed > Teaspoon.slow
43
- @el.innerHTML += "<span>#{elapsed}ms</span>" unless state == "failed"
45
+ @el.innerHTML += "<span>#{elapsed}ms</span>" if state == "passed"
44
46
  @el.className = classes.join(" ")
45
- @buildErrors() unless result.status == "passed"
47
+ @buildErrors() if result.status == "failed"
46
48
  @parentView.updateState?(state)
@@ -1,3 +1,5 @@
1
+ #= require teaspoon/reporters/html/base_view
2
+
1
3
  class Teaspoon.Reporters.HTML.SuiteView extends Teaspoon.Reporters.BaseView
2
4
 
3
5
  viewId = 0
@@ -6,7 +8,7 @@ class Teaspoon.Reporters.HTML.SuiteView extends Teaspoon.Reporters.BaseView
6
8
  @views = @reporter.views
7
9
  @suite.viewId = viewId += 1
8
10
  @views.suites[@suite.viewId] = @
9
- @suite = new Teaspoon.Suite(@suite)
11
+ @suite = new (Teaspoon.resolveClass("Suite"))(@suite)
10
12
  super
11
13
 
12
14
 
@@ -23,7 +25,7 @@ class Teaspoon.Reporters.HTML.SuiteView extends Teaspoon.Reporters.BaseView
23
25
  if parent.viewId
24
26
  @views.suites[parent.viewId]
25
27
  else
26
- view = new Teaspoon.Reporters.HTML.SuiteView(parent, @reporter)
28
+ view = new (Teaspoon.resolveClass("Reporters.HTML.SuiteView"))(parent, @reporter)
27
29
  @views.suites[view.suite.viewId] = view
28
30
 
29
31
 
@@ -20,13 +20,17 @@ class Teaspoon.Runner
20
20
 
21
21
  getReporter: ->
22
22
  if @params["reporter"]
23
- Teaspoon.Reporters[@params["reporter"]]
23
+ @findReporter(@params["reporter"])
24
24
  else
25
25
  if window.navigator.userAgent.match(/PhantomJS/)
26
- Teaspoon.Reporters.Console
26
+ @findReporter("Console")
27
27
  else
28
- Teaspoon.Reporters.HTML
28
+ @findReporter("HTML")
29
29
 
30
30
 
31
31
  setup: ->
32
32
  # left for subclasses to implement
33
+
34
+
35
+ findReporter: (type) ->
36
+ Teaspoon.resolveClass("Reporters.#{type}")
@@ -1,32 +1,90 @@
1
- class TeaspoonInterface
2
-
3
- constructor: ->
4
- @files = $u("#teaspoon-suite-list .file a")
5
- @input = $u("#teaspoon-filter-input")[0]
6
- @input.value = ""
7
- @input.onkeyup = @filter
8
-
9
-
10
- filter: =>
11
- for file in @files
12
- if LiquidMetal.score(file.innerHTML, @input.value) > 0
13
- file.parentNode.style.display = "block"
14
- else
15
- file.parentNode.style.display = "none"
16
-
17
-
18
- window.onload = -> new TeaspoonInterface()
19
-
20
- `
21
- /*!
22
- * LiquidMetal
23
- * Copyright (c) 2009, Ryan McGeary (ryanonjavascript -[at]- mcgeary [*dot*] org)
24
- */
25
- var LiquidMetal=function(){var l=0.0;var m=1.0;var n=0.8;var o=0.9;var p=0.85;return{score:function(a,b){if(b.length==0)return n;if(b.length>a.length)return l;var c=this.buildScoreArray(a,b);var d=0.0;for(var i=0;i<c.length;i++){d+=c[i]}return(d/c.length)},buildScoreArray:function(a,b){var d=new Array(a.length);var e=a.toLowerCase();var f=b.toLowerCase().split("");var g=-1;var h=false;for(var i=0;i<f.length;i++){var c=f[i];var j=e.indexOf(c,g+1);if(j<0)return fillArray(d,l);if(j==0)h=true;if(isNewWord(a,j)){d[j-1]=1;fillArray(d,p,g+1,j-1)}else if(isUpperCase(a,j)){fillArray(d,p,g+1,j)}else{fillArray(d,l,g+1,j)}d[j]=m;g=j}var k=h?o:n;fillArray(d,k,g+1);return d}};function isUpperCase(a,b){var c=a.charAt(b);return("A"<=c&&c<="Z")}function isNewWord(a,b){var c=a.charAt(b-1);return(c==" "||c=="\t")}function fillArray(a,b,c,d){c=Math.max(c||0,0);d=Math.min(d||a.length,a.length);for(var i=c;i<d;i++){a[i]=b}return a}}();
26
-
27
- /*!
28
- * uSelector
29
- * author: Fabio Miranda Costa | github: fabiomcosta | twitter: @fabiomiranda | license: MIT-style license
30
- */
31
- (function(h,i){var f,c,j,k,m={},e,l,q=/^\s+|\s+$/g,r=!!i.querySelectorAll,g=function(d,b,a){f=a||[];e=b||g.context;if(r)try{n(e.querySelectorAll(d));return f}catch(v){}l=e.ownerDocument||e;d=d.replace(q,"");for(c={};d=d.replace(/([#.:])?([^#.:]*)/,s););d=(b=c.id)&&c.tag||c.classes||c.pseudos||!b&&(c.classes||c.pseudos)?t:o;if(b){if(a=b=l.getElementById(b))if(!(a=l===e))a:{a=b;do if(a===e){a=true;break a}while(a=a.parentNode);a=false}a&&d([b])}else d(e.getElementsByTagName(c.tag||"*"));return f},u=function(d){if(c.tag){var b=d.nodeName.toUpperCase();if(c.tag=="*"){if(b<"@")return false}else if(b!=c.tag)return false}if(c.id&&d.getAttribute("id")!=c.id)return false;if(j=c.classes){var a=" "+d.className+" ";for(b=j.length;b--;)if(a.indexOf(" "+j[b]+" ")<0)return false}if(k=c.pseudos)for(b=k.length;b--;){a=m[k[b]];if(!(a&&a.call(g,d)))return false}return true},s=function(d,b,a){if(b)if(b=="#")c.id=a;else if(b==".")if(c.classes)c.classes.push(a);else c.classes=[a];else{if(b==":")if(c.pseudos)c.pseudos.push(a);else c.pseudos=[a]}else c.tag=a.toUpperCase();return""},p=Array.prototype.slice,n=function(d){f=p.call(d,0)},o=function(d){for(var b=0,a;a=d[b++];)f.push(a)};try{p.call(i.documentElement.childNodes,0)}catch(w){n=o}var t=function(d){for(var b=0,a;a=d[b++];)u(a)&&f.push(a)};g.pseudos=m;g.context=i;h.uSelector=g;h.$u||(h.$u=g)})(this,document);
32
- `
1
+ #= require_self
2
+ #= require teaspoon/runner
3
+ #= require teaspoon/fixture
4
+ #= require teaspoon/hook
5
+ #= require teaspoon/reporters/html
6
+ #= require teaspoon/reporters/console
7
+
8
+ class @Teaspoon
9
+ @defer: false
10
+ @slow: 75
11
+ @root: window.location.pathname.replace(/\/+(index\.html)?$/, "").replace(/\/[^\/]*$/, "")
12
+ @started: false
13
+ @finished: false
14
+ @Reporters: {}
15
+ @Date: Date
16
+ @location: window.location
17
+ @messages: []
18
+
19
+ @execute: ->
20
+ unless Teaspoon.framework
21
+ throw "No framework registered. Expected a framework to register itself, but nothing has."
22
+
23
+ if Teaspoon.defer
24
+ Teaspoon.defer = false
25
+ return
26
+ Teaspoon.reload() if Teaspoon.started
27
+ Teaspoon.started = true
28
+ new (Teaspoon.resolveClass("Runner"))()
29
+
30
+
31
+ @reload: ->
32
+ window.location.reload()
33
+
34
+
35
+ @onWindowLoad: (method) ->
36
+ originalOnload = window.onload
37
+ window.onload = ->
38
+ originalOnload() if originalOnload && originalOnload.call
39
+ method()
40
+
41
+
42
+ @resolveDependenciesFromParams: (all = []) ->
43
+ deps = []
44
+ return all if (paths = Teaspoon.location.search.match(/[\?&]file(\[\])?=[^&\?]*/gi)) == null
45
+
46
+ for path in paths
47
+ parts = decodeURIComponent(path.replace(/\+/g, " ")).match(/\/(.+)\.(js|js.coffee|coffee)$/i)
48
+ continue if parts == null
49
+ file = parts[1].substr(parts[1].lastIndexOf("/") + 1)
50
+ for dep in all then deps.push(dep) if dep.indexOf(file) >= 0
51
+ deps
52
+
53
+
54
+ @log: ->
55
+ Teaspoon.messages.push(arguments[0])
56
+ try console.log(arguments...)
57
+ catch e
58
+ throw new Error("Unable to use console.log for logging")
59
+
60
+
61
+ @getMessages: ->
62
+ messages = Teaspoon.messages
63
+ Teaspoon.messages = []
64
+ messages
65
+
66
+
67
+ @setFramework: (namespace) ->
68
+ Teaspoon.framework = namespace
69
+ window.fixture = Teaspoon.resolveClass("Fixture")
70
+
71
+
72
+ # This checks if a framework has overridden a core class and if we should
73
+ # load that instead of the core base class.
74
+ @resolveClass: (klass) ->
75
+ if framework_override = Teaspoon.checkNamespace(Teaspoon.framework, klass)
76
+ return framework_override
77
+ else if teaspoon_core = Teaspoon.checkNamespace(Teaspoon, klass)
78
+ return teaspoon_core
79
+
80
+ throw "Could not find the class you're looking for: #{klass}"
81
+
82
+
83
+ @checkNamespace: (root, klass) ->
84
+ namespaces = klass.split('.')
85
+ scope = root
86
+
87
+ for namespace, i in namespaces
88
+ return false if !(scope = scope[namespace])
89
+
90
+ return scope
@@ -1,4 +1,5 @@
1
1
  class Teaspoon::SuiteController < ActionController::Base
2
+ before_filter :check_env
2
3
  before_filter :prepend_fixture_paths
3
4
 
4
5
  layout false
@@ -23,6 +24,10 @@ class Teaspoon::SuiteController < ActionController::Base
23
24
 
24
25
  private
25
26
 
27
+ def check_env
28
+ Teaspoon::Environment.check_env!
29
+ end
30
+
26
31
  def prepend_fixture_paths
27
32
  Teaspoon.configuration.fixture_paths.each do |path|
28
33
  prepend_view_path Teaspoon.configuration.root.join(path)
@@ -4,7 +4,7 @@
4
4
  <title>Teaspoon :: Suites</title>
5
5
  <meta name="viewport" content="width=device-width, user-scalable=no">
6
6
  <%= stylesheet_link_tag "teaspoon" %>
7
- <%= javascript_include_tag "teaspoon-teaspoon" %>
7
+ <%= javascript_include_tag "teaspoon-filterer" %>
8
8
  </head>
9
9
  <body>
10
10
  <div id="teaspoon-interface">
@@ -1,88 +1,118 @@
1
+ require "teaspoon/exceptions"
2
+ require "rails/generators"
3
+
1
4
  module Teaspoon
2
5
  module Generators
3
6
  class InstallGenerator < Rails::Generators::Base
4
- source_root File.expand_path("../", __FILE__)
7
+ source_root File.expand_path("../templates", __FILE__)
5
8
 
6
9
  desc "Installs the Teaspoon initializer into your application."
7
10
 
8
11
  class_option :framework,
9
12
  type: :string,
10
13
  aliases: "-t",
11
- default: "jasmine",
12
- desc: "Specify which test framework to use (Available: jasmine, mocha, or qunit)"
14
+ default: Teaspoon::Framework.default,
15
+ desc: "Specify which test framework to use (Available: #{Teaspoon::Framework.available.keys.join(', ')})"
16
+
17
+ class_option :version,
18
+ type: :string,
19
+ aliases: "-v",
20
+ default: nil,
21
+ desc: "Specify the framework version to use (Depends on the framework)"
13
22
 
14
23
  class_option :coffee,
15
24
  type: :boolean,
16
25
  aliases: "-c",
17
26
  default: false,
18
- desc: "Generate a CoffeeScript spec helper instead of Javascript"
27
+ desc: "Generate a CoffeeScript spec helper instead of Javascript"
19
28
 
20
- class_option :no_comments,
29
+ class_option :documentation,
21
30
  type: :boolean,
22
- aliases: "-q",
23
- default: false,
24
- desc: "Install the teaspoon_env.rb without comments"
31
+ aliases: ["-d"],
32
+ default: true,
33
+ desc: "Install the teaspoon_env.rb with comment documentation"
25
34
 
26
35
  class_option :partials,
27
36
  type: :boolean,
28
37
  aliases: "-p",
29
38
  default: false,
30
- desc: "Copy the boot and body partials"
39
+ desc: "Copy the boot and body partials"
31
40
 
32
- def validate_framework
33
- return if frameworks.include?(options[:framework])
34
- puts "Unknown framework -- available #{frameworks.join(', ')}"
35
- exit(1)
41
+ def verify_framework_and_version
42
+ version.present?
43
+ framework
44
+ rescue
45
+ abort_with_message if behavior == :invoke
36
46
  end
37
47
 
38
48
  def copy_environment
39
- if options[:no_comments]
40
- copy_file "templates/#{framework}/env.rb",
41
- "#{framework_type}/teaspoon_env.rb"
42
- else
43
- template "templates/#{framework}/env_comments.rb.tt",
44
- "#{framework_type}/teaspoon_env.rb"
45
- end
49
+ source = options[:documentation] ? "env_comments.rb.tt" : "env.rb.tt"
50
+ template source, "#{framework.install_path}/teaspoon_env.rb"
46
51
  end
47
52
 
48
53
  def create_structure
49
- empty_directory "#{framework_type}/javascripts/support"
50
- empty_directory "#{framework_type}/javascripts/fixtures"
54
+ empty_directory "#{framework.install_path}/javascripts/support"
55
+ empty_directory "#{framework.install_path}/javascripts/fixtures"
51
56
  end
52
57
 
53
- def copy_spec_helper
54
- copy_file "templates/#{framework}/#{framework_type}_helper.#{helper_ext}",
55
- "#{framework_type}/javascripts/#{framework_type}_helper.#{helper_ext}"
58
+ def install_framework_files
59
+ instance_eval(&framework.install_callback)
56
60
  end
57
61
 
58
62
  def copy_partials
59
63
  return unless options[:partials]
60
- copy_file "templates/_boot.html.erb",
61
- "#{framework_type}/javascripts/fixtures/_boot.html.erb"
62
- copy_file "templates/_body.html.erb",
63
- "#{framework_type}/javascripts/fixtures/_body.html.erb"
64
+ copy_file "_boot.html.erb", "#{framework.install_path}/javascripts/fixtures/_boot.html.erb"
65
+ copy_file "_body.html.erb", "#{framework.install_path}/javascripts/fixtures/_body.html.erb"
64
66
  end
65
67
 
66
- def display_readme
68
+ def display_post_install
67
69
  readme "POST_INSTALL" if behavior == :invoke
68
70
  end
69
71
 
70
72
  private
71
73
 
74
+ def described_frameworks
75
+ Teaspoon::Framework.available.map do |framework, options|
76
+ klass = Teaspoon::Framework.fetch(framework)
77
+ "#{framework}: versions[#{klass.versions.join(', ')}]"
78
+ end
79
+ end
80
+
72
81
  def framework
73
- options[:framework]
82
+ @framework ||= begin
83
+ framework = Teaspoon::Framework.fetch(options[:framework])
84
+ source_paths
85
+ @source_paths = framework.template_paths + @source_paths
86
+ framework
87
+ end
88
+ end
89
+
90
+ def suite
91
+ @suite ||= begin
92
+ config = Teaspoon::Configuration::Suite.new
93
+ framework.modify_config(config)
94
+ config
95
+ end
74
96
  end
75
97
 
76
- def frameworks
77
- %w{jasmine mocha qunit}
98
+ def version
99
+ @version ||= options[:version] ? determine_requested_version : framework.versions.last
78
100
  end
79
101
 
80
- def helper_ext
81
- (options[:coffee]) ? "coffee" : "js"
102
+ def determine_requested_version
103
+ return options[:version] if framework.versions.include?(options[:version])
104
+ raise Teaspoon::UnknownFrameworkVersion.new(name: framework.name, version: options[:version])
82
105
  end
83
106
 
84
- def framework_type
85
- (options[:framework] == "qunit") ? "test" : "spec"
107
+ def abort_with_message
108
+ if Teaspoon::Framework.available.empty?
109
+ readme "MISSING_FRAMEWORK"
110
+ else
111
+ message = "Unknown framework: #{options[:framework]}#{options[:version] ? "[#{options[:version]}]" : ''}"
112
+ message << "\n Available: #{described_frameworks.join("\n ")}"
113
+ say_status message, nil, :red
114
+ end
115
+ exit(1)
86
116
  end
87
117
  end
88
118
  end