teaspoon 0.7.9 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +382 -260
- data/app/assets/javascripts/teaspoon-angular.js +108 -26241
- data/app/assets/javascripts/teaspoon-jasmine.js +103 -2642
- data/app/assets/javascripts/teaspoon-mocha.js +109 -5416
- data/app/assets/javascripts/teaspoon-qunit.js +107 -2255
- data/app/assets/javascripts/teaspoon-teaspoon.js +0 -1
- data/app/assets/javascripts/teaspoon/angular.coffee +3 -1
- data/app/assets/javascripts/teaspoon/base/hook.coffee +21 -0
- data/app/assets/javascripts/teaspoon/base/reporters/html.coffee +26 -14
- data/app/assets/javascripts/teaspoon/base/reporters/html/progress_view.coffee +1 -1
- data/app/assets/javascripts/teaspoon/base/reporters/html/template.coffee +3 -3
- data/app/assets/javascripts/teaspoon/base/teaspoon.coffee +10 -1
- data/app/assets/javascripts/teaspoon/jasmine.coffee +3 -1
- data/app/assets/javascripts/teaspoon/mocha.coffee +3 -1
- data/app/assets/javascripts/teaspoon/mocha/reporters/html.coffee +1 -1
- data/app/assets/javascripts/teaspoon/qunit.coffee +3 -1
- data/app/assets/javascripts/teaspoon/qunit/reporters/html.coffee +1 -1
- data/app/assets/javascripts/teaspoon/teaspoon.coffee +0 -1
- data/app/assets/stylesheets/teaspoon.css +12 -8
- data/app/controllers/teaspoon/suite_controller.rb +32 -0
- data/app/views/teaspoon/suite/_body.html.erb +0 -0
- data/app/views/teaspoon/suite/_boot.html.erb +4 -0
- data/app/views/teaspoon/suite/_boot_require_js.html.erb +19 -0
- data/app/views/teaspoon/{spec/suites.html.erb → suite/index.html.erb} +6 -7
- data/app/views/teaspoon/suite/show.html.erb +19 -0
- data/bin/teaspoon +1 -1
- data/config/routes.rb +14 -4
- data/lib/generators/teaspoon/install/POST_INSTALL +2 -2
- data/lib/generators/teaspoon/install/install_generator.rb +22 -11
- data/lib/generators/teaspoon/install/templates/_body.html.erb +0 -0
- data/lib/generators/teaspoon/install/templates/_boot.html.erb +4 -0
- data/lib/generators/teaspoon/install/templates/jasmine/env.rb +11 -0
- data/lib/generators/teaspoon/install/templates/jasmine/env_comments.rb +182 -0
- data/lib/generators/teaspoon/install/templates/jasmine/spec_helper.coffee +8 -6
- data/lib/generators/teaspoon/install/templates/jasmine/spec_helper.js +8 -7
- data/lib/generators/teaspoon/install/templates/mocha/env.rb +11 -0
- data/lib/generators/teaspoon/install/templates/mocha/env_comments.rb +182 -0
- data/lib/generators/teaspoon/install/templates/mocha/spec_helper.coffee +13 -13
- data/lib/generators/teaspoon/install/templates/mocha/spec_helper.js +13 -13
- data/lib/generators/teaspoon/install/templates/qunit/env.rb +11 -0
- data/lib/generators/teaspoon/install/templates/qunit/env_comments.rb +182 -0
- data/lib/generators/teaspoon/install/templates/qunit/test_helper.coffee +6 -5
- data/lib/generators/teaspoon/install/templates/qunit/test_helper.js +6 -5
- data/lib/tasks/teaspoon.rake +9 -2
- data/lib/teaspoon.rb +4 -6
- data/lib/teaspoon/command_line.rb +116 -134
- data/lib/teaspoon/configuration.rb +144 -66
- data/lib/teaspoon/console.rb +70 -37
- data/lib/teaspoon/coverage.rb +42 -15
- data/lib/teaspoon/deprecated.rb +65 -0
- data/lib/teaspoon/drivers/base.rb +10 -0
- data/lib/teaspoon/drivers/phantomjs/runner.js +9 -11
- data/lib/teaspoon/drivers/phantomjs_driver.rb +21 -21
- data/lib/teaspoon/drivers/selenium_driver.rb +32 -13
- data/lib/teaspoon/engine.rb +32 -12
- data/lib/teaspoon/environment.rb +16 -12
- data/lib/teaspoon/exceptions.rb +41 -5
- data/lib/teaspoon/exporter.rb +52 -0
- data/lib/teaspoon/formatters/base.rb +171 -0
- data/lib/teaspoon/formatters/clean_formatter.rb +2 -4
- data/lib/teaspoon/formatters/documentation_formatter.rb +60 -0
- data/lib/teaspoon/formatters/dot_formatter.rb +12 -90
- data/lib/teaspoon/formatters/json_formatter.rb +36 -0
- data/lib/teaspoon/formatters/junit_formatter.rb +51 -32
- data/lib/teaspoon/formatters/modules/report_module.rb +76 -0
- data/lib/teaspoon/formatters/pride_formatter.rb +23 -27
- data/lib/teaspoon/formatters/snowday_formatter.rb +7 -11
- data/lib/teaspoon/formatters/swayze_or_oprah_formatter.rb +88 -64
- data/lib/teaspoon/formatters/tap_formatter.rb +18 -27
- data/lib/teaspoon/formatters/tap_y_formatter.rb +35 -45
- data/lib/teaspoon/formatters/teamcity_formatter.rb +69 -31
- data/lib/teaspoon/instrumentation.rb +33 -33
- data/lib/teaspoon/result.rb +2 -1
- data/lib/teaspoon/runner.rb +40 -28
- data/lib/teaspoon/server.rb +23 -25
- data/lib/teaspoon/suite.rb +52 -72
- data/lib/teaspoon/utility.rb +3 -14
- data/lib/teaspoon/version.rb +1 -1
- data/spec/dummy/app/assets/javascripts/integration/integration_spec.coffee +3 -0
- data/spec/dummy/app/assets/javascripts/integration/spec_helper.coffee +2 -0
- data/spec/dummy/config/application.rb +3 -0
- data/spec/features/console_reporter_spec.rb +48 -18
- data/spec/features/hooks_spec.rb +23 -41
- data/spec/features/html_reporter_spec.rb +38 -21
- data/spec/features/install_generator_spec.rb +34 -20
- data/spec/features/instrumentation_spec.rb +3 -2
- data/spec/fixtures/coverage.json +243 -0
- data/spec/javascripts/fixtures/_body.html.erb +1 -0
- data/spec/javascripts/jasmine_helper.coffee +1 -1
- data/spec/javascripts/teaspoon/base/fixture_spec.coffee +4 -4
- data/spec/javascripts/teaspoon/base/reporters/html_spec.coffee +9 -10
- data/spec/javascripts/teaspoon/mocha/reporters/html_mspec.coffee +0 -6
- data/spec/javascripts/teaspoon/phantomjs/runner_spec.coffee +5 -6
- data/spec/javascripts/turbolinks_helper.coffee +1 -1
- data/spec/spec_helper.rb +3 -4
- data/spec/teaspoon/command_line_spec.rb +139 -23
- data/spec/teaspoon/configuration_spec.rb +164 -46
- data/spec/teaspoon/console_spec.rb +142 -47
- data/spec/teaspoon/coverage_spec.rb +98 -28
- data/spec/teaspoon/drivers/base_spec.rb +5 -0
- data/spec/teaspoon/drivers/phantomjs_driver_spec.rb +32 -14
- data/spec/teaspoon/drivers/selenium_driver_spec.rb +32 -24
- data/spec/teaspoon/engine_spec.rb +8 -5
- data/spec/teaspoon/environment_spec.rb +56 -33
- data/spec/teaspoon/exceptions_spec.rb +57 -0
- data/spec/teaspoon/exporter_spec.rb +96 -0
- data/spec/teaspoon/formatters/base_spec.rb +259 -0
- data/spec/teaspoon/formatters/clean_formatter_spec.rb +37 -0
- data/spec/teaspoon/formatters/documentation_formatter_spec.rb +127 -0
- data/spec/teaspoon/formatters/dot_formatter_spec.rb +52 -56
- data/spec/teaspoon/formatters/json_formatter_spec.rb +77 -0
- data/spec/teaspoon/formatters/junit_formatter_spec.rb +72 -35
- data/spec/teaspoon/formatters/pride_formatter_spec.rb +37 -0
- data/spec/teaspoon/formatters/snowday_formatter_spec.rb +35 -0
- data/spec/teaspoon/formatters/tap_formatter_spec.rb +29 -81
- data/spec/teaspoon/formatters/tap_y_formatter_spec.rb +31 -141
- data/spec/teaspoon/formatters/teamcity_formatter_spec.rb +99 -42
- data/spec/teaspoon/instrumentation_spec.rb +44 -44
- data/spec/teaspoon/result_spec.rb +37 -0
- data/spec/teaspoon/runner_spec.rb +70 -59
- data/spec/teaspoon/server_spec.rb +34 -52
- data/spec/teaspoon/suite_spec.rb +42 -188
- data/spec/teaspoon_env.rb +39 -28
- data/vendor/assets/javascripts/{angular-scenario-1.0.5.js → angular/1.0.5.js} +0 -0
- data/vendor/assets/javascripts/{angular-scenario-1.0.5.MIT-LICENSE → angular/MIT-LICENSE} +0 -0
- data/vendor/assets/javascripts/{jasmine-1.3.1.js → jasmine/1.3.1.js} +0 -0
- data/vendor/assets/javascripts/jasmine/2.0.0.js +2412 -0
- data/vendor/assets/javascripts/{jasmine-1.3.1.MIT.LICENSE → jasmine/MIT.LICENSE} +0 -0
- data/vendor/assets/javascripts/{mocha-1.10.0.js → mocha/1.10.0.js} +1 -0
- data/vendor/assets/javascripts/mocha/1.17.1.js +5813 -0
- data/vendor/assets/javascripts/{mocha-1.10.1.MIT.LICENSE → mocha/MIT.LICENSE} +0 -0
- data/vendor/assets/javascripts/{qunit-1.12.0.js → qunit/1.12.0.js} +1 -1
- data/vendor/assets/javascripts/qunit/1.14.0.js +2288 -0
- data/vendor/assets/javascripts/{qunit-1.12.0.MIT.LICENSE → qunit/MIT.LICENSE} +0 -0
- data/vendor/assets/javascripts/support/chai.js +827 -385
- data/vendor/assets/javascripts/support/jasmine-jquery-1.7.0.js +720 -0
- data/vendor/assets/javascripts/support/jasmine-jquery-2.0.0.js +812 -0
- data/vendor/assets/javascripts/support/sinon-chai.js +17 -0
- data/vendor/assets/javascripts/support/sinon.js +1138 -643
- metadata +57 -36
- data/app/controllers/teaspoon/spec_controller.rb +0 -38
- data/app/helpers/teaspoon/spec_helper.rb +0 -36
- data/app/views/teaspoon/spec/_require_js.html.erb +0 -21
- data/app/views/teaspoon/spec/_standard.html.erb +0 -4
- data/app/views/teaspoon/spec/runner.html.erb +0 -19
- data/lib/generators/teaspoon/install/templates/env.rb +0 -38
- data/lib/generators/teaspoon/install/templates/jasmine/initializer.rb +0 -64
- data/lib/generators/teaspoon/install/templates/mocha/initializer.rb +0 -64
- data/lib/generators/teaspoon/install/templates/qunit/initializer.rb +0 -64
- data/lib/teaspoon/check_coverage.rb +0 -33
- data/lib/teaspoon/drivers/base_driver.rb +0 -10
- data/lib/teaspoon/exception_handling.rb +0 -18
- data/lib/teaspoon/formatters/base_formatter.rb +0 -63
- data/spec/dummy/config/initializers/teaspoon.rb +0 -41
- data/spec/teaspoon/check_coverage_spec.rb +0 -50
- data/spec/teaspoon/formatters/base_formatter_spec.rb +0 -45
- data/vendor/assets/javascripts/support/chai.MIT.LICENSE +0 -22
- data/vendor/assets/javascripts/support/expect.MIT.LICENSE +0 -22
- data/vendor/assets/javascripts/support/jasmine-jquery.MIT.LICENSE +0 -20
- data/vendor/assets/javascripts/support/jasmine-jquery.js +0 -659
- data/vendor/assets/javascripts/support/sinon-chai.MIT-ISH.LICENSE +0 -13
- data/vendor/assets/javascripts/support/sinon.BSD.LICENSE +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8fbbf5295bc786b2056c1863d366a253f191e420
|
4
|
+
data.tar.gz: 43b86be934c3ebe643d667f3569e3b2fbee76232
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2ccba66f0a0d524924cdf6999e3d785d80c46b3e6c704b066de0900641c576a90aabda5e52c6ede4440148f0806064dfca54a6e1b2ee2f42d997fee1f1078d5
|
7
|
+
data.tar.gz: dfa0de920af9e2b437498f08e39afdd449a69297c1cb9179e00f8c7bdbd7dfb76b358a3550f32ae93991b1e6bb2a069436a6159b796f6cfa7f23ff1a62af0923
|
data/README.md
CHANGED
@@ -1,26 +1,49 @@
|
|
1
|
-
|
1
|
+
Teaspoon
|
2
|
+
========
|
2
3
|
|
3
|
-
[![Gem Version](https://
|
4
|
-
[![
|
5
|
-
[![
|
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
|
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
|
-
|
15
|
+
The goal is to be simple, while still providing the most complete Javascript testing solution for Rails.
|
12
16
|
|
13
|
-
|
17
|
+
Teaspoon takes advantage of the asset pipeline. And ships with support for Jasmine, Mocha, and QUnit.
|
14
18
|
|
15
|
-
|
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
|
-
|
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
|
-
|
43
|
+
#### nice to haves
|
22
44
|
|
23
|
-
|
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. [
|
45
|
-
6. [
|
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`
|
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
|
-
|
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
|
-
|
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
|
-
|
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.
|
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
|
-
|
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=
|
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
|
-
###
|
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,
|
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:**
|
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
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
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
|
-
```
|
164
|
-
describe
|
196
|
+
```javascript
|
197
|
+
describe("My great feature", function() {
|
198
|
+
it("hasn't been tested yet");
|
165
199
|
|
166
|
-
|
200
|
+
xit("has a test I can't figure out", function() {
|
201
|
+
expect("complexity").to.be("easily testable");
|
202
|
+
});
|
167
203
|
|
168
|
-
|
169
|
-
|
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
|
-
|
212
|
+
### Deferring Execution
|
172
213
|
|
173
|
-
|
174
|
-
expect(true).to.be(false)
|
175
|
-
```
|
214
|
+
Teaspoon allows deferring execution, which can be useful for asynchronous execution.
|
176
215
|
|
177
|
-
|
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
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
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
|
-
|
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']
|
196
|
-
describe('Model'
|
197
|
-
//
|
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
|
-
|
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.
|
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
|
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
|
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
|
-
```
|
245
|
-
fixture.preload("fixture.html", "fixture.json")
|
246
|
-
describe
|
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
|
-
|
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
|
254
|
-
expect($("h1", fixture.el).text()).toBe("Title")
|
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(
|
257
|
-
expect(
|
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)
|
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
|
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
|
-
|
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
|
-
|
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
|
362
|
+
bundle exec teaspoon --coverage=default
|
273
363
|
```
|
274
364
|
|
275
|
-
|
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
|
-
|
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
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
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
|
-
|
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
|
-
|
398
|
+
<dl>
|
308
399
|
|
309
|
-
|
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
|
-
|
312
|
-
|
313
|
-
suite.helper = "my_spec_helper.js"
|
314
|
-
end
|
315
|
-
```
|
403
|
+
<b>default:</b> <code>"/teaspoon"</code>
|
404
|
+
</dd>
|
316
405
|
|
317
|
-
|
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
|
-
|
320
|
-
|
321
|
-
suite.helper = "other_spec_helper.js"
|
322
|
-
end
|
323
|
-
```
|
410
|
+
<b>default:</b> <code>nil</code>
|
411
|
+
</dd>
|
324
412
|
|
325
|
-
|
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
|
-
|
417
|
+
<b>default:</b> <code>["spec/javascripts", "spec/javascripts/stylesheets", "test/javascripts", "test/javascripts/stylesheets"]</code>
|
418
|
+
</dd>
|
328
419
|
|
329
|
-
|
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
|
-
|
423
|
+
<b>default:</b> <code>["spec/javascripts/fixtures", "test/javascripts/fixtures"]</code>
|
424
|
+
</dd>
|
332
425
|
|
333
|
-
|
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>
|
345
|
-
|
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>
|
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
|
-
|
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
|
-
|
360
|
-
|
361
|
-
<b>Note:</b>
|
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
|
-
|
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>
|
376
|
-
|
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>
|
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
|
-
|
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>"
|
493
|
+
<b>default:</b> <code>"body"</code>
|
397
494
|
</dd>
|
398
495
|
|
399
|
-
<dt>
|
400
|
-
|
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>[
|
499
|
+
<b>default:</b> <code>[%r{/lib/ruby/gems/}, %r{/vendor/assets/}, %r{/support/}, %r{/(.+)_helper.}]</code>
|
409
500
|
</dd>
|
410
501
|
|
411
|
-
<dt>
|
412
|
-
|
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>
|
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
|
510
|
+
### Console Runner Specific
|
420
511
|
|
421
|
-
These configuration directives are applicable only when running via the rake task or command line interface
|
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
|
-
|
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
|
-
|
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=
|
527
|
+
<li>ENV: DRIVER=[DRIVER]</li>
|
436
528
|
</ul>
|
437
529
|
</dd>
|
438
530
|
|
439
|
-
<dt>
|
440
|
-
|
531
|
+
<dt> driver_options </dt><dd>
|
532
|
+
Specify additional options/switches for the driver.<br/><br/>
|
441
533
|
|
442
|
-
|
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:
|
448
|
-
<li>ENV:
|
540
|
+
<li>CLI: --driver-options OPTIONS</li>
|
541
|
+
<li>ENV: DRIVER_OPTIONS=[OPTIONS]</li>
|
449
542
|
</ul>
|
450
543
|
</dd>
|
451
544
|
|
452
|
-
<dt>
|
453
|
-
Specify
|
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>
|
548
|
+
<b>default:</b> <code>180</code>
|
456
549
|
|
457
550
|
<ul>
|
458
|
-
<li>CLI: --
|
459
|
-
<li>ENV:
|
551
|
+
<li>CLI: --driver-timeout SECONDS</li>
|
552
|
+
<li>ENV: DRIVER_TIMEOUT=[SECONDS]</li>
|
460
553
|
</ul>
|
461
554
|
</dd>
|
462
555
|
|
463
|
-
<dt>
|
464
|
-
|
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>
|
559
|
+
<b>default:</b> <code>nil</code>
|
467
560
|
|
468
561
|
<ul>
|
469
|
-
<li>CLI: --server
|
470
|
-
<li>ENV:
|
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
|
-
|
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=
|
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
|
-
<
|
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: --
|
493
|
-
<li>ENV:
|
584
|
+
<li>CLI: --server-timeout SECONDS</li>
|
585
|
+
<li>ENV: SERVER_TIMEOUT=[SECONDS]</li>
|
494
586
|
</ul>
|
495
587
|
</dd>
|
496
588
|
|
497
|
-
<dt>
|
498
|
-
|
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>
|
501
|
-
<b>default:</b> <code>"dot"</code>
|
592
|
+
<b>default:</b> <code>true</code>
|
502
593
|
|
503
594
|
<ul>
|
504
|
-
<li>CLI: -
|
505
|
-
<li>ENV:
|
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>
|
510
|
-
|
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>
|
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: -
|
516
|
-
<li>ENV:
|
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
|
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>
|
532
|
-
|
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: -
|
538
|
-
<li>ENV:
|
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>
|
543
|
-
Specify
|
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: -
|
550
|
-
<li>ENV:
|
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
|
-
|
555
|
-
|
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
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
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
|
-
- [
|
585
|
-
- [
|
586
|
-
- [
|
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/
|
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
|
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
|
-
|
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
|
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
|
-
|
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
|
-
|
753
|
+
## Alternative Projects
|
623
754
|
|
624
|
-
|
625
|
-
|
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
|
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
|
|