teaspoon 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT.LICENSE +1 -1
- data/README.md +46 -377
- data/app/assets/javascripts/teaspoon-jasmine.js +200 -194
- data/app/assets/javascripts/teaspoon-mocha.js +183 -185
- data/app/assets/javascripts/teaspoon-qunit.js +201 -193
- data/app/assets/javascripts/teaspoon-teaspoon.js +10 -10
- data/app/assets/javascripts/teaspoon/base/fixture.coffee +0 -1
- data/app/assets/javascripts/teaspoon/base/hook.coffee +7 -6
- data/app/assets/javascripts/teaspoon/qunit.coffee +10 -0
- data/app/controllers/teaspoon/suite_controller.rb +3 -4
- data/app/views/teaspoon/suite/_boot.html.erb +1 -1
- data/app/views/teaspoon/suite/_boot_require_js.html.erb +1 -0
- data/bin/teaspoon +1 -1
- data/config/routes.rb +4 -14
- data/lib/generators/teaspoon/install/install_generator.rb +22 -11
- data/lib/generators/teaspoon/install/templates/jasmine/{env_comments.rb → env_comments.rb.tt} +10 -5
- data/lib/generators/teaspoon/install/templates/jasmine/spec_helper.coffee +5 -5
- data/lib/generators/teaspoon/install/templates/jasmine/spec_helper.js +5 -5
- data/lib/generators/teaspoon/install/templates/mocha/{env_comments.rb → env_comments.rb.tt} +10 -5
- data/lib/generators/teaspoon/install/templates/mocha/spec_helper.coffee +6 -5
- data/lib/generators/teaspoon/install/templates/mocha/spec_helper.js +6 -5
- data/lib/generators/teaspoon/install/templates/qunit/{env_comments.rb → env_comments.rb.tt} +10 -5
- data/lib/generators/teaspoon/install/templates/qunit/test_helper.coffee +5 -5
- data/lib/generators/teaspoon/install/templates/qunit/test_helper.js +5 -5
- data/lib/tasks/teaspoon.rake +1 -1
- data/lib/teaspoon/command_line.rb +37 -40
- data/lib/teaspoon/configuration.rb +27 -30
- data/lib/teaspoon/configuration.rb.orig +187 -0
- data/lib/teaspoon/console.rb +31 -17
- data/lib/teaspoon/coverage.rb +2 -3
- data/lib/teaspoon/deprecated.rb +13 -8
- data/lib/teaspoon/drivers/base.rb +2 -2
- data/lib/teaspoon/drivers/capybara_webkit_driver.rb +33 -0
- data/lib/teaspoon/drivers/phantomjs/runner.js +2 -2
- data/lib/teaspoon/drivers/phantomjs_driver.rb +13 -4
- data/lib/teaspoon/drivers/selenium_driver.rb +3 -5
- data/lib/teaspoon/engine.rb +33 -5
- data/lib/teaspoon/environment.rb +2 -4
- data/lib/teaspoon/exceptions.rb +8 -5
- data/lib/teaspoon/formatters/base.rb +39 -27
- data/lib/teaspoon/formatters/clean_formatter.rb +0 -1
- data/lib/teaspoon/formatters/description.rb +36 -0
- data/lib/teaspoon/formatters/documentation_formatter.rb +2 -2
- data/lib/teaspoon/formatters/json_formatter.rb +1 -2
- data/lib/teaspoon/formatters/junit_formatter.rb +20 -20
- data/lib/teaspoon/formatters/modules/report_module.rb +4 -4
- data/lib/teaspoon/formatters/pride_formatter.rb +0 -1
- data/lib/teaspoon/formatters/rspec_html_formatter.rb +463 -0
- data/lib/teaspoon/formatters/snowday_formatter.rb +0 -1
- data/lib/teaspoon/formatters/swayze_or_oprah_formatter.rb +5 -4
- data/lib/teaspoon/formatters/tap_formatter.rb +2 -3
- data/lib/teaspoon/formatters/tap_y_formatter.rb +20 -21
- data/lib/teaspoon/formatters/teamcity_formatter.rb +4 -5
- data/lib/teaspoon/instrumentation.rb +7 -7
- data/lib/teaspoon/result.rb +1 -3
- data/lib/teaspoon/runner.rb +1 -2
- data/lib/teaspoon/server.rb +2 -1
- data/lib/teaspoon/suite.rb +20 -17
- data/lib/teaspoon/utility.rb +1 -3
- data/lib/teaspoon/version.rb +1 -1
- data/spec/dummy/config/application.rb +14 -18
- data/spec/dummy/config/boot.rb +2 -6
- data/spec/dummy/config/environment.rb +3 -3
- data/spec/dummy/config/environments/development.rb +27 -13
- data/spec/dummy/config/environments/production.rb +79 -0
- data/spec/dummy/config/environments/test.rb +26 -13
- data/spec/dummy/config/routes.rb +1 -1
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/features/console_reporter_spec.rb +3 -8
- data/spec/features/hooks_spec.rb +17 -4
- data/spec/features/html_reporter_spec.rb +12 -1
- data/spec/features/install_generator_spec.rb +2 -3
- data/spec/features/instrumentation_spec.rb +11 -11
- data/spec/javascripts/teaspoon/base/teaspoon_spec.coffee +14 -1
- data/spec/spec_helper.rb +7 -4
- data/spec/teaspoon/command_line_spec.rb +19 -28
- data/spec/teaspoon/configuration_spec.rb +22 -14
- data/spec/teaspoon/console_spec.rb +79 -63
- data/spec/teaspoon/coverage_spec.rb +23 -23
- data/spec/teaspoon/drivers/capybara_webkit_driver_spec.rb +39 -0
- data/spec/teaspoon/drivers/phantomjs_driver_spec.rb +10 -5
- data/spec/teaspoon/drivers/selenium_driver_spec.rb +10 -10
- data/spec/teaspoon/environment_spec.rb +28 -20
- data/spec/teaspoon/exceptions_spec.rb +4 -4
- data/spec/teaspoon/exporter_spec.rb +28 -28
- data/spec/teaspoon/formatters/base_spec.rb +29 -29
- data/spec/teaspoon/formatters/clean_formatter_spec.rb +1 -1
- data/spec/teaspoon/formatters/documentation_formatter_spec.rb +1 -1
- data/spec/teaspoon/formatters/dot_formatter_spec.rb +1 -1
- data/spec/teaspoon/formatters/json_formatter_spec.rb +7 -7
- data/spec/teaspoon/formatters/junit_formatter_spec.rb +10 -10
- data/spec/teaspoon/formatters/pride_formatter_spec.rb +1 -1
- data/spec/teaspoon/formatters/rspec_html_formatter_spec.rb +107 -0
- data/spec/teaspoon/formatters/snowday_formatter_spec.rb +1 -1
- data/spec/teaspoon/formatters/tap_formatter_spec.rb +1 -1
- data/spec/teaspoon/formatters/tap_y_formatter_spec.rb +1 -1
- data/spec/teaspoon/formatters/teamcity_formatter_spec.rb +27 -27
- data/spec/teaspoon/instrumentation_spec.rb +35 -29
- data/spec/teaspoon/result_spec.rb +40 -36
- data/spec/teaspoon/runner_spec.rb +23 -20
- data/spec/teaspoon/server_spec.rb +19 -16
- data/spec/teaspoon/suite_spec.rb +23 -9
- data/spec/teaspoon_env.rb +7 -12
- data/test/javascripts/teaspoon/qunit/models_test.coffee +6 -2
- data/vendor/assets/javascripts/support/chai-1.10.0.js +4800 -0
- data/vendor/assets/javascripts/support/chai-jq-0.0.7.js +524 -0
- data/vendor/assets/javascripts/support/chai.js +4435 -4349
- metadata +57 -54
- data/app/assets/javascripts/teaspoon-angular.js +0 -1299
- data/app/assets/javascripts/teaspoon/angular.coffee +0 -55
- data/app/assets/javascripts/teaspoon/angular/reporters/console.coffee +0 -11
- data/app/assets/javascripts/teaspoon/angular/reporters/html.coffee +0 -21
- data/spec/javascripts/angular_helper.coffee +0 -5
- data/spec/javascripts/teaspoon/angular/models_aspec.coffee +0 -95
- data/spec/javascripts/teaspoon/angular/reporters/html_aspec.coffee +0 -9
- data/vendor/assets/javascripts/angular/1.0.5.js +0 -26195
- data/vendor/assets/javascripts/angular/MIT-LICENSE +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8ffc6219e0e838470408d91b594a02577eea996
|
4
|
+
data.tar.gz: 554631fbea03ee62eccc64e72e3a01058fcccf40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a01d5ce7d1720a38df484a26bbebc02a702e3f2b45031d130de8db4df46fe22d493823d309340a3cb158ec4f1399878f304f23d70b1b13f332ecac672549e0b8
|
7
|
+
data.tar.gz: 637de65f6914f5c5fca583c567ca2f6c2e82fb8a57764cced9816e1a782cd00f6e2ed053acd75ba6013254a7a3ddbfed26487c09355a5169e3b11e1d173d32d3
|
data/MIT.LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,50 +1,27 @@
|
|
1
1
|
Teaspoon
|
2
2
|
========
|
3
3
|
|
4
|
-
[![Gem Version](https://img.shields.io/gem/v/teaspoon.svg)](
|
5
|
-
[![Dependency Status](https://
|
4
|
+
[![Gem Version](https://img.shields.io/gem/v/guard-teaspoon.svg)](https://rubygems.org/gems/teaspoon)
|
5
|
+
[![Dependency Status](https://gemnasium.com/modeset/teaspoon.svg)](https://gemnasium.com/modeset/teaspoon)
|
6
6
|
[![Build Status](https://img.shields.io/travis/modeset/teaspoon.svg)](https://travis-ci.org/modeset/teaspoon)
|
7
|
-
[![Code Climate](https://
|
8
|
-
[![Coverage
|
7
|
+
[![Code Climate](https://codeclimate.com/github/modeset/teaspoon/badges/gpa.svg)](https://codeclimate.com/github/modeset/teaspoon)
|
8
|
+
[![Test Coverage](https://codeclimate.com/github/modeset/teaspoon/badges/coverage.svg)](https://codeclimate.com/github/modeset/teaspoon)
|
9
|
+
[![License](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)
|
9
10
|
|
10
11
|
<img src="https://raw.github.com/modeset/teaspoon/master/screenshots/logo_big.png" alt="Logo by Morgan Keys" align="right" />
|
11
12
|
<sup>Logo by [Morgan Keys](http://www.morganrkeys.com/)</sup>
|
12
13
|
|
13
|
-
Teaspoon is a Javascript test runner built for Rails. It
|
14
|
-
|
15
|
-
The goal is to be simple, while still providing the most complete Javascript testing solution for Rails.
|
16
|
-
|
17
|
-
Teaspoon takes advantage of the asset pipeline. And ships with support for Jasmine, Mocha, and QUnit.
|
18
|
-
|
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.
|
14
|
+
Teaspoon is a Javascript test runner built for Rails. It can run tests in the browser and headless using PhantomJS, Selenium WebDriver, or Capybara Webkit.
|
20
15
|
|
21
16
|
Feedback, ideas and pull requests are always welcome, or you can hit us up on Twitter @modeset_.
|
22
17
|
|
23
|
-
|
24
|
-
|
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:
|
18
|
+
[![Join the chat at https://gitter.im/modeset/teaspoon](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/modeset/teaspoon?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
34
19
|
|
35
|
-
|
20
|
+
The goal of Teaspoon is to stay simple while also providing the most complete Javascript testing solution for Rails.
|
36
21
|
|
37
|
-
|
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
|
42
|
-
|
43
|
-
#### nice to haves
|
44
|
-
|
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
|
22
|
+
Teaspoon takes advantage of the Rails asset pipeline, and ships with support for Jasmine, Mocha, and QUnit.
|
47
23
|
|
24
|
+
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. Or, if you want to use the [Spring](https://github.com/rails/spring) preloader, try the unofficial [spring-commands-teaspoon](https://github.com/alejandrobabio/spring-commands-teaspoon).
|
48
25
|
|
49
26
|
## Screenshots
|
50
27
|
|
@@ -82,32 +59,19 @@ group :development, :test do
|
|
82
59
|
end
|
83
60
|
```
|
84
61
|
|
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
|
62
|
+
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, or if you want a CoffeeScript spec helper. Run the install generator with the `--help` flag for a list of available options.
|
86
63
|
|
87
64
|
```
|
88
65
|
rails generate teaspoon:install --framework=mocha --coffee
|
89
66
|
```
|
90
67
|
|
91
|
-
To run Teaspoon headless you'll need Selenium Webdriver or
|
92
|
-
|
93
|
-
```
|
94
|
-
brew install phantomjs
|
95
|
-
- OR -
|
96
|
-
npm install -g phantomjs
|
97
|
-
```
|
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
|
-
```
|
68
|
+
To run Teaspoon headless you'll need PhantomJS, Selenium Webdriver or Capybara Webkit. We recommend PhantomJS, which you can install with homebrew, npm or [as a download](http://phantomjs.org/download.html).
|
107
69
|
|
108
70
|
### Upgrading
|
109
71
|
|
110
|
-
|
72
|
+
As of version 0.8.0 there are some changes to how configuration and loading works, which might cause some confusion. For this we're sorry, but it'll be better in the long run. 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. We appreciate your tolerance and willingness to help us fix anything that we missed.
|
73
|
+
|
74
|
+
:heart:
|
111
75
|
|
112
76
|
1. backup your `spec/teaspoon_env.rb` file.
|
113
77
|
2. run the install generator to get the new `teaspoon_env.rb`.
|
@@ -140,6 +104,7 @@ The rake task provides several ways of focusing tests. You can specify the suite
|
|
140
104
|
```
|
141
105
|
rake teaspoon suite=my_fantastic_suite
|
142
106
|
rake teaspoon files=spec/javascripts/integration,spec/javascripts/calculator_spec.js
|
107
|
+
rake teaspoon driver_options="—ssl-protocol=TLSv1 --ignore-ssl-errors=yes"
|
143
108
|
```
|
144
109
|
|
145
110
|
### CLI
|
@@ -148,7 +113,7 @@ rake teaspoon files=spec/javascripts/integration,spec/javascripts/calculator_spe
|
|
148
113
|
bundle exec teaspoon
|
149
114
|
```
|
150
115
|
|
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.
|
116
|
+
The CLI also provides several ways of focusing tests and is more full featured than the rake task. You can specify the suite to run, the files to run, directories to run, filters, etc.
|
152
117
|
|
153
118
|
```
|
154
119
|
bundle exec teaspoon --suite=my_fantastic_suite
|
@@ -162,14 +127,14 @@ Get full command line help:
|
|
162
127
|
bundle exec teaspoon --help
|
163
128
|
```
|
164
129
|
|
165
|
-
**Note:** The rake task and CLI run within the development environment unless otherwise specified.
|
130
|
+
**Note:** The rake task and CLI run within the development environment for optimization unless otherwise specified.
|
166
131
|
|
167
132
|
|
168
133
|
## Writing Specs
|
169
134
|
|
170
135
|
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.
|
171
136
|
|
172
|
-
Teaspoon supports [Jasmine](http://pivotal.github.com/jasmine), [Mocha](
|
137
|
+
Teaspoon supports [Jasmine 1.3](http://pivotal.github.com/jasmine), [Mocha](https://github.com/mochajs/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.
|
173
138
|
|
174
139
|
Here's a basic spec written in Javascript using Jasmine:
|
175
140
|
|
@@ -215,12 +180,12 @@ Teaspoon allows deferring execution, which can be useful for asynchronous execut
|
|
215
180
|
|
216
181
|
```javascript
|
217
182
|
Teaspoon.defer = true;
|
218
|
-
setTimeout(Teaspoon.execute, 1000); // defers execution for 1 second
|
183
|
+
setTimeout(Teaspoon.execute, 1000); // defers execution for 1 second
|
219
184
|
```
|
220
185
|
|
221
186
|
### Using Require.js
|
222
187
|
|
223
|
-
|
188
|
+
There's a wiki article that goes into more depth on using [RequireJS with Teaspoon](https://github.com/modeset/teaspoon/wiki/RequireJS-with-Teaspoon). But in simple terms you can configure your suite to boot with RequireJS by setting the suite `boot_partial` directive to `"boot_require_js"`.
|
224
189
|
|
225
190
|
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
191
|
|
@@ -241,7 +206,7 @@ define(['Model'], function (Model) {
|
|
241
206
|
|
242
207
|
## Fixtures
|
243
208
|
|
244
|
-
Teaspoon ships with a fixture library that works with Jasmine, Mocha, and QUnit with
|
209
|
+
Teaspoon ships with a fixture library that works with Jasmine, Mocha, and QUnit with minimal effort. It has a consistent API, and isn't dependent on jQuery.
|
245
210
|
|
246
211
|
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.
|
247
212
|
|
@@ -291,7 +256,7 @@ describe("Using fixtures", function() {
|
|
291
256
|
|
292
257
|
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
258
|
|
294
|
-
**Note:** The element that Teaspoon creates is "#teaspoon-fixtures", in case you need to access it directly.
|
259
|
+
**Note:** The element that Teaspoon creates is "#teaspoon-fixtures", in case you need to access it directly and put your own fixtures in manually.
|
295
260
|
|
296
261
|
|
297
262
|
## Suites
|
@@ -300,7 +265,7 @@ Teaspoon uses the concept of suites to group tests at a high level. These suites
|
|
300
265
|
|
301
266
|
A default suite has been generated for you in your `teaspoon_env.rb`.
|
302
267
|
|
303
|
-
Suites inherit from a "default" suite. To modify
|
268
|
+
Suites inherit from a "default" suite. To modify this default, simply don't specify a name for the suite. In this example we're configuring the default, which all other suites will inherit from.
|
304
269
|
|
305
270
|
```ruby
|
306
271
|
config.suite do |suite|
|
@@ -318,36 +283,37 @@ end
|
|
318
283
|
|
319
284
|
### Hooks
|
320
285
|
|
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.
|
286
|
+
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.
|
287
|
+
|
288
|
+
You can define hooks in your suite configuration by specifying a name and a block. Hooks with the same name will be added to an array, and all configured hook callbacks with that name will be called when the hook is requested. If you don't specify a name, :default will be assumed.
|
322
289
|
|
323
290
|
```ruby
|
324
291
|
config.suite :my_suite do |suite|
|
325
292
|
suite.hook :fixtures do
|
326
293
|
# some code that would load your fixtures
|
327
294
|
end
|
295
|
+
|
296
|
+
suite.hook :setup do |arguments|
|
297
|
+
# some code that has access to your passed in arguments
|
298
|
+
end
|
328
299
|
end
|
329
300
|
```
|
330
301
|
|
331
|
-
|
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
|
302
|
+
Once hooks have been defined in your configuration, you can invoke them using the javascript `Teaspoon.hook` interface in your specs. A request will be sent to the server, where all blocks that have been specified for a given hook will be called in the order they were defined. Any arguments passed to `Teaspoon.hook` will be provided to the hooks defined in the configuration.
|
342
303
|
```
|
343
304
|
|
344
|
-
|
305
|
+
```js
|
306
|
+
Teaspoon.hook('fixtures')
|
307
|
+
Teaspoon.hook('setup', {foo: 'bar'})
|
308
|
+
```
|
345
309
|
|
346
310
|
|
347
311
|
## Coverage
|
348
312
|
|
349
313
|
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
314
|
|
315
|
+
**Note:** Ensure that you are using Istanbul version `v0.3.0` or greater.
|
316
|
+
|
351
317
|
Each suite allows specifying ignored files, which allows you to ignore support libraries and dependencies.
|
352
318
|
|
353
319
|
The following configuration and example generates a text and cobertura report -- and an annotated HTML report that you can inspect further.
|
@@ -393,309 +359,10 @@ end
|
|
393
359
|
|
394
360
|
## Configuration
|
395
361
|
|
396
|
-
When you install Teaspoon a `teaspoon_env.rb` file is generated that contains
|
397
|
-
|
398
|
-
<dl>
|
399
|
-
|
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/>
|
402
|
-
|
403
|
-
<b>default:</b> <code>"/teaspoon"</code>
|
404
|
-
</dd>
|
405
|
-
|
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/>
|
409
|
-
|
410
|
-
<b>default:</b> <code>nil</code>
|
411
|
-
</dd>
|
412
|
-
|
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/>
|
416
|
-
|
417
|
-
<b>default:</b> <code>["spec/javascripts", "spec/javascripts/stylesheets", "test/javascripts", "test/javascripts/stylesheets"]</code>
|
418
|
-
</dd>
|
419
|
-
|
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/>
|
422
|
-
|
423
|
-
<b>default:</b> <code>["spec/javascripts/fixtures", "test/javascripts/fixtures"]</code>
|
424
|
-
</dd>
|
425
|
-
|
426
|
-
</dl>
|
427
|
-
|
428
|
-
### Suite Configuration Directives
|
429
|
-
|
430
|
-
<dl>
|
431
|
-
|
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/>
|
435
|
-
|
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/>
|
443
|
-
|
444
|
-
<b>default:</b> <code>"{spec/javascripts,app/assets}/**/*_spec.{js,js.coffee,coffee}"</code>
|
445
|
-
</dd>
|
446
|
-
|
447
|
-
<dt> helper </dt><dd>
|
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/>
|
449
|
-
|
450
|
-
<b>default:</b> <code>"spec_helper"</code>
|
451
|
-
</dd>
|
452
|
-
|
453
|
-
<dt> javascripts </dt><dd>
|
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/>
|
457
|
-
|
458
|
-
<b>available:</b> teaspoon-jasmine, teaspoon-mocha, teaspoon-qunit<br/>
|
459
|
-
<b>default:</b> <code>["jasmine/1.3.1", "teaspoon-jasmine"]</code>
|
460
|
-
</dd>
|
461
|
-
|
462
|
-
<dt> stylesheets </dt><dd>
|
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/>
|
465
|
-
|
466
|
-
<b>default:</b> <code>["teaspoon"]</code>
|
467
|
-
</dd>
|
468
|
-
|
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/>
|
471
|
-
|
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>
|
481
|
-
</dd>
|
482
|
-
|
483
|
-
</dl>
|
484
|
-
|
485
|
-
|
486
|
-
## Configuration
|
487
|
-
|
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.
|
362
|
+
When you install Teaspoon a `teaspoon_env.rb` file is generated that contains good documentation for each configuration directive. Otherwise you can get a refresher by checking the [Teaspoon Configuration](https://github.com/modeset/teaspoon/wiki/Teaspoon-Configuration) article.
|
489
363
|
|
490
|
-
|
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/>
|
364
|
+
**Note** If you want `teaspoon_env.rb` to live in a location other than the default install path, you can specify an alternate path in a `TEASPOON_ENV` environment variable (eg `$ TEASPOON_ENV=config/teaspoon.rb teaspoon`).
|
492
365
|
|
493
|
-
<b>default:</b> <code>"body"</code>
|
494
|
-
</dd>
|
495
|
-
|
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/>
|
498
|
-
|
499
|
-
<b>default:</b> <code>[%r{/lib/ruby/gems/}, %r{/vendor/assets/}, %r{/support/}, %r{/(.+)_helper.}]</code>
|
500
|
-
</dd>
|
501
|
-
|
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>)
|
504
|
-
|
505
|
-
<b>default:</b> <code>Hash.new{ |h, k| h[k] = [] }</code>
|
506
|
-
</dd>
|
507
|
-
|
508
|
-
</dl>
|
509
|
-
|
510
|
-
### Console Runner Specific
|
511
|
-
|
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.
|
513
|
-
|
514
|
-
<dl>
|
515
|
-
|
516
|
-
<dt> driver </dt><dd>
|
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/>
|
518
|
-
|
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/>
|
521
|
-
|
522
|
-
<b>available:</b> phantomjs, selenium<br/>
|
523
|
-
<b>default:</b> <code>"phantomjs"</code>
|
524
|
-
|
525
|
-
<ul>
|
526
|
-
<li>CLI: -d, --driver DRIVER</li>
|
527
|
-
<li>ENV: DRIVER=[DRIVER]</li>
|
528
|
-
</ul>
|
529
|
-
</dd>
|
530
|
-
|
531
|
-
<dt> driver_options </dt><dd>
|
532
|
-
Specify additional options/switches for the driver.<br/><br/>
|
533
|
-
|
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/>
|
536
|
-
|
537
|
-
<b>default:</b> <code>nil</code>
|
538
|
-
|
539
|
-
<ul>
|
540
|
-
<li>CLI: --driver-options OPTIONS</li>
|
541
|
-
<li>ENV: DRIVER_OPTIONS=[OPTIONS]</li>
|
542
|
-
</ul>
|
543
|
-
</dd>
|
544
|
-
|
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/>
|
547
|
-
|
548
|
-
<b>default:</b> <code>180</code>
|
549
|
-
|
550
|
-
<ul>
|
551
|
-
<li>CLI: --driver-timeout SECONDS</li>
|
552
|
-
<li>ENV: DRIVER_TIMEOUT=[SECONDS]</li>
|
553
|
-
</ul>
|
554
|
-
</dd>
|
555
|
-
|
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/>
|
558
|
-
|
559
|
-
<b>default:</b> <code>nil</code>
|
560
|
-
|
561
|
-
<ul>
|
562
|
-
<li>CLI: --server SERVER</li>
|
563
|
-
<li>ENV: SERVER=[SERVER]</li>
|
564
|
-
</ul>
|
565
|
-
</dd>
|
566
|
-
|
567
|
-
<dt> server_port </dt><dd>
|
568
|
-
Specify a port to run on a specific port, otherwise Teaspoon will use a random available port.<br/><br/>
|
569
|
-
|
570
|
-
<b>default:</b> <code>nil</code>
|
571
|
-
|
572
|
-
<ul>
|
573
|
-
<li>CLI: --server-port PORT</li>
|
574
|
-
<li>ENV: SERVER_PORT=[PORT]</li>
|
575
|
-
</ul>
|
576
|
-
</dd>
|
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/>
|
580
|
-
|
581
|
-
<b>default:</b> <code>20</code>
|
582
|
-
|
583
|
-
<ul>
|
584
|
-
<li>CLI: --server-timeout SECONDS</li>
|
585
|
-
<li>ENV: SERVER_TIMEOUT=[SECONDS]</li>
|
586
|
-
</ul>
|
587
|
-
</dd>
|
588
|
-
|
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/>
|
591
|
-
|
592
|
-
<b>default:</b> <code>true</code>
|
593
|
-
|
594
|
-
<ul>
|
595
|
-
<li>CLI: -F, --[no-]fail-fast</li>
|
596
|
-
<li>ENV: FAIL_FAST=[true/false]</li>
|
597
|
-
</ul>
|
598
|
-
</dd>
|
599
|
-
|
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/>
|
603
|
-
|
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>
|
606
|
-
|
607
|
-
<ul>
|
608
|
-
<li>CLI: -f, --format FORMATTERS</li>
|
609
|
-
<li>ENV: FORMATTERS=[FORMATTERS]</li>
|
610
|
-
</ul>
|
611
|
-
</dd>
|
612
|
-
|
613
|
-
<dt> color </dt><dd>
|
614
|
-
Specify if you want color output from the formatters.<br/><br/>
|
615
|
-
|
616
|
-
<b>default:</b> <code>true</code>
|
617
|
-
|
618
|
-
<ul>
|
619
|
-
<li>CLI: -c, --[no-]color</li>
|
620
|
-
<li>ENV: COLOR=[true/false]</li>
|
621
|
-
</ul>
|
622
|
-
</dd>
|
623
|
-
|
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/>
|
626
|
-
|
627
|
-
<b>default:</b> <code>false</code>
|
628
|
-
|
629
|
-
<ul>
|
630
|
-
<li>CLI: -q, --[no-]suppress-log</li>
|
631
|
-
<li>ENV: SUPPRESS_LOG=[true/false]</li>
|
632
|
-
</ul>
|
633
|
-
</dd>
|
634
|
-
|
635
|
-
<dt> use_coverage </dt><dd>
|
636
|
-
Specify that you always want a coverage configuration to be used.<br/><br/>
|
637
|
-
|
638
|
-
<b>default:</b> <code>nil</code>
|
639
|
-
|
640
|
-
<ul>
|
641
|
-
<li>CLI: -C, --coverage=CONFIG_NAME</li>
|
642
|
-
<li>ENV: USE_COVERAGE=[CONFIG_NAME]</li>
|
643
|
-
</ul>
|
644
|
-
</dd>
|
645
|
-
|
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/>
|
664
|
-
|
665
|
-
<b>default:</b> <code>"coverage"</code>
|
666
|
-
</dd>
|
667
|
-
|
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>
|
696
|
-
</dd>
|
697
|
-
|
698
|
-
</dl>
|
699
366
|
|
700
367
|
## Test Frameworks
|
701
368
|
|
@@ -705,8 +372,6 @@ These configuration directives are applicable only when running via the rake tas
|
|
705
372
|
|
706
373
|
[QUnit](http://qunitjs.com) We're not sure about how many people use QUnit, but we like jQuery, so we added it. Read more about [Using QUnit](https://github.com/modeset/teaspoon/wiki/Using-QUnit) with Teaspoon.
|
707
374
|
|
708
|
-
[Angular](http://angularjs.org/) This is an experimental addition, and feedback is needed. Read more about [Using Angular](https://github.com/modeset/teaspoon/wiki/Using-Angular) with Teaspoon.
|
709
|
-
|
710
375
|
|
711
376
|
## Support Libraries
|
712
377
|
|
@@ -714,16 +379,19 @@ We know that testing usually requires more than just the test framework, so we'v
|
|
714
379
|
|
715
380
|
- [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
381
|
- [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.
|
382
|
+
- [Chai-jQ](http://formidablelabs.github.io/chai-jq/) (0.0.7) An alternate plugin for the Chai assertion library to provide jQuery-specific assertions. MIT License.
|
717
383
|
- [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
384
|
- [expect.js](https://github.com/LearnBoost/expect.js) (0.1.2) Minimalistic BDD assertion toolkit based on should.js. MIT License.
|
719
385
|
- [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
386
|
- [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.
|
721
387
|
|
722
|
-
You can require
|
388
|
+
You can require the various support files in your spec helper by using:
|
723
389
|
|
724
390
|
```javascript
|
725
391
|
//= require support/sinon
|
726
392
|
//= require support/chai
|
393
|
+
//= require support/chai-1.10.0
|
394
|
+
//= require support/sinon-chai
|
727
395
|
//= require support/expect
|
728
396
|
//= require support/jasmine-jquery-1.7.0
|
729
397
|
//= require support/jasmine-jquery-2.0.0
|
@@ -745,6 +413,8 @@ Rake::Task['default'].clear
|
|
745
413
|
task default: [:spec, :teaspoon, :cucumber]
|
746
414
|
```
|
747
415
|
|
416
|
+
Some build services also support selenium based setups using Xvfb and Firefox. This works well on on TravisCI, and we've heard of some success doing this on CircleCI, however if you are experiencing timeouts try to add a post-dependency command to precompile your assets (eg. `rake assets:precompile`.
|
417
|
+
|
748
418
|
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.
|
749
419
|
|
750
420
|
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.
|
@@ -770,4 +440,3 @@ All licenses for the [bundled Javascript libraries](https://github.com/modeset/t
|
|
770
440
|
|
771
441
|
## Make Code Not War
|
772
442
|
![crest](https://secure.gravatar.com/avatar/aa8ea677b07f626479fd280049b0e19f?s=75)
|
773
|
-
|