teaspoon 0.7.9 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +382 -260
  3. data/app/assets/javascripts/teaspoon-angular.js +108 -26241
  4. data/app/assets/javascripts/teaspoon-jasmine.js +103 -2642
  5. data/app/assets/javascripts/teaspoon-mocha.js +109 -5416
  6. data/app/assets/javascripts/teaspoon-qunit.js +107 -2255
  7. data/app/assets/javascripts/teaspoon-teaspoon.js +0 -1
  8. data/app/assets/javascripts/teaspoon/angular.coffee +3 -1
  9. data/app/assets/javascripts/teaspoon/base/hook.coffee +21 -0
  10. data/app/assets/javascripts/teaspoon/base/reporters/html.coffee +26 -14
  11. data/app/assets/javascripts/teaspoon/base/reporters/html/progress_view.coffee +1 -1
  12. data/app/assets/javascripts/teaspoon/base/reporters/html/template.coffee +3 -3
  13. data/app/assets/javascripts/teaspoon/base/teaspoon.coffee +10 -1
  14. data/app/assets/javascripts/teaspoon/jasmine.coffee +3 -1
  15. data/app/assets/javascripts/teaspoon/mocha.coffee +3 -1
  16. data/app/assets/javascripts/teaspoon/mocha/reporters/html.coffee +1 -1
  17. data/app/assets/javascripts/teaspoon/qunit.coffee +3 -1
  18. data/app/assets/javascripts/teaspoon/qunit/reporters/html.coffee +1 -1
  19. data/app/assets/javascripts/teaspoon/teaspoon.coffee +0 -1
  20. data/app/assets/stylesheets/teaspoon.css +12 -8
  21. data/app/controllers/teaspoon/suite_controller.rb +32 -0
  22. data/app/views/teaspoon/suite/_body.html.erb +0 -0
  23. data/app/views/teaspoon/suite/_boot.html.erb +4 -0
  24. data/app/views/teaspoon/suite/_boot_require_js.html.erb +19 -0
  25. data/app/views/teaspoon/{spec/suites.html.erb → suite/index.html.erb} +6 -7
  26. data/app/views/teaspoon/suite/show.html.erb +19 -0
  27. data/bin/teaspoon +1 -1
  28. data/config/routes.rb +14 -4
  29. data/lib/generators/teaspoon/install/POST_INSTALL +2 -2
  30. data/lib/generators/teaspoon/install/install_generator.rb +22 -11
  31. data/lib/generators/teaspoon/install/templates/_body.html.erb +0 -0
  32. data/lib/generators/teaspoon/install/templates/_boot.html.erb +4 -0
  33. data/lib/generators/teaspoon/install/templates/jasmine/env.rb +11 -0
  34. data/lib/generators/teaspoon/install/templates/jasmine/env_comments.rb +182 -0
  35. data/lib/generators/teaspoon/install/templates/jasmine/spec_helper.coffee +8 -6
  36. data/lib/generators/teaspoon/install/templates/jasmine/spec_helper.js +8 -7
  37. data/lib/generators/teaspoon/install/templates/mocha/env.rb +11 -0
  38. data/lib/generators/teaspoon/install/templates/mocha/env_comments.rb +182 -0
  39. data/lib/generators/teaspoon/install/templates/mocha/spec_helper.coffee +13 -13
  40. data/lib/generators/teaspoon/install/templates/mocha/spec_helper.js +13 -13
  41. data/lib/generators/teaspoon/install/templates/qunit/env.rb +11 -0
  42. data/lib/generators/teaspoon/install/templates/qunit/env_comments.rb +182 -0
  43. data/lib/generators/teaspoon/install/templates/qunit/test_helper.coffee +6 -5
  44. data/lib/generators/teaspoon/install/templates/qunit/test_helper.js +6 -5
  45. data/lib/tasks/teaspoon.rake +9 -2
  46. data/lib/teaspoon.rb +4 -6
  47. data/lib/teaspoon/command_line.rb +116 -134
  48. data/lib/teaspoon/configuration.rb +144 -66
  49. data/lib/teaspoon/console.rb +70 -37
  50. data/lib/teaspoon/coverage.rb +42 -15
  51. data/lib/teaspoon/deprecated.rb +65 -0
  52. data/lib/teaspoon/drivers/base.rb +10 -0
  53. data/lib/teaspoon/drivers/phantomjs/runner.js +9 -11
  54. data/lib/teaspoon/drivers/phantomjs_driver.rb +21 -21
  55. data/lib/teaspoon/drivers/selenium_driver.rb +32 -13
  56. data/lib/teaspoon/engine.rb +32 -12
  57. data/lib/teaspoon/environment.rb +16 -12
  58. data/lib/teaspoon/exceptions.rb +41 -5
  59. data/lib/teaspoon/exporter.rb +52 -0
  60. data/lib/teaspoon/formatters/base.rb +171 -0
  61. data/lib/teaspoon/formatters/clean_formatter.rb +2 -4
  62. data/lib/teaspoon/formatters/documentation_formatter.rb +60 -0
  63. data/lib/teaspoon/formatters/dot_formatter.rb +12 -90
  64. data/lib/teaspoon/formatters/json_formatter.rb +36 -0
  65. data/lib/teaspoon/formatters/junit_formatter.rb +51 -32
  66. data/lib/teaspoon/formatters/modules/report_module.rb +76 -0
  67. data/lib/teaspoon/formatters/pride_formatter.rb +23 -27
  68. data/lib/teaspoon/formatters/snowday_formatter.rb +7 -11
  69. data/lib/teaspoon/formatters/swayze_or_oprah_formatter.rb +88 -64
  70. data/lib/teaspoon/formatters/tap_formatter.rb +18 -27
  71. data/lib/teaspoon/formatters/tap_y_formatter.rb +35 -45
  72. data/lib/teaspoon/formatters/teamcity_formatter.rb +69 -31
  73. data/lib/teaspoon/instrumentation.rb +33 -33
  74. data/lib/teaspoon/result.rb +2 -1
  75. data/lib/teaspoon/runner.rb +40 -28
  76. data/lib/teaspoon/server.rb +23 -25
  77. data/lib/teaspoon/suite.rb +52 -72
  78. data/lib/teaspoon/utility.rb +3 -14
  79. data/lib/teaspoon/version.rb +1 -1
  80. data/spec/dummy/app/assets/javascripts/integration/integration_spec.coffee +3 -0
  81. data/spec/dummy/app/assets/javascripts/integration/spec_helper.coffee +2 -0
  82. data/spec/dummy/config/application.rb +3 -0
  83. data/spec/features/console_reporter_spec.rb +48 -18
  84. data/spec/features/hooks_spec.rb +23 -41
  85. data/spec/features/html_reporter_spec.rb +38 -21
  86. data/spec/features/install_generator_spec.rb +34 -20
  87. data/spec/features/instrumentation_spec.rb +3 -2
  88. data/spec/fixtures/coverage.json +243 -0
  89. data/spec/javascripts/fixtures/_body.html.erb +1 -0
  90. data/spec/javascripts/jasmine_helper.coffee +1 -1
  91. data/spec/javascripts/teaspoon/base/fixture_spec.coffee +4 -4
  92. data/spec/javascripts/teaspoon/base/reporters/html_spec.coffee +9 -10
  93. data/spec/javascripts/teaspoon/mocha/reporters/html_mspec.coffee +0 -6
  94. data/spec/javascripts/teaspoon/phantomjs/runner_spec.coffee +5 -6
  95. data/spec/javascripts/turbolinks_helper.coffee +1 -1
  96. data/spec/spec_helper.rb +3 -4
  97. data/spec/teaspoon/command_line_spec.rb +139 -23
  98. data/spec/teaspoon/configuration_spec.rb +164 -46
  99. data/spec/teaspoon/console_spec.rb +142 -47
  100. data/spec/teaspoon/coverage_spec.rb +98 -28
  101. data/spec/teaspoon/drivers/base_spec.rb +5 -0
  102. data/spec/teaspoon/drivers/phantomjs_driver_spec.rb +32 -14
  103. data/spec/teaspoon/drivers/selenium_driver_spec.rb +32 -24
  104. data/spec/teaspoon/engine_spec.rb +8 -5
  105. data/spec/teaspoon/environment_spec.rb +56 -33
  106. data/spec/teaspoon/exceptions_spec.rb +57 -0
  107. data/spec/teaspoon/exporter_spec.rb +96 -0
  108. data/spec/teaspoon/formatters/base_spec.rb +259 -0
  109. data/spec/teaspoon/formatters/clean_formatter_spec.rb +37 -0
  110. data/spec/teaspoon/formatters/documentation_formatter_spec.rb +127 -0
  111. data/spec/teaspoon/formatters/dot_formatter_spec.rb +52 -56
  112. data/spec/teaspoon/formatters/json_formatter_spec.rb +77 -0
  113. data/spec/teaspoon/formatters/junit_formatter_spec.rb +72 -35
  114. data/spec/teaspoon/formatters/pride_formatter_spec.rb +37 -0
  115. data/spec/teaspoon/formatters/snowday_formatter_spec.rb +35 -0
  116. data/spec/teaspoon/formatters/tap_formatter_spec.rb +29 -81
  117. data/spec/teaspoon/formatters/tap_y_formatter_spec.rb +31 -141
  118. data/spec/teaspoon/formatters/teamcity_formatter_spec.rb +99 -42
  119. data/spec/teaspoon/instrumentation_spec.rb +44 -44
  120. data/spec/teaspoon/result_spec.rb +37 -0
  121. data/spec/teaspoon/runner_spec.rb +70 -59
  122. data/spec/teaspoon/server_spec.rb +34 -52
  123. data/spec/teaspoon/suite_spec.rb +42 -188
  124. data/spec/teaspoon_env.rb +39 -28
  125. data/vendor/assets/javascripts/{angular-scenario-1.0.5.js → angular/1.0.5.js} +0 -0
  126. data/vendor/assets/javascripts/{angular-scenario-1.0.5.MIT-LICENSE → angular/MIT-LICENSE} +0 -0
  127. data/vendor/assets/javascripts/{jasmine-1.3.1.js → jasmine/1.3.1.js} +0 -0
  128. data/vendor/assets/javascripts/jasmine/2.0.0.js +2412 -0
  129. data/vendor/assets/javascripts/{jasmine-1.3.1.MIT.LICENSE → jasmine/MIT.LICENSE} +0 -0
  130. data/vendor/assets/javascripts/{mocha-1.10.0.js → mocha/1.10.0.js} +1 -0
  131. data/vendor/assets/javascripts/mocha/1.17.1.js +5813 -0
  132. data/vendor/assets/javascripts/{mocha-1.10.1.MIT.LICENSE → mocha/MIT.LICENSE} +0 -0
  133. data/vendor/assets/javascripts/{qunit-1.12.0.js → qunit/1.12.0.js} +1 -1
  134. data/vendor/assets/javascripts/qunit/1.14.0.js +2288 -0
  135. data/vendor/assets/javascripts/{qunit-1.12.0.MIT.LICENSE → qunit/MIT.LICENSE} +0 -0
  136. data/vendor/assets/javascripts/support/chai.js +827 -385
  137. data/vendor/assets/javascripts/support/jasmine-jquery-1.7.0.js +720 -0
  138. data/vendor/assets/javascripts/support/jasmine-jquery-2.0.0.js +812 -0
  139. data/vendor/assets/javascripts/support/sinon-chai.js +17 -0
  140. data/vendor/assets/javascripts/support/sinon.js +1138 -643
  141. metadata +57 -36
  142. data/app/controllers/teaspoon/spec_controller.rb +0 -38
  143. data/app/helpers/teaspoon/spec_helper.rb +0 -36
  144. data/app/views/teaspoon/spec/_require_js.html.erb +0 -21
  145. data/app/views/teaspoon/spec/_standard.html.erb +0 -4
  146. data/app/views/teaspoon/spec/runner.html.erb +0 -19
  147. data/lib/generators/teaspoon/install/templates/env.rb +0 -38
  148. data/lib/generators/teaspoon/install/templates/jasmine/initializer.rb +0 -64
  149. data/lib/generators/teaspoon/install/templates/mocha/initializer.rb +0 -64
  150. data/lib/generators/teaspoon/install/templates/qunit/initializer.rb +0 -64
  151. data/lib/teaspoon/check_coverage.rb +0 -33
  152. data/lib/teaspoon/drivers/base_driver.rb +0 -10
  153. data/lib/teaspoon/exception_handling.rb +0 -18
  154. data/lib/teaspoon/formatters/base_formatter.rb +0 -63
  155. data/spec/dummy/config/initializers/teaspoon.rb +0 -41
  156. data/spec/teaspoon/check_coverage_spec.rb +0 -50
  157. data/spec/teaspoon/formatters/base_formatter_spec.rb +0 -45
  158. data/vendor/assets/javascripts/support/chai.MIT.LICENSE +0 -22
  159. data/vendor/assets/javascripts/support/expect.MIT.LICENSE +0 -22
  160. data/vendor/assets/javascripts/support/jasmine-jquery.MIT.LICENSE +0 -20
  161. data/vendor/assets/javascripts/support/jasmine-jquery.js +0 -659
  162. data/vendor/assets/javascripts/support/sinon-chai.MIT-ISH.LICENSE +0 -13
  163. data/vendor/assets/javascripts/support/sinon.BSD.LICENSE +0 -27
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8cef218e8022c1570a522f1d4a1d7f7f8e2a367f
4
- data.tar.gz: ca33470c138fad431468907cb7e8c0961cd6d739
3
+ metadata.gz: 8fbbf5295bc786b2056c1863d366a253f191e420
4
+ data.tar.gz: 43b86be934c3ebe643d667f3569e3b2fbee76232
5
5
  SHA512:
6
- metadata.gz: e3d0cfcf706cf47bff2d7bb0b727159ba2e77dfa02dfaca7199ff68bae1583fd9d46ef331340c2cfc0fcefd9c3138892abdbf01990ff5db0e6cc45e266d5776a
7
- data.tar.gz: ad850647cd5f11675c4bb3995326a4bb31eb40bc0b7e1f0b14d6438786f098272aee1858bafc65294a448bf6467d3b46763099123d21c9ea7eff55a218e55e12
6
+ metadata.gz: d2ccba66f0a0d524924cdf6999e3d785d80c46b3e6c704b066de0900641c576a90aabda5e52c6ede4440148f0806064dfca54a6e1b2ee2f42d997fee1f1078d5
7
+ data.tar.gz: dfa0de920af9e2b437498f08e39afdd449a69297c1cb9179e00f8c7bdbd7dfb76b358a3550f32ae93991b1e6bb2a069436a6159b796f6cfa7f23ff1a62af0923
data/README.md CHANGED
@@ -1,26 +1,49 @@
1
- ### ![Logo by Morgan Keys](https://raw.github.com/modeset/teaspoon/master/screenshots/logo.png)
1
+ Teaspoon
2
+ ========
2
3
 
3
- [![Gem Version](https://badge.fury.io/rb/teaspoon.png)](http://badge.fury.io/rb/teaspoon)
4
- [![Build Status](https://travis-ci.org/modeset/teaspoon.png)](https://travis-ci.org/modeset/teaspoon)
5
- [![Code Climate](https://codeclimate.com/github/modeset/teaspoon.png)](https://codeclimate.com/github/modeset/teaspoon)
4
+ [![Gem Version](https://img.shields.io/gem/v/teaspoon.svg)](http://badge.fury.io/rb/teaspoon)
5
+ [![Dependency Status](https://img.shields.io/gemnasium/modeset/teaspoon.svg)](https://gemnasium.com/modeset/teaspoon)
6
+ [![Build Status](https://img.shields.io/travis/modeset/teaspoon.svg)](https://travis-ci.org/modeset/teaspoon)
7
+ [![Code Climate](https://img.shields.io/codeclimate/github/modeset/teaspoon.svg)](https://codeclimate.com/github/modeset/teaspoon)
8
+ [![Coverage Status](https://img.shields.io/coveralls/modeset/teaspoon/master.svg)](https://coveralls.io/r/modeset/teaspoon?branch=master)
6
9
 
10
+ <img src="https://raw.github.com/modeset/teaspoon/master/screenshots/logo_big.png" alt="Logo by Morgan Keys" align="right" />
7
11
  <sup>Logo by [Morgan Keys](http://www.morganrkeys.com/)</sup>
8
12
 
9
- Teaspoon is a Javascript test runner built on top of Rails. It can run tests in the browser, or headlessly using PhantomJS or with Selenium WebDriver.
13
+ Teaspoon is a Javascript test runner built for Rails. It runs tests in the browser or headless using PhantomJS or Selenium WebDriver.
10
14
 
11
- Its objective is to be the simplest, while also being the most complete Javascript testing solution for Rails. It takes full advantage of the asset pipeline and ships with support for Jasmine, Mocha, QUnit, and (experimentally) Angular.
15
+ The goal is to be simple, while still providing the most complete Javascript testing solution for Rails.
12
16
 
13
- Ok, another Javascript test runner, right? Really? Yeah, that's tough, but we're pretty confident Teaspoon is one of the nicest and most full featured you'll find at the moment. And if you disagree, let us know and we'll probably fix whatever it is that you didn't like.
17
+ Teaspoon takes advantage of the asset pipeline. And ships with support for Jasmine, Mocha, and QUnit.
14
18
 
15
- Feedback, ideas and pull requests are always welcome, or you can hit us up on Twitter [@modeset_](https://twitter.com/modeset_).
19
+ Ok, another Javascript test runner, right? Yeah, that's tough, but we're pretty confident Teaspoon is one of the nicest and most full featured you'll find at the moment. And if you disagree, let us know and we'll likely fix whatever it is that you didn't like.
20
+
21
+ Feedback, ideas and pull requests are always welcome, or you can hit us up on Twitter @modeset_.
16
22
 
17
23
  If you'd like to use Teaspoon with [Guard](https://github.com/guard/guard), check out the [guard-teaspoon](https://github.com/modeset/guard-teaspoon) project.
18
24
 
19
- ### Developer Notice:
25
+ Or, if you'd want to use [Spring](https://github.com/rails/spring) preloader, use with [spring-commands-teaspoon](https://github.com/alejandrobabio/spring-commands-teaspoon).
26
+
27
+ ## Developer Notice
28
+
29
+ The master branch deviates heavily from 0.7.9 and represents the changes that will be in 0.8. There's a good [wiki article](https://github.com/modeset/teaspoon/wiki/Changelog) about the notable changes and how you can ease the pain of upgrading.
30
+
31
+ While we know that considerable changes like these can be a pain, they're not made frivolously, and they set the groundwork for what we can all build on and contribute to. There was some cleanup that needed to happen, and some polish, and in that process we tried to think about what we've learned thus far, and how we can better that for future versions. We appreciate your tolerance and willingness to help us fix anything that we missed.
32
+
33
+ :heart:
34
+
35
+ ### 0.8.0 - follow ups / todo
36
+
37
+ Here's a short list of things that 0.8.0 might also address.
38
+
39
+ - add jasmine2 support
40
+ - tests for the require js stuff (this is brittle and since we don't use requirejs, intrinsically hard)
41
+ - hooks could be improved to specify method (get/post), and to pass params -- passing to the blocks if they have arity
20
42
 
21
- Teabag has been renamed to Teaspoon. A deprecation notice was provided with the last release of the gem under the teabag name, and versions will continue to move forward from 0.7.3.
43
+ #### nice to haves
22
44
 
23
- Updating requires that you rename your `teabag.rb` initializer to `teaspoon.rb`, and `teabag_env.rb` to `teaspoon_env.rb`. Replacing any references to teabag to teaspoon within them. Or if you've not made any changes just clean these files up and run the install generator again.
45
+ - a more useful rake task library (like rspec https://www.relishapp.com/rspec/rspec-core/docs/command-line/rake-task)
46
+ - rspec interface, so rspec reporters can be used
24
47
 
25
48
 
26
49
  ## Screenshots
@@ -41,8 +64,8 @@ Updating requires that you rename your `teabag.rb` initializer to `teaspoon.rb`,
41
64
  2. [Usage](#usage)
42
65
  3. [Writing Specs](#writing-specs)
43
66
  4. [Fixtures](#fixtures)
44
- 5. [Coverage](#coverage)
45
- 6. [Suites](#suites)
67
+ 5. [Suites](#suites)
68
+ 6. [Coverage](#coverage)
46
69
  7. [Configuration](#configuration)
47
70
  8. [Test Frameworks](#test-frameworks)
48
71
  9. [Support Libraries](#support-libraries)
@@ -51,92 +74,102 @@ Updating requires that you rename your `teabag.rb` initializer to `teaspoon.rb`,
51
74
 
52
75
  ## Installation
53
76
 
54
- Add it to your Gemfile. In most cases you'll want to restrict it to the `:development, :test` or `:asset` groups.
55
-
56
- You should [install phantomjs](http://phantomjs.org/download.html). If phantomjs is found it will be used, otherwise you can use the gem as a fallback -- which might not be optimal.
77
+ Add it to your Gemfile. In most cases you'll want to restrict it to the `:development, :test` groups.
57
78
 
58
79
  ```ruby
59
80
  group :development, :test do
60
- gem "phantomjs", ">= 1.8.1.1" # this is optional if you install phantomjs manually (as of teaspoon 0.7.9)
61
81
  gem "teaspoon"
62
82
  end
63
83
  ```
64
84
 
65
- Optionally run the install generator to get the initializer and a basic spec helper.
85
+ Run the install generator to get the environment file and a basic spec helper. You can tell the generator which framework you want to use, if you want a coffeescript spec helper, etc. Run the install generator with the `--help` flag for a list of available options.
66
86
 
67
87
  ```
68
- rails generate teaspoon:install
88
+ rails generate teaspoon:install --framework=mocha --coffee
69
89
  ```
70
90
 
71
- You can tell the generator which framework you want to use, if you want coffeescript spec helper files, and if you want the env file created (used by the command line interface).
91
+ To run Teaspoon headless you'll need Selenium Webdriver or PhantomJS. We recommend PhantomJS, which you can install with homebrew, npm or [as a download](http://phantomjs.org/download.html).
72
92
 
73
93
  ```
74
- rails generate teaspoon:install --framework=mocha --coffee
94
+ brew install phantomjs
95
+ - OR -
96
+ npm install -g phantomjs
75
97
  ```
76
98
 
99
+ The PhantomJS binary will be used by default if it's available in your path, otherwise you can use the gem as a fallback.
100
+
101
+ ```ruby
102
+ group :development, :test do
103
+ gem "teaspoon"
104
+ gem "phantomjs", ">= 1.8.1.1" # this is optional if the phantomjs binary is installed (as of teaspoon 0.7.9)
105
+ end
106
+ ```
107
+
108
+ ### Upgrading
109
+
110
+ We made some changes to how configuration and loading works for version 0.8.0, which might cause some confusion. For this we're sorry, but it'll be better in the long run -- and hey, on the up side, we didn't write a javascript test runner and then abandon it.
111
+
112
+ 1. backup your `spec/teaspoon_env.rb` file.
113
+ 2. run the install generator to get the new `teaspoon_env.rb`.
114
+ 3. migrate your old settings into the new file, noting the changes that might exist.
115
+ 4. move all settings that you had in `config/initializers/teaspoon.rb` into `spec/teaspoon_env.rb` and delete the initializer.
116
+
117
+
77
118
  ## Usage
78
119
 
79
- Teaspoon uses the Rails asset pipeline to serve files. This allows you to use `= require` in your test files, and allows you use things like HAML or RABL/JBuilder within your fixtures. You can run Teaspoon in three ways -- in the browser, via the rake task, and using the command line interface.
120
+ Teaspoon uses the Rails asset pipeline to serve files. This allows you to use `= require` in your test files, and allows you use things like HAML or RABL/JBuilder within your fixtures.
80
121
 
81
122
  Here's a great [Quick Start Walkthrough](https://github.com/modeset/teaspoon/wiki/Quick-Start-Walkthrough) for writing and running your first tests.
82
123
 
124
+ You can run Teaspoon three ways -- in the browser, via the rake task, and using the command line interface (CLI).
125
+
83
126
  ### Browser
84
127
 
85
128
  ```
86
129
  http://localhost:3000/teaspoon
87
130
  ```
88
131
 
89
- You can focus tests in various ways, and Teaspoon provides an interface to run focus tests by suite, file, and filter.
90
-
91
132
  ### Rake
92
133
 
93
- The rake task provides several ways of foucusing tests. You can specify the suite to run, the files to run, and/or directories to run.
134
+ ```
135
+ rake teaspoon
136
+ ```
137
+
138
+ The rake task provides several ways of focusing tests. You can specify the suite to run, the files to run, directories to run, etc.
94
139
 
95
140
  ```
96
141
  rake teaspoon suite=my_fantastic_suite
97
- rake teaspoon files=test/javascripts/controllers/my_controller_test.js
98
- rake teaspoon files=test/javascripts/integration,test/javascripts/models
99
- rake teaspoon files=test/javascripts/integration,test/javascripts/models,test/javascripts/controllers/my_controller_test.js
100
- rake teaspoon suite=my_fantastic_suite files=test/javascripts/integration,test/javascripts/models,test/javascripts/controllers/my_controller_test.js
142
+ rake teaspoon files=spec/javascripts/integration,spec/javascripts/calculator_spec.js
101
143
  ```
102
144
 
103
- ### Command Line Interface
104
-
105
- The command line interface requires a `teaspoon_env.rb` file that you can get by running the generator. This file is used to load the Rails environment so Teaspoon can run within the context of Rails. This file can be in the spec, test, or root path -- but can be specified using the `--require` option.
145
+ ### CLI
106
146
 
107
147
  ```
108
148
  bundle exec teaspoon
109
149
  ```
110
150
 
111
- The CLI provides several ways of focusing tests. You can specify the suite to run, the files to run, directories to run, and a filter.
151
+ The CLI also provides several ways of focusing tests. You can specify the suite to run, the files to run, directories to run, filters, etc.
112
152
 
113
153
  ```
114
154
  bundle exec teaspoon --suite=my_fantastic_suite
115
- bundle exec teaspoon spec/javascripts/calculator_spec.js
116
- bundle exec teaspoon spec/javascripts/integration
155
+ bundle exec teaspoon spec/javascripts/integration spec/javascripts/calculator_spec.js
117
156
  bundle exec teaspoon --filter="Calculator should add two digits"
118
157
  ```
119
158
 
120
- Teaspoon also has support for [tapout](https://github.com/rubyworks/tapout). Use the tap_y formatter and pipe the results to tapout to use any of the reporters that tapout provides.
121
-
122
- ```
123
- bundle exec teaspoon -q --format=tap_y | tapout progress
124
- ```
125
-
126
159
  Get full command line help:
127
160
 
128
161
  ```
129
162
  bundle exec teaspoon --help
130
163
  ```
131
164
 
132
- **Note:** By default the rake task and command line interface run within the development environment, but you can specify the environment using `RAILS_ENV=test rake teaspoon`. This is to stay consistent with what you might see in the browser (since that's likely running in development).
165
+ **Note:** The rake task and CLI run within the development environment unless otherwise specified.
133
166
 
134
167
 
135
168
  ## Writing Specs
136
169
 
137
- Depending on what framework you use this can be slightly different. There's an expectation that you have a certain level of familiarity with the test framework that you're using. Right now Teaspoon supports [Jasmine](http://pivotal.github.com/jasmine), [Mocha](http://visionmedia.github.com/mocha) and [QUnit](http://qunitjs.com).
170
+ Depending on which framework you use this can differ, and there's an expectation that you have a certain level of familiarity with your chosen test framework.
138
171
 
139
- Since we have the asset pipeline at our fingertips you can feel free to use the `= require` directive throughout your specs and spec helpers.
172
+ Teaspoon supports [Jasmine](http://pivotal.github.com/jasmine), [Mocha](http://visionmedia.github.com/mocha) and [QUnit](http://qunitjs.com). And since it's possible to use the asset pipeline, feel free to use the `= require` directive throughout your specs and spec helpers.
140
173
 
141
174
  Here's a basic spec written in Javascript using Jasmine:
142
175
 
@@ -152,72 +185,69 @@ describe("My great feature", function() {
152
185
  });
153
186
  ```
154
187
 
155
- Check out examples of a [Mocha Spec](https://github.com/modeset/teaspoon/wiki/Using-Mocha), a [QUnit Test](https://github.com/modeset/teaspoon/wiki/Using-QUnit), and an [Angular Test](https://github.com/modeset/teaspoon/wiki/Using-Angular).
188
+ You can also check out the examples of a [Mocha Spec](https://github.com/modeset/teaspoon/wiki/Using-Mocha), and a [QUnit Test](https://github.com/modeset/teaspoon/wiki/Using-QUnit).
156
189
 
157
190
  ### Pending Specs
158
191
 
159
- We've normalized declaring that a spec is pending between Mocha and Jasmine. Since Jasmine lacks the concept we've added it in, and since Mocha has several ways to accomplish it we thought it would be worth mentioning what we consider the standard between the two to be. QUnit doesn't support specifying a test as pending.
192
+ Every test framework is different, but we've tried to normalize some of those differences. For instance, Jasmine lacks the concept pending, while Mocha provides several ways to achieve this. So we thought it would be worth defining what is standard between the two frameworks. QUnit doesn't easily support the concept of pending, so that's not covered.
160
193
 
161
- To mark a spec as pending you can either not provide a function as the second argument to `it`, or you can use `xit` and `xdescribe`. Mocha provides some additional ways to accomplish this, but to keep it consistent we've normalized on what they both support.
194
+ To mark a spec as pending in both Mocha and Jasmine, you can either not provide a function as the second argument to the `it` call, or you can use `xit` and `xdescribe`.
162
195
 
163
- ```coffeescript
164
- describe "My great feature", ->
196
+ ```javascript
197
+ describe("My great feature", function() {
198
+ it("hasn't been tested yet");
165
199
 
166
- it "hasn't been tested yet"
200
+ xit("has a test I can't figure out", function() {
201
+ expect("complexity").to.be("easily testable");
202
+ });
167
203
 
168
- xit "has a test I can't figure out" ->
169
- expect("complexity").to.be("easily testable")
204
+ xdescribe("A whole section that I've not gotten to", function() {
205
+ it("hasn't been tested yet", function() {
206
+ expect(true).to.be(false);
207
+ });
208
+ });
209
+ });
210
+ ```
170
211
 
171
- xdescribe "A whole section that I've not gotten to", ->
212
+ ### Deferring Execution
172
213
 
173
- it "hasn't been tested yet", ->
174
- expect(true).to.be(false)
175
- ```
214
+ Teaspoon allows deferring execution, which can be useful for asynchronous execution.
176
215
 
177
- If you're using a specific framework and you want to take advantage of the things that framework provides you're free to do so. This is provided as the standard as the Teaspoon reporters understand the techniques above and have specs for them.
216
+ ```javascript
217
+ Teaspoon.defer = true;
218
+ setTimeout(Teaspoon.execute, 1000); // defers execution for 1 second as an example
219
+ ```
178
220
 
179
221
  ### Using Require.js
180
- If you are using require.js to get your files you can set a configuration option for your suite of "use_require".
181
- ```ruby
182
- Teaspoon.setup do |config|
183
- config.suite do |suite|
184
- suite.use_require = true
185
- end
186
- end
187
- ```
188
- Then in your suite spec helper, add require.js to be included, if you have not already. (Note: Teaspoon doesn't include require.js with it, so you will need to provide your own require.js and require the correct path.)
222
+
223
+ You can configure your suite to boot with require.js by setting the suite `boot_partial` directive to `"boot_require_js"`.
224
+
225
+ Be sure to require `require.js` in your spec helper. Teaspoon doesn't include it as a support library, so you'll need to provide your own.
226
+
189
227
  ```javascript
190
228
  //= require require
191
229
  ```
192
230
 
193
- Once you've done that, when that suite is executed, Teaspoon will use require.js to get all the specs in the suite (or specific files). In your specs you will need to use require to pull down the dependencies as you would normally. Here is an example with mocha.
231
+ Now require.js will be used to load all the specs in your suite, however, you'll still need to use require.js to pull down the dependencies as you would normally.
232
+
194
233
  ```javascript
195
- define(['Model'] , function (Model) {
196
- describe('Model' , function () {
197
- // put your tests here
234
+ define(['Model'], function (Model) {
235
+ describe('Model', function () {
236
+ // ...
198
237
  });
199
238
  });
200
239
  ```
201
240
 
202
- ### Deferring Execution
203
-
204
- Teaspoon allows deferring execution in the cases when you're using AMD or other asynchronous libraries. This is especially useful if you're using [CommonJS](http://www.commonjs.org/), etc. You can tell Teaspoon to defer and then execute the runner yourself later -- after loading asychronously. There's a wiki article about how you can setup your specs and spec helper when using [RequireJS with Teaspoon](https://github.com/modeset/teaspoon/wiki/RequireJS-with-Teaspoon).
205
-
206
- ```javascript
207
- Teaspoon.defer = true;
208
- setTimeout(Teaspoon.execute, 1000); // defers execution for 1 second
209
- ```
210
-
211
241
 
212
242
  ## Fixtures
213
243
 
214
- You're free to use your own fixture library (like jasmine-jquery, which we've included as a support library), but Teaspoon ships with a fixture library that works with Jasmine, Mocha, and QUnit with a minimum of effort, has a nice consistent API, and isn't dependent on jQuery.
244
+ Teaspoon ships with a fixture library that works with Jasmine, Mocha, and QUnit with a minimum of effort, has a nice consistent API, and isn't dependent on jQuery.
215
245
 
216
- The fixture path is configurable within Teaspoon, and the views will be rendered by a standard controller. This allows you to use things like RABL/JBuilder if you're building JSON, or HAML if you're building markup. The element that Teaspoon creates is "#teaspoon-fixtures", in case you need to access it directly -- or you can access it via `fixture.el` after loading fixtures.
246
+ The fixture path is configurable within Teaspoon, and the views will be rendered by a standard controller. This allows you to use things like RABL/JBuilder if you're building JSON, or HAML if you're building markup.
217
247
 
218
248
  ### Loading Files
219
249
 
220
- Loading fixtures allows you to specify any number of files to load, and if they should be appended to the fixture element, or replace what's currently there.
250
+ Loading fixtures allows you to specify any number of files to load, and if they should be appended to the fixture element or replace what's currently there.
221
251
 
222
252
  `fixture.load(url[, url, ...], append = false)` or `fixture(url[, url, ...], append = false)`
223
253
 
@@ -235,44 +265,105 @@ You shouldn't have to cleanup (we do that for you based on your test framework),
235
265
 
236
266
  ### Preloading Files
237
267
 
238
- Some test cases require stubbing Ajax requests, and in those cases you may want to preload the fixture files -- which caches them for later. You can preload fixtures in your spec helper, or before you start mocking Ajax methods.
268
+ Some test cases require stubbing Ajax requests, and in those cases you may want to preload the fixture files to cache them for later. You can preload fixtures in your spec helper, or before you start mocking Ajax methods.
239
269
 
240
270
  `fixture.preload(url[, url, ...])`
241
271
 
242
272
  ### Example Usage
243
273
 
244
- ```coffeescript
245
- fixture.preload("fixture.html", "fixture.json") # make the actual requests for the files
246
- describe "Using fixtures", ->
247
-
248
- fixture.set("<h2>Another Title</h2>") # create some markup manually (will be in a beforeEach)
274
+ ```javascript
275
+ fixture.preload("fixture.html", "fixture.json"); // make the actual requests for the files
276
+ describe("Using fixtures", function() {
277
+ fixture.set("<h2>Another Title</h2>"); // create some markup manually (will be in a beforeEach)
249
278
 
250
- beforeEach ->
251
- @fixtures = fixture.load("fixture.html", "fixture.json", true) # append these fixtures which were already cached
279
+ beforeEach(function() {
280
+ this.fixtures = fixture.load("fixture.html", "fixture.json", true); // append these fixtures which were already cached
281
+ });
252
282
 
253
- it "loads fixtures", ->
254
- expect($("h1", fixture.el).text()).toBe("Title") # using fixture.el as a jquery scope
283
+ it("loads fixtures", function() {
284
+ expect($("h1", fixture.el).text()).toBe("Title") // using fixture.el as a jquery scope
255
285
  expect($("h2", fixture.el).text()).toBe("Another Title")
256
- expect(@fixtures[0]).toBe(fixture.el) # the element is available as a return value and through fixture.el
257
- expect(@fixtures[1]).toEqual(fixture.json[0]) # the json for json fixtures is returned, and available in fixture.json
286
+ expect(this.fixtures[0]).toBe(fixture.el) // the element is available as a return value and through fixture.el
287
+ expect(this.fixtures[1]).toEqual(fixture.json[0]) // the json for json fixtures is returned, and available in fixture.json
288
+ });
289
+ });
258
290
  ```
259
291
 
260
- Check out some example of using fixtures with [Mocha](https://github.com/modeset/teaspoon/wiki/Using-Mocha), [QUnit](https://github.com/modeset/teaspoon/wiki/Using-QUnit), and [Angular](https://github.com/modeset/teaspoon/wiki/Using-Angular).
292
+ Check out some example of using fixtures with [Mocha](https://github.com/modeset/teaspoon/wiki/Using-Mocha), [QUnit](https://github.com/modeset/teaspoon/wiki/Using-QUnit).
293
+
294
+ **Note:** The element that Teaspoon creates is "#teaspoon-fixtures", in case you need to access it directly.
295
+
296
+
297
+ ## Suites
298
+
299
+ Teaspoon uses the concept of suites to group tests at a high level. These suites run in isolation and can have different configurations.
300
+
301
+ A default suite has been generated for you in your `teaspoon_env.rb`.
302
+
303
+ Suites inherit from a "default" suite. To modify the "default" suite simply don't specify a name for the suite. In this example we're configuring the default suite, which all other suites will inherit from.
304
+
305
+ ```ruby
306
+ config.suite do |suite|
307
+ suite.helper = "other_spec_helper.js"
308
+ end
309
+ ```
310
+
311
+ When defining a custom suite, provide a name and a block. The following example defines a suite named "my_suite".
312
+
313
+ ```ruby
314
+ config.suite :my_suite do |suite|
315
+ suite.helper = "my_spec_helper.js"
316
+ end
317
+ ```
318
+
319
+ ### Hooks
320
+
321
+ Hooks are designed to facilitate loading fixtures or other things that might be required on the back end before, after, or during running a suite or test. You can define hooks in your suite by specifying a name and a block. Hooks with the same name will be added to an array, and all will be called when the hook is requested. If you don't specify a name, :default will be assumed.
322
+
323
+ ```ruby
324
+ config.suite :my_suite do |suite|
325
+ suite.hook :fixtures do
326
+ # some code that would load your fixtures
327
+ end
328
+ end
329
+ ```
330
+
331
+ You can then use the javascript `Teaspoon.hook("fixtures")` call at the beginning of a suite run or similar. All blocks that have been specified for a given hook will be called in the order they were defined.
332
+
333
+ ### Manifest Style
334
+
335
+ Teaspoon is happy to look for files for you (and this is recommended), but you can disable this feature and maintain a manifest yourself. Configure the suite to not match any files, and then use your spec helper to create your manifest.
336
+
337
+ ```ruby
338
+ config.suite do |suite|
339
+ suite.matcher = nil
340
+ suite.helper = "spec_manifest"
341
+ end
342
+ ```
343
+
344
+ **Note:** This limits your ability to run specific files from the command line interface and other benefits, and so isn't recommended.
261
345
 
262
346
 
263
347
  ## Coverage
264
348
 
265
- Teaspoon can use [Istanbul](https://github.com/gotwarlost/istanbul) to generate code coverage statistics and reports. Install Istanbul and adjust the configuration to always generate coverage reports, or specify by passing `--coverage` to the command line interface. Check the [configuration](#configuration) for more information.
349
+ Teaspoon uses [Istanbul](https://github.com/gotwarlost/istanbul) to generate code coverage statistics and reports. You can define coverage configurations the same way you define suites.
350
+
351
+ Each suite allows specifying ignored files, which allows you to ignore support libraries and dependencies.
266
352
 
267
- Each suite allows you to specify which files should be ignored when generating coverage reports, which allows you to ignore support libraries and dependencies that you're not testing.
353
+ The following configuration and example generates a text and cobertura report -- and an annotated HTML report that you can inspect further.
268
354
 
269
- The following example will generate a simple text report and an HTML report with annotated source that you can inspect further.
355
+ ```ruby
356
+ config.coverage do |coverage|
357
+ coverage.reports = ['text', 'html', 'cobertura']
358
+ end
359
+ ```
270
360
 
271
361
  ```shell
272
- bundle exec teaspoon --coverage-reports=text,html
362
+ bundle exec teaspoon --coverage=default
273
363
  ```
274
364
 
275
- An example text report that's output to the console after the tests have completed.
365
+ If you use the `"text"`, or `"text-summary"` reports, they will be output to the console after the tests have completed.
366
+
276
367
  ```
277
368
  --------------------+-----------+-----------+-----------+-----------+
278
369
  File | % Stmts |% Branches | % Funcs | % Lines |
@@ -284,99 +375,109 @@ All files | 93.75 | 75 | 94.12 | 93.65 |
284
375
  --------------------+-----------+-----------+-----------+-----------+
285
376
  ```
286
377
 
287
- Teaspoon can have thresholds to fail the build (i.e. return an exit code not equal to zero). These are the same as istanbul: statement, function, branch and line coverage thresholds. They can be set in your environment file:
378
+ ### Thresholds
379
+
380
+ Teaspoon allows defining coverage threshold requirements. If a threshold is not met, it will cause a test run failure.
381
+
382
+ This example would cause a failure if less than 50% of the statements were not covered by the tests for instance.
288
383
 
289
384
  ```ruby
290
- Teaspoon.setup do |config|
291
- config.statements_coverage_threshold = 50
292
- config.functions_coverage_threshold = 50
293
- config.branches_coverage_threshold = 50
294
- config.lines_coverage_threshold = 50
385
+ config.coverage :CI do |coverage|
386
+ coverage.statements = 50
387
+ coverage.functions = 50
388
+ coverage.branches = 50
389
+ coverage.lines = 50
295
390
  end
296
391
  ```
297
392
 
298
- or on the command line:
299
-
300
- ```shell
301
- bundle exec teaspoon --coverage true --statements-coverage-threshold 50 --functions-coverage-threshold 50 --branches-coverage-threshold 50 --lines-coverage-threshold 50
302
- ```
303
393
 
394
+ ## Configuration
304
395
 
305
- ## Suites
396
+ When you install Teaspoon a `teaspoon_env.rb` file is generated that contains most of this information, but we've provided it here too.
306
397
 
307
- Teaspoon uses the concept of suites to group your tests at a high level. These suites are run in isolation from one another, and can have different configurations. You can define suites in the configuration, and for brevity `config` is the argument passed to the `Teaspoon.setup` block.
398
+ <dl>
308
399
 
309
- When creating a suite, provide a name (optional) and a block. The following example defines a suite named "my_suite". You can focus run this suite by browsing to `/teaspoon/my_suite` or running the rake task with `suite=my_suite`.
400
+ <dt> mount_at </dt><dd>
401
+ Determines where the Teaspoon routes will be mounted. Changing this to "/jasmine" would allow you to browse to <code>http://localhost:3000/jasmine</code> to run your tests.<br/><br/>
310
402
 
311
- ```ruby
312
- config.suite :my_suite do |suite|
313
- suite.helper = "my_spec_helper.js"
314
- end
315
- ```
403
+ <b>default:</b> <code>"/teaspoon"</code>
404
+ </dd>
316
405
 
317
- There's always a "default" suite defined, and to modify this suite just don't specify a name, or use `:default`. In this example we're setting the default suite configuration.
406
+ <dt> root </dt><dd>
407
+ Specifies the root where Teaspoon will look for files. If you're testing an engine using a dummy application it can be useful to set this to your engines root (e.g. <code>Teaspoon::Engine.root</code>).<br/>
408
+ <b>Note:</b> Defaults to <code>Rails.root</code> if nil.<br/><br/>
318
409
 
319
- ```ruby
320
- config.suite do |suite|
321
- suite.helper = "other_spec_helper.js"
322
- end
323
- ```
410
+ <b>default:</b> <code>nil</code>
411
+ </dd>
324
412
 
325
- **Note:** Suites inherit from the default suite, so default configuration will propagate to all other suites.
413
+ <dt> asset_paths </dt><dd>
414
+ Paths that will be appended to the Rails assets paths.<br/>
415
+ <b>Note:</b> Relative to <code>config.root</code>.<br/><br/>
326
416
 
327
- ### Manifest Style
417
+ <b>default:</b> <code>["spec/javascripts", "spec/javascripts/stylesheets", "test/javascripts", "test/javascripts/stylesheets"]</code>
418
+ </dd>
328
419
 
329
- Teaspoon is happy to look for files for you, but you can disable this feature and maintain a manifest yourself. Each suite can utilize a different spec helper and you can use these to create your own manifest using the `= require` directive. This isn't recommended because it limits your abilities to run specific files from the command line interface, but it's available if you want to use it.
420
+ <dt> fixture_paths </dt><dd>
421
+ Fixtures are rendered through a controller, which allows using HAML, RABL/JBuilder, etc. Files in this path will be rendered as fixtures.<br/><br/>
330
422
 
331
- Tell the suite that you don't want it to match any files, and then require files in your spec helper.
423
+ <b>default:</b> <code>["spec/javascripts/fixtures", "test/javascripts/fixtures"]</code>
424
+ </dd>
332
425
 
333
- ```ruby
334
- config.suite do |suite|
335
- suite.matcher = nil
336
- suite.helper = "spec_manifest"
337
- end
338
- ```
426
+ </dl>
339
427
 
340
428
  ### Suite Configuration Directives
341
429
 
342
430
  <dl>
343
431
 
344
- <dt> matcher </dt><dd>
345
- You can specify a file matcher and all matching files will be loaded when the suite is run. It's important that these files can be served via sprockets / are within an asset path.<br/><br/>
432
+ <dt> use_framework(name[, version]) </dt><dd>
433
+ Specify the framework and optionally version you would like to use. This will do some basic setup for you -- which you can override with the directives below. This should be specified first, as it can override other directives.<br/><br/>
434
+ <b>Note:</b> If no version is specified, the latest is assumed.<br/><br/>
346
435
 
347
- <b>Note:</b> Can also be set to <code>nil</code>.<br/><br/>
436
+ <b>available:</b> jasmine[1.3.1, 2.0.0], mocha[1.10.0, 1.17.1] qunit[1.12.0, 1.14.0]<br/>
437
+ <b>default:</b> <code>[no default]</code>
438
+ </dd>
439
+
440
+ <dt> matcher </dt><dd>
441
+ Specify a file matcher as a regular expression and all matching files will be loaded when the suite is run. These files need to be within an asset path. You can add asset paths using the `config.asset_paths`.<br/>
442
+ <b>Note:</b> Can be set to <code>nil</code> to match no files.<br/><br/>
348
443
 
349
444
  <b>default:</b> <code>"{spec/javascripts,app/assets}/**/*_spec.{js,js.coffee,coffee}"</code>
350
445
  </dd>
351
446
 
352
447
  <dt> helper </dt><dd>
353
- Each suite can load a different spec helper, which can in turn require additional files. This file is loaded before your specs are loaded, and can be used as a manifest.<br/><br/>
448
+ This suites spec helper, which can require additional support files. This file is loaded before any of your test files are loaded.<br/><br/>
354
449
 
355
450
  <b>default:</b> <code>"spec_helper"</code>
356
451
  </dd>
357
452
 
358
453
  <dt> javascripts </dt><dd>
359
- These are the core Teaspoon javascripts. It's strongly encouraged to include only the base files here. You can require other support libraries in your spec helper, which allows you to change them without having to restart the server.<br/><br/>
360
-
361
- <b>Note:</b> To use the CoffeeScript source files use <code>"teaspoon/jasmine"</code> etc.<br/><br/>
454
+ The core Teaspoon javascripts. If you're using the `use_framework` directive this will be set based on that, but it can be useful to provide an override to use a custom version of a test framework.<br/>
455
+ <b>Note:</b> It's recommended to only include the core files here, as you can require support libraries from your spec helper.<br/>
456
+ <b>Note:</b> For CoffeeScript files use <code>"teaspoon/jasmine"</code> etc.<br/><br/>
362
457
 
363
458
  <b>available:</b> teaspoon-jasmine, teaspoon-mocha, teaspoon-qunit<br/>
364
- <b>default:</b> <code>["teaspoon-jasmine"]</code>
459
+ <b>default:</b> <code>["jasmine/1.3.1", "teaspoon-jasmine"]</code>
365
460
  </dd>
366
461
 
367
462
  <dt> stylesheets </dt><dd>
368
- If you want to change how Teaspoon looks, or include your own stylesheets you can do that here. The default is the stylesheet for the HTML reporter.<br/><br/>
369
-
370
- <b>Note:</b> Spec related CSS can and should be loaded using fixtures.
463
+ You can include your own stylesheets if you want to change how Teaspoon looks.<br/>
464
+ <b>Note:</b> Spec related CSS can and should be loaded using fixtures.<br/><br/>
371
465
 
372
466
  <b>default:</b> <code>["teaspoon"]</code>
373
467
  </dd>
374
468
 
375
- <dt> no_coverage </dt><dd>
376
- When running coverage reports, you probably want to exclude libraries that you're not testing.
377
- Accepts an array of filenames or regular expressions. The default is to exclude assets from vendors or gems.<br/><br/>
469
+ <dt> boot_partial </dt><dd>
470
+ Partial to be rendered in the head tag of the runner. You can use the provided ones or define your own by creating a `_boot.html.erb` in your fixtures path, and adjust the config to `"/boot"` for instance.<br/><br/>
378
471
 
379
- <b>default:</b> <code>`[%r{/lib/ruby/gems/}, %r{/vendor/assets/}, %r{/support/}, %r{/(.+)_helper.}]`</code>
472
+ <b>available:</b> boot, boot_require_js<br/>
473
+ <b>default:</b> <code>"boot"</code>
474
+ </dd>
475
+
476
+ <dt> normalize_asset_path </dt><dd>
477
+ When using custom file-extensions you might need to supply a custom asset path normalization. If you need to match a
478
+ custom extension, simply supply a custom lambda/proc that returns the desired filename.<br/><br/>
479
+
480
+ <b>default:</b> <code>`filename.gsub('.erb', '').gsub(/(\.js\.coffee|\.coffee)$/, ".js")`</code>
380
481
  </dd>
381
482
 
382
483
  </dl>
@@ -386,180 +487,212 @@ end
386
487
 
387
488
  The best way to read about the configuration options is to generate the initializer and env, but we've included the info here as well.
388
489
 
389
- **Note:** `Teaspoon.setup` may not be available in all environments, so the generator wraps it within a check.
390
-
391
- <dl>
392
-
393
- <dt> mount_at </dt><dd>
394
- This determines where the Teaspoon routes will be mounted. Changing this to "/jasmine" would allow you to browse to http://localhost:3000/jasmine to run your specs.<br/><br/>
490
+ <dt> body_partial </dt><dd>
491
+ Partial to be rendered in the body tag of the runner. You can define your own to create a custom body structure.<br/><br/>
395
492
 
396
- <b>default:</b> <code>"/teaspoon"</code>
493
+ <b>default:</b> <code>"body"</code>
397
494
  </dd>
398
495
 
399
- <dt> root </dt><dd>
400
- This defaults to Rails.root if left nil. If you're testing an engine using a dummy application it can be useful to set this to your engines root.. E.g. <code>Teaspoon::Engine.root</code><br/><br/>
401
-
402
- <b>default:</b> <code>nil</code>
403
- </dd>
404
-
405
- <dt> asset_paths </dt><dd>
406
- These paths are appended to the Rails assets paths (relative to config.root), and by default is an array that you can replace or add to.<br/><br/>
496
+ <dt> no_coverage </dt><dd>
497
+ Assets to be ignored when generating coverage reports. Accepts an array of filenames or regular expressions. The default excludes assets from vendor, gems and support libraries.<br/><br/>
407
498
 
408
- <b>default:</b> <code>["spec/javascripts", "spec/javascripts/stylesheets", "test/javascripts", "test/javascripts/stylesheets"]</code>
499
+ <b>default:</b> <code>[%r{/lib/ruby/gems/}, %r{/vendor/assets/}, %r{/support/}, %r{/(.+)_helper.}]</code>
409
500
  </dd>
410
501
 
411
- <dt> fixture_path </dt><dd>
412
- Fixtures are rendered through a standard controller. This means you can use things like HAML or RABL/JBuilder, etc. to generate fixtures within this path.<br/><br/>
502
+ <dt> hook(name, &block) </dt><dd>
503
+ Hooks allow you to use `Teaspoon.hook("fixtures")` before, after, or during your spec run. This will make a synchronous Ajax request to the server that will call all of the blocks you've defined for that hook name. (e.g. <code>suite.hook :fixtures, proc{ }</code>)
413
504
 
414
- <b>default:</b> <code>"spec/javascripts/fixtures"</code>
505
+ <b>default:</b> <code>Hash.new{ |h, k| h[k] = [] }</code>
415
506
  </dd>
416
507
 
417
508
  </dl>
418
509
 
419
- ### Console Runner Specific (Teaspoon Env)
510
+ ### Console Runner Specific
420
511
 
421
- These configuration directives are applicable only when running via the rake task or command line interface and should be set within the teaspoon_env.rb file. You can get this file by running the generator.
512
+ These configuration directives are applicable only when running via the rake task or command line interface. These directives can be overridden using the command line interface arguments or with ENV variables when using the rake task.
422
513
 
423
514
  <dl>
424
515
 
425
516
  <dt> driver </dt><dd>
426
- Allows you to specify which driver to use when running headlessly. Supports <a href="http://phantomjs.org">PhantomJS</a> and <a href="http://seleniumhq.org/docs/03_webdriver.jsp">Selenium Webdriver</a>.<br/><br/>
517
+ Specify which headless driver to use. Supports <a href="http://phantomjs.org">PhantomJS</a> and <a href="http://seleniumhq.org/docs/03_webdriver.jsp">Selenium Webdriver</a>.<br/><br/>
427
518
 
428
- Check this wiki article for information about <a href="https://github.com/modeset/teaspoon/wiki/Using-Selenium-WebDriver">Using Selenium WebDriver</a>, and this one about <a href="https://github.com/modeset/teaspoon/wiki/Using-PhantomJS">Using PhantomJS</a>.<br/><br/>
519
+ <a href="https://github.com/modeset/teaspoon/wiki/Using-PhantomJS">Using PhantomJS</a>.<br/>
520
+ <a href="https://github.com/modeset/teaspoon/wiki/Using-Selenium-WebDriver">Using Selenium WebDriver</a><br/><br/>
429
521
 
430
522
  <b>available:</b> phantomjs, selenium<br/>
431
523
  <b>default:</b> <code>"phantomjs"</code>
432
524
 
433
525
  <ul>
434
526
  <li>CLI: -d, --driver DRIVER</li>
435
- <li>ENV: DRIVER=selenium</li>
527
+ <li>ENV: DRIVER=[DRIVER]</li>
436
528
  </ul>
437
529
  </dd>
438
530
 
439
- <dt> driver_cli_options </dt><dd>
440
- An experimental feature to allow you to specify additional CLI options/switches. Currently this is only supported if using the 'phantomjs' driver.<br/><br/>
531
+ <dt> driver_options </dt><dd>
532
+ Specify additional options/switches for the driver.<br/><br/>
441
533
 
442
- Check this wiki article for information about <a href="https://github.com/ariya/phantomjs/wiki/API-Reference#command-line-options">PhantomJS Command-line Options</a>. Some options may cause Teaspoon to fail to function as expected/may not produce the expected result or may conflict with other options.<br/><br/>
534
+ <a href="https://github.com/modeset/teaspoon/wiki/Using-PhantomJS">Using PhantomJS</a>.<br/>
535
+ <a href="https://github.com/modeset/teaspoon/wiki/Using-Selenium-WebDriver">Using Selenium WebDriver</a><br/><br/>
443
536
 
444
537
  <b>default:</b> <code>nil</code>
445
538
 
446
539
  <ul>
447
- <li>CLI: -o, --driver-cli-options OPTIONS_STRING</li>
448
- <li>ENV: DRIVER_CLI_OPTIONS="--ssl-protocol=any --ssl-certificates-path=/path/to/certs"</li>
540
+ <li>CLI: --driver-options OPTIONS</li>
541
+ <li>ENV: DRIVER_OPTIONS=[OPTIONS]</li>
449
542
  </ul>
450
543
  </dd>
451
544
 
452
- <dt> server </dt><dd>
453
- Specify a server to use with Rack (eg. thin, mongrel). If nil is provided Rack::Server is used.<br/><br/>
545
+ <dt> driver_timeout </dt><dd>
546
+ Specify the timeout for the driver. Specs are expected to complete within this time frame or the run will be considered a failure. This is to avoid issues that can arise where tests stall.<br/><br/>
454
547
 
455
- <b>default:</b> <code>nil</code>
548
+ <b>default:</b> <code>180</code>
456
549
 
457
550
  <ul>
458
- <li>CLI: --server SERVER</li>
459
- <li>ENV: SERVER=thin</li>
551
+ <li>CLI: --driver-timeout SECONDS</li>
552
+ <li>ENV: DRIVER_TIMEOUT=[SECONDS]</li>
460
553
  </ul>
461
554
  </dd>
462
555
 
463
- <dt> server_timeout </dt><dd>
464
- Timeout for starting the server in seconds. If your server is slow to start you may have to bump this, or you may want to lower this if you know it shouldn't take long to start.<br/><br/>
556
+ <dt> server </dt><dd>
557
+ Specify a server to use with Rack (e.g. thin, mongrel). If nil is provided Rack::Server is used.<br/><br/>
465
558
 
466
- <b>default:</b> <code>20</code>
559
+ <b>default:</b> <code>nil</code>
467
560
 
468
561
  <ul>
469
- <li>CLI: --server-timeout SECONDS</li>
470
- <li>ENV: SERVER_TIMEOUT=10</li>
562
+ <li>CLI: --server SERVER</li>
563
+ <li>ENV: SERVER=[SERVER]</li>
471
564
  </ul>
472
565
  </dd>
473
566
 
474
567
  <dt> server_port </dt><dd>
475
- By default Teaspoon will locate an open port when starting the server, but if you want to run on a specific port you can do so by providing one.<br/><br/>
568
+ Specify a port to run on a specific port, otherwise Teaspoon will use a random available port.<br/><br/>
476
569
 
477
570
  <b>default:</b> <code>nil</code>
478
571
 
479
572
  <ul>
480
573
  <li>CLI: --server-port PORT</li>
481
- <li>ENV: SERVER_PORT=31337</li>
574
+ <li>ENV: SERVER_PORT=[PORT]</li>
482
575
  </ul>
483
576
  </dd>
484
577
 
578
+ <dt> server_timeout </dt><dd>
579
+ Timeout for starting the server in seconds. If your server is slow to start you may have to bump this, or you may want to lower this if you know it shouldn't take long to start.<br/><br/>
485
580
 
486
- <dt> fail_fast </dt><dd>
487
- If you have several suites it can be useful to make Teaspoon fail directly after any suite contains failures, but in environments like CI this may not be desirable.<br/><br/>
488
-
489
- <b>default:</b> <code>true</code>
581
+ <b>default:</b> <code>20</code>
490
582
 
491
583
  <ul>
492
- <li>CLI: --[no-]fail-fast</li>
493
- <li>ENV: FAIL_FAST=false</li>
584
+ <li>CLI: --server-timeout SECONDS</li>
585
+ <li>ENV: SERVER_TIMEOUT=[SECONDS]</li>
494
586
  </ul>
495
587
  </dd>
496
588
 
497
- <dt> formatters </dt><dd>
498
- You can specify the formatters that Teaspoon will use when outputting the results.<br/><br/>
589
+ <dt> fail_fast </dt><dd>
590
+ Force Teaspoon to fail immediately after a failing suite. Can be useful to make Teaspoon fail early if you have several suites, but in environments like CI this may not be desirable.<br/><br/>
499
591
 
500
- <b>available:</b> dot, tap, tap_y, swayze_or_oprah<br/>
501
- <b>default:</b> <code>"dot"</code>
592
+ <b>default:</b> <code>true</code>
502
593
 
503
594
  <ul>
504
- <li>CLI: -f, --format FORMATTERS</li>
505
- <li>ENV: FORMATTERS=dot,swayze_or_oprah</li>
595
+ <li>CLI: -F, --[no-]fail-fast</li>
596
+ <li>ENV: FAIL_FAST=[true/false]</li>
506
597
  </ul>
507
598
  </dd>
508
599
 
509
- <dt> suppress_log </dt><dd>
510
- Teaspoon pipes all console[log/debug/error] calls to STDOUT. This is useful to catch places where you've forgotten to remove them, but in verbose applications this may not be desirable.<br/><br/>
600
+ <dt> formatters </dt><dd>
601
+ Specify the formatters to use when outputting the results.<br/>
602
+ <b>Note:</b> Output files can be specified by using <code>"junit>/path/to/output.xml"</code>.<br/><br/>
511
603
 
512
- <b>default:</b> <code>false</code>
604
+ <b>available:</b> dot, documentation, clean, json, junit, pride, snowday, swayze_or_oprah, tap, tap_y, teamcity<br/>
605
+ <b>default:</b> <code>"dot"</code>
513
606
 
514
607
  <ul>
515
- <li>CLI: -q, --[no-]suppress-log</li>
516
- <li>ENV: SUPPRESS_LOG=true</li>
608
+ <li>CLI: -f, --format FORMATTERS</li>
609
+ <li>ENV: FORMATTERS=[FORMATTERS]</li>
517
610
  </ul>
518
611
  </dd>
519
612
 
520
613
  <dt> color </dt><dd>
521
- Specify if you want color output by default.<br/><br/>
614
+ Specify if you want color output from the formatters.<br/><br/>
522
615
 
523
616
  <b>default:</b> <code>true</code>
524
617
 
525
618
  <ul>
526
619
  <li>CLI: -c, --[no-]color</li>
527
- <li>ENV: COLOR=false</li>
620
+ <li>ENV: COLOR=[true/false]</li>
528
621
  </ul>
529
622
  </dd>
530
623
 
531
- <dt> coverage </dt><dd>
532
- Add instrumentation to your code and display coverage information. Requires <a href="https://github.com/gotwarlost/istanbul">istanbul</a>.<br/><br/>
624
+ <dt> suppress_log </dt><dd>
625
+ Teaspoon pipes all console[log/debug/error] to $stdout. This is useful to catch places where you've forgotten to remove them, but in verbose applications this may not be desirable.<br/><br/>
533
626
 
534
627
  <b>default:</b> <code>false</code>
535
628
 
536
629
  <ul>
537
- <li>CLI: -C, --coverage</li>
538
- <li>ENV: COVERAGE=true</li>
630
+ <li>CLI: -q, --[no-]suppress-log</li>
631
+ <li>ENV: SUPPRESS_LOG=[true/false]</li>
539
632
  </ul>
540
633
  </dd>
541
634
 
542
- <dt> coverage_reports </dt><dd>
543
- Specify which code coverage reports instanbul should generate.<br/><br/>
635
+ <dt> use_coverage </dt><dd>
636
+ Specify that you always want a coverage configuration to be used.<br/><br/>
544
637
 
545
- <b>available:</b> text-summary, text, html, lcov, lcovonly, cobertura<br/>
546
638
  <b>default:</b> <code>nil</code>
547
639
 
548
640
  <ul>
549
- <li>CLI: -R, --coverage-reports REPORTS</li>
550
- <li>ENV: COVERAGE_REPORTS=text,html</li>
641
+ <li>CLI: -C, --coverage=CONFIG_NAME</li>
642
+ <li>ENV: USE_COVERAGE=[CONFIG_NAME]</li>
551
643
  </ul>
552
644
  </dd>
553
645
 
554
- <dt> coverage_output_dir </dt><dd>
555
- Specify directory where coverage reports should be generated.<br/><br/>
646
+ </dl>
647
+
648
+ ### Coverage Configuration Directives
649
+
650
+ <dl>
651
+
652
+ <dt> reports </dt><dd>
653
+ Which coverage reports Instanbul should generate. Correlates directly to what Istanbul supports.<br/><br/>
654
+
655
+ <b>available:</b> text-summary, text, html, lcov, lcovonly, cobertura, teamcity<br/>
656
+ <b>default:</b> <code>["text-summary", "html"]</code>
657
+ </dd>
658
+
659
+ <dl>
660
+
661
+ <dt> output_dir </dt><dd>
662
+ The path that the coverage should be written to - when there's an artifact to write to disk.<br/>
663
+ <b>Note:</b> Relative to <code>config.root</code>.<br/><br/>
556
664
 
557
665
  <b>default:</b> <code>"coverage"</code>
666
+ </dd>
558
667
 
559
- <ul>
560
- <li>CLI: -O, --coverage-output-dir DIR</li>
561
- <li>ENV: COVERAGE_OUTPUT_DIR=coverage</li>
562
- </ul>
668
+ <dl>
669
+
670
+ <dt> statements </dt><dd>
671
+ Specify a statement threshold. If this coverage threshold isn't met the test run will fail. (0-100) or nil.<br/><br/>
672
+
673
+ <b>default:</b> <code>nil</code>
674
+ </dd>
675
+
676
+ <dl>
677
+
678
+ <dt> functions </dt><dd>
679
+ Specify a function threshold. If this coverage threshold isn't met the test run will fail. (0-100) or nil.<br/><br/>
680
+
681
+ <b>default:</b> <code>nil</code>
682
+ </dd>
683
+
684
+ <dl>
685
+
686
+ <dt> branches </dt><dd>
687
+ Specify a branch threshold. If this coverage threshold isn't met the test run will fail. (0-100) or nil.<br/><br/>
688
+
689
+ <b>default:</b> <code>nil</code>
690
+ </dd>
691
+
692
+ <dt> lines </dt><dd>
693
+ Specify a line threshold. If this coverage threshold isn't met the test run will fail. (0-100) or nil.<br/><br/>
694
+
695
+ <b>default:</b> <code>nil</code>
563
696
  </dd>
564
697
 
565
698
  </dl>
@@ -579,28 +712,31 @@ These configuration directives are applicable only when running via the rake tas
579
712
 
580
713
  We know that testing usually requires more than just the test framework, so we've included some of the libraries that we use on a regular basis.
581
714
 
582
- - [Sinon.JS](http://sinonjs.org) Standalone test spies, stubs and mocks for JavaScript. No dependencies, works with any unit testing framework.
583
- - [ChaiJS](http://chaijs.com/) BDD / TDD assertion library for node and the browser that can be delightfully paired with any javascript testing framework.
584
- - [expect.js](https://github.com/LearnBoost/expect.js) Minimalistic BDD assertion toolkit based on should.js.
585
- - [jasmine-jquery.js](https://github.com/velesin/jasmine-jquery) A set of custom matchers for jQuery, and an API for handling HTML fixtures in your specs.
586
- - [angular-scenario.js](https://github.com/angular/angular.js) Angular test setup.
715
+ - [Sinon.JS](http://sinonjs.org) (1.8.2) Standalone test spies, stubs and mocks for JavaScript. No dependencies, works with any unit testing framework. BSD Licence.
716
+ - [ChaiJS](http://chaijs.com/) (1.8.1) BDD / TDD assertion library for node and the browser that can be delightfully paired with any javascript testing framework. MIT License.
717
+ - [Sinon-Chai](https://github.com/domenic/sinon-chai) (1.0.0) Extends Chai with assertions for the Sinon.JS mocking framework. MIT-ish License.
718
+ - [expect.js](https://github.com/LearnBoost/expect.js) (0.1.2) Minimalistic BDD assertion toolkit based on should.js. MIT License.
719
+ - [jasmine-jquery-1.7.0.js](https://github.com/velesin/jasmine-jquery) (1.7.0) For Jasmine v1, A set of custom matchers for jQuery, and an API for handling HTML fixtures in your specs. MIT License.
720
+ - [jasmine-jquery-2.0.0.js](https://github.com/velesin/jasmine-jquery) (2.0.0) For Jasmine v2, A set of custom matchers for jQuery, and an API for handling HTML fixtures in your specs. MIT License.
587
721
 
588
722
  You can require these files in your spec helper by using:
589
723
 
590
724
  ```javascript
591
- //=require support/sinon
592
- //=require support/chai
593
- //=require support/expect
594
- //=require support/jasmine-jquery
595
- //=require support/angular-scenario
725
+ //= require support/sinon
726
+ //= require support/chai
727
+ //= require support/expect
728
+ //= require support/jasmine-jquery-1.7.0
729
+ //= require support/jasmine-jquery-2.0.0
596
730
  ```
597
731
 
598
732
 
599
733
  ## CI Support
600
734
 
601
- Teaspoon works great on CI setups. Add a line to execute Teaspoon (e.g. `bundle exec teaspoon`) in your CI config file. If you're using TravisCI or CircleCI it just works, but if you're using something else all you should need is to ensure phantomjs is installed.
735
+ Teaspoon works great on CI setups, and we've spent a good amount of time on getting that good. There's a lot of information to go over with that topic, but here are some highlights.
602
736
 
603
- You can add teaspoon to the default rake tasks by clearing out the defaults (this is sometimes not required), and then adding teaspoon in the chain where you want. So with rspec and cucumber, you get the rspec specs running first, then the javascript specs, and then cucumber (or whatever integration specs you have). This is what I do personally, and then I don't have to do any CI setup.
737
+ Add a line to execute Teaspoon (e.g. `bundle exec teaspoon`) in your CI config file. If you're using TravisCI or CircleCI it just works, but if you're using something else all you should need is to ensure PhantomJS is installed.
738
+
739
+ Alternately, you can add Teaspoon to the default rake tasks by clearing out the defaults (not always required), and then add `:teaspoon` into the chain of tasks where you want.
604
740
 
605
741
  ```ruby
606
742
  Rake::Task['default'].prerequisites.clear
@@ -609,39 +745,25 @@ Rake::Task['default'].clear
609
745
  task default: [:spec, :teaspoon, :cucumber]
610
746
  ```
611
747
 
612
- If you want to generate reports that CI can use you can install istanbul for coverage reports -- and output the report using the cobertura format, which Hudson can read.
613
-
614
- Again on hudson compatibile CI setups, you can track spec failure information/rate tracking by using the tap formatter, which can be parsed by hudson.
748
+ If you want to generate reports that CI can use you can install Istanbul for coverage reports -- and output the report using the cobertura format, which Hudson and some others can read. You can track spec failure rates by using the tap formatter, or on TeamCity setups you can use the teamcity formatter. A junit formatter is available as well.
615
749
 
616
- A good setup:
750
+ We encourage you to experiment and let us know. Feel free to create a wiki article about what you did to get it working on your CI setup.
617
751
 
618
- ```
619
- teaspoon -q --coverage-reports=cobertura --format=tap
620
- ```
621
752
 
622
- Or using Rake/ENV:
753
+ ## Alternative Projects
623
754
 
624
- ```
625
- SUPPRESS_LOG=true COVERAGE_REPORTS=cobertura FORMATTERS=tap rake
626
- ```
755
+ [Konacha](https://github.com/jfirebaugh/konacha)
756
+ [Jasminerice](https://github.com/bradphelan/jasminerice)
757
+ [Evergreen](https://github.com/abepetrillo/evergreen)
758
+ [jasmine-rails](https://github.com/searls/jasmine-rails)
759
+ [guard-jasmine](https://github.com/netzpirat/guard-jasmine)
627
760
 
628
- There is also a TeamCity formatter:
629
-
630
- ```
631
- teaspoon -q --format=teamcity
632
- ```
633
-
634
- Or using Rake/ENV:
635
-
636
- ```
637
- SUPPRESS_LOG=true FORMATTERS=teamcity rake
638
- ```
639
761
 
640
762
  ## License
641
763
 
642
764
  Licensed under the [MIT License](http://creativecommons.org/licenses/MIT/)
643
765
 
644
- Copyright 2012 [Mode Set](https://github.com/modeset)
766
+ Copyright 2014 [Mode Set](https://github.com/modeset)
645
767
 
646
768
  All licenses for the [bundled Javascript libraries](https://github.com/modeset/teaspoon/tree/master/vendor/assets/javascripts) are included (MIT/BSD).
647
769