teaspoon 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
|
@@ -41,7 +41,7 @@ Teaspoon.configure do |config|
|
|
|
41
41
|
# directives.
|
|
42
42
|
# Note: If no version is specified, the latest is assumed.
|
|
43
43
|
#
|
|
44
|
-
# Available: jasmine[1.3.1
|
|
44
|
+
# Available: jasmine[1.3.1], mocha[1.10.0, 1.17.1] qunit[1.12.0, 1.14.0]
|
|
45
45
|
suite.use_framework :qunit
|
|
46
46
|
|
|
47
47
|
# Specify a file matcher as a regular expression and all matching files will be loaded when the suite is run. These
|
|
@@ -80,6 +80,11 @@ Teaspoon.configure do |config|
|
|
|
80
80
|
# synchronous Ajax request to the server that will call all of the blocks you've defined for that hook name.
|
|
81
81
|
#suite.hook :fixtures, proc{ }
|
|
82
82
|
|
|
83
|
+
# Determine whether specs loaded into the test harness should be embedded as individual script tags or concatenated
|
|
84
|
+
# into a single file. Similar to Rails' asset `debug: true` and `config.assets.debug = true` options. By default,
|
|
85
|
+
# Teaspoon expands all assets to provide more valuable stack traces that reference individual source files.
|
|
86
|
+
#suite.expand_assets = false
|
|
87
|
+
|
|
83
88
|
end
|
|
84
89
|
|
|
85
90
|
# Example suite. Since we're just filtering to files already within the root test/javascripts, these files will also
|
|
@@ -134,8 +139,8 @@ Teaspoon.configure do |config|
|
|
|
134
139
|
# Specify the formatters to use when outputting the results.
|
|
135
140
|
# Note: Output files can be specified by using `"junit>/path/to/output.xml"`.
|
|
136
141
|
#
|
|
137
|
-
# Available:
|
|
138
|
-
#config.formatters = ["
|
|
142
|
+
# Available: <%= Teaspoon::Formatters.known_formatters.map(&:name).join ", " %>
|
|
143
|
+
#config.formatters = ["<%= Teaspoon::Formatters.known_formatters.select(&:default?).first.name %>"]
|
|
139
144
|
|
|
140
145
|
# Specify if you want color output from the formatters.
|
|
141
146
|
#config.color = true
|
|
@@ -161,14 +166,14 @@ Teaspoon.configure do |config|
|
|
|
161
166
|
|
|
162
167
|
config.coverage do |coverage|
|
|
163
168
|
|
|
164
|
-
# Which coverage reports
|
|
169
|
+
# Which coverage reports Istanbul should generate. Correlates directly to what Istanbul supports.
|
|
165
170
|
#
|
|
166
171
|
# Available: text-summary, text, html, lcov, lcovonly, cobertura, teamcity
|
|
167
172
|
#coverage.reports = ["text-summary", "html"]
|
|
168
173
|
|
|
169
174
|
# The path that the coverage should be written to - when there's an artifact to write to disk.
|
|
170
175
|
# Note: Relative to `config.root`.
|
|
171
|
-
#coverage.
|
|
176
|
+
#coverage.output_path = "coverage"
|
|
172
177
|
|
|
173
178
|
# Various thresholds requirements can be defined, and those thresholds will be checked at the end of a run. If any
|
|
174
179
|
# aren't met the run will fail with a message. Thresholds can be defined as a percentage (0-100), or nil.
|
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
# Use this polyfill to avoid the confusion.
|
|
7
7
|
#= require support/bind-poly
|
|
8
8
|
#
|
|
9
|
+
# You can require your own javascript files here. By default this will include everything in application, however you
|
|
10
|
+
# may get better load performance if you require the specific files that are being used in the test that tests them.
|
|
11
|
+
#= require application
|
|
12
|
+
#
|
|
9
13
|
# Deferring execution
|
|
10
14
|
# If you're using CommonJS, RequireJS or some other asynchronous library you can defer execution. Call
|
|
11
15
|
# Teaspoon.execute() after everything has been loaded. Simple example of a timeout:
|
|
@@ -16,14 +20,10 @@
|
|
|
16
20
|
# Matching files
|
|
17
21
|
# By default Teaspoon will look for files that match _test.{js,js.coffee,.coffee}. Add a filename_test.js file in your
|
|
18
22
|
# test path and it'll be included in the default suite automatically. If you want to customize suites, check out the
|
|
19
|
-
# configuration in
|
|
23
|
+
# configuration in teaspoon_env.rb
|
|
20
24
|
#
|
|
21
25
|
# Manifest
|
|
22
26
|
# If you'd rather require your test files manually (to control order for instance) you can disable the suite matcher in
|
|
23
27
|
# the configuration and use this file as a manifest.
|
|
24
28
|
#
|
|
25
29
|
# For more information: http://github.com/modeset/teaspoon
|
|
26
|
-
#
|
|
27
|
-
# You can require your own javascript files here. By default this will include everything in application, however you
|
|
28
|
-
# may get better load performance if you require the specific files that are being used in the test that tests them.
|
|
29
|
-
#= require application
|
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
// Use this polyfill to avoid the confusion.
|
|
7
7
|
//= require support/bind-poly
|
|
8
8
|
//
|
|
9
|
+
// You can require your own javascript files here. By default this will include everything in application, however you
|
|
10
|
+
// may get better load performance if you require the specific files that are being used in the test that tests them.
|
|
11
|
+
//= require application
|
|
12
|
+
//
|
|
9
13
|
// Deferring execution
|
|
10
14
|
// If you're using CommonJS, RequireJS or some other asynchronous library you can defer execution. Call
|
|
11
15
|
// Teaspoon.execute() after everything has been loaded. Simple example of a timeout:
|
|
@@ -16,15 +20,11 @@
|
|
|
16
20
|
// Matching files
|
|
17
21
|
// By default Teaspoon will look for files that match _test.{js,js.coffee,.coffee}. Add a filename_test.js file in your
|
|
18
22
|
// test path and it'll be included in the default suite automatically. If you want to customize suites, check out the
|
|
19
|
-
// configuration in
|
|
23
|
+
// configuration in teaspoon_env.rb
|
|
20
24
|
//
|
|
21
25
|
// Manifest
|
|
22
26
|
// If you'd rather require your test files manually (to control order for instance) you can disable the suite matcher in
|
|
23
27
|
// the configuration and use this file as a manifest.
|
|
24
28
|
//
|
|
25
29
|
// For more information: http://github.com/modeset/teaspoon
|
|
26
|
-
//
|
|
27
|
-
// You can require your own javascript files here. By default this will include everything in application, however you
|
|
28
|
-
// may get better load performance if you require the specific files that are being used in the test that tests them.
|
|
29
|
-
//= require application
|
|
30
30
|
|
data/lib/tasks/teaspoon.rake
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
require "optparse"
|
|
2
2
|
require "teaspoon/version"
|
|
3
3
|
require "teaspoon/exceptions"
|
|
4
|
+
require "teaspoon/formatters/base"
|
|
4
5
|
|
|
5
6
|
module Teaspoon
|
|
6
7
|
class CommandLine
|
|
7
|
-
|
|
8
8
|
def initialize
|
|
9
9
|
@options = {}
|
|
10
10
|
@options[:files] = opt_parser.parse!
|
|
@@ -31,90 +31,87 @@ module Teaspoon
|
|
|
31
31
|
protected
|
|
32
32
|
|
|
33
33
|
def opts_for_general
|
|
34
|
-
opt :environment,
|
|
35
|
-
|
|
36
|
-
"Require Teaspoon environment file."
|
|
34
|
+
opt :environment, "-r", "--require FILE",
|
|
35
|
+
"Require Teaspoon environment file."
|
|
37
36
|
|
|
38
|
-
#opt :custom_options_file,
|
|
39
|
-
#
|
|
40
|
-
#
|
|
37
|
+
# opt :custom_options_file,
|
|
38
|
+
# "-O", "--options PATH",
|
|
39
|
+
# "Specify the path to a custom options file."
|
|
41
40
|
|
|
42
41
|
opt :driver, "-d", "--driver DRIVER",
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
"Specify driver:",
|
|
43
|
+
" phantomjs (default)",
|
|
44
|
+
" selenium",
|
|
45
|
+
" capybara_webkit"
|
|
46
46
|
|
|
47
47
|
opt :driver_options, "--driver-options OPTIONS",
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
"Specify driver-specific options to pass into the driver.",
|
|
49
|
+
" e.g. \"--ssl-protocol=any --ssl-certificates-path=/path/to/certs\".",
|
|
50
|
+
" Driver options are only supported with phantomjs."
|
|
51
51
|
|
|
52
52
|
opt :driver_timeout, "--driver-timeout SECONDS",
|
|
53
|
-
|
|
53
|
+
"Sets the timeout for the driver to wait before exiting."
|
|
54
54
|
|
|
55
55
|
opt :server, "--server SERVER",
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
"Sets server to use with Rack.",
|
|
57
|
+
" e.g. webrick, thin"
|
|
58
58
|
|
|
59
59
|
opt :server_port, "--server-port PORT",
|
|
60
|
-
|
|
60
|
+
"Sets the server to use a specific port."
|
|
61
61
|
|
|
62
62
|
opt :server_timeout, "--server-timeout SECONDS",
|
|
63
|
-
|
|
63
|
+
"Sets the timeout that the server must start within."
|
|
64
64
|
|
|
65
65
|
opt :fail_fast, "-F", "--[no-]fail-fast",
|
|
66
|
-
|
|
66
|
+
"Abort after the first failing suite."
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
def opts_for_filtering
|
|
70
70
|
separator("Filtering")
|
|
71
71
|
|
|
72
72
|
opt :suite, "-s", "--suite SUITE",
|
|
73
|
-
|
|
73
|
+
"Focus to a specific suite."
|
|
74
74
|
|
|
75
75
|
opt :filter, "-g", "--filter FILTER",
|
|
76
|
-
|
|
76
|
+
"Filter tests matching a specific filter."
|
|
77
77
|
end
|
|
78
78
|
|
|
79
79
|
def opts_for_output
|
|
80
80
|
separator("Output")
|
|
81
81
|
|
|
82
82
|
opt :suppress_log, "-q", "--[no-]suppress-log",
|
|
83
|
-
|
|
83
|
+
"Suppress logs coming from console[log/debug/error]."
|
|
84
84
|
|
|
85
85
|
opt :color, "-c", "--[no-]color",
|
|
86
|
-
|
|
86
|
+
"Enable/Disable color output."
|
|
87
87
|
|
|
88
88
|
opt :export, "-e", "--export [OUTPUT_PATH]",
|
|
89
|
-
|
|
89
|
+
"Exports the test suite as the full HTML (requires wget)."
|
|
90
90
|
|
|
91
91
|
opt :formatters, "-f", "--format FORMATTERS",
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
" documentation - descriptive documentation",
|
|
95
|
-
" clean - like dots but doesn't log re-run commands",
|
|
96
|
-
" json - json formatter (raw teaspoon)",
|
|
97
|
-
" junit - junit compatible formatter",
|
|
98
|
-
" pride - yay rainbows!",
|
|
99
|
-
" snowday - makes you feel warm inside",
|
|
100
|
-
" swayze_or_oprah - quote from either Patrick Swayze or Oprah Winfrey",
|
|
101
|
-
" tap - test anything protocol formatter",
|
|
102
|
-
" tap_y - tap_yaml, format used by tapout",
|
|
103
|
-
" teamcity - teamcity compatible formatter"
|
|
92
|
+
"Specify formatters (comma separated)",
|
|
93
|
+
*Teaspoon::Formatters.known_formatters.map(&:cli_help)
|
|
104
94
|
end
|
|
105
95
|
|
|
106
96
|
def opts_for_coverage
|
|
107
97
|
separator("Coverage")
|
|
108
98
|
|
|
109
99
|
opt :use_coverage, "-C", "--coverage CONFIG_NAME",
|
|
110
|
-
|
|
100
|
+
"Generate coverage reports using a pre-defined coverage configuration."
|
|
111
101
|
end
|
|
112
102
|
|
|
113
103
|
def opts_for_utility
|
|
114
104
|
separator("Utility")
|
|
115
105
|
|
|
116
|
-
@parser.on "-v", "--version", "Display the version."
|
|
117
|
-
|
|
106
|
+
@parser.on "-v", "--version", "Display the version." do
|
|
107
|
+
STDOUT.print("#{Teaspoon::VERSION}\n")
|
|
108
|
+
exit
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
@parser.on "-h", "--help", "You're looking at it." do
|
|
112
|
+
STDOUT.print("#{@parser}\n")
|
|
113
|
+
exit
|
|
114
|
+
end
|
|
118
115
|
end
|
|
119
116
|
|
|
120
117
|
private
|
|
@@ -124,7 +121,7 @@ module Teaspoon
|
|
|
124
121
|
end
|
|
125
122
|
|
|
126
123
|
def opt(config, *args)
|
|
127
|
-
@parser.on(*args, proc{ |value| @options[config] = value })
|
|
124
|
+
@parser.on(*args, proc { |value| @options[config] = value })
|
|
128
125
|
end
|
|
129
126
|
|
|
130
127
|
def require_console
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
require "singleton"
|
|
2
2
|
|
|
3
3
|
module Teaspoon
|
|
4
|
-
|
|
5
4
|
autoload :Formatters, "teaspoon/formatters/base"
|
|
6
5
|
autoload :Drivers, "teaspoon/drivers/base"
|
|
7
6
|
|
|
@@ -17,7 +16,7 @@ module Teaspoon
|
|
|
17
16
|
# - add it to ENV_OVERRIDES if it can be overridden from ENV
|
|
18
17
|
# - add it to the initializers in /lib/generators/install/templates so it's documented there as well
|
|
19
18
|
|
|
20
|
-
cattr_accessor
|
|
19
|
+
cattr_accessor :mount_at, :root, :asset_paths, :fixture_paths
|
|
21
20
|
@@mount_at = "/teaspoon"
|
|
22
21
|
@@root = nil # will default to Rails.root
|
|
23
22
|
@@asset_paths = ["spec/javascripts", "spec/javascripts/stylesheets", "test/javascripts", "test/javascripts/stylesheets"]
|
|
@@ -25,9 +24,9 @@ module Teaspoon
|
|
|
25
24
|
|
|
26
25
|
# console runner specific
|
|
27
26
|
|
|
28
|
-
cattr_accessor
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
cattr_accessor :driver, :driver_options, :driver_timeout, :server, :server_port, :server_timeout, :fail_fast,
|
|
28
|
+
:formatters, :color, :suppress_log,
|
|
29
|
+
:use_coverage
|
|
31
30
|
@@driver = "phantomjs"
|
|
32
31
|
@@driver_options = nil
|
|
33
32
|
@@driver_timeout = 180
|
|
@@ -53,41 +52,38 @@ module Teaspoon
|
|
|
53
52
|
# suite configurations
|
|
54
53
|
|
|
55
54
|
cattr_accessor :suite_configs
|
|
56
|
-
@@suite_configs = {"default" => {block: proc{}}}
|
|
55
|
+
@@suite_configs = { "default" => { block: proc {} } }
|
|
57
56
|
|
|
58
57
|
def self.suite(name = :default, &block)
|
|
59
|
-
@@suite_configs[name.to_s] = {block: block, instance: Suite.new(&block)}
|
|
58
|
+
@@suite_configs[name.to_s] = { block: block, instance: Suite.new(&block) }
|
|
60
59
|
end
|
|
61
60
|
|
|
62
61
|
class Suite
|
|
63
|
-
|
|
64
62
|
FRAMEWORKS = {
|
|
65
63
|
jasmine: ["1.3.1", "2.0.0"],
|
|
66
64
|
mocha: ["1.10.0", "1.17.1"],
|
|
67
65
|
qunit: ["1.12.0", "1.14.0"],
|
|
68
|
-
angular: ["1.0.5"],
|
|
69
66
|
}
|
|
70
67
|
|
|
71
|
-
attr_accessor
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
:hooks
|
|
68
|
+
attr_accessor :matcher, :helper, :javascripts, :stylesheets,
|
|
69
|
+
:boot_partial, :body_partial,
|
|
70
|
+
:no_coverage, :hooks, :expand_assets
|
|
75
71
|
|
|
76
72
|
def initialize
|
|
77
|
-
@matcher
|
|
78
|
-
@helper
|
|
79
|
-
@javascripts
|
|
80
|
-
@stylesheets
|
|
81
|
-
|
|
82
|
-
@boot_partial = "boot"
|
|
83
|
-
@body_partial = "body"
|
|
73
|
+
@matcher = "{spec/javascripts,app/assets}/**/*_spec.{js,js.coffee,coffee}"
|
|
74
|
+
@helper = "spec_helper"
|
|
75
|
+
@javascripts = ["jasmine/1.3.1", "teaspoon-jasmine"]
|
|
76
|
+
@stylesheets = ["teaspoon"]
|
|
84
77
|
|
|
85
|
-
@
|
|
78
|
+
@boot_partial = "boot"
|
|
79
|
+
@body_partial = "body"
|
|
86
80
|
|
|
87
|
-
@
|
|
81
|
+
@no_coverage = [%r{/lib/ruby/gems/}, %r{/vendor/assets/}, %r{/support/}, %r{/(.+)_helper.}]
|
|
82
|
+
@hooks = Hash.new { |h, k| h[k] = [] }
|
|
83
|
+
@expand_assets = true
|
|
88
84
|
|
|
89
85
|
default = Teaspoon.configuration.suite_configs["default"]
|
|
90
|
-
|
|
86
|
+
instance_eval(&default[:block]) if default
|
|
91
87
|
yield self if block_given?
|
|
92
88
|
end
|
|
93
89
|
|
|
@@ -96,7 +92,9 @@ module Teaspoon
|
|
|
96
92
|
version ||= FRAMEWORKS[name].last if FRAMEWORKS[name]
|
|
97
93
|
unless FRAMEWORKS[name] && FRAMEWORKS[name].include?(version)
|
|
98
94
|
message = "Unknown framework \"#{name}\""
|
|
99
|
-
|
|
95
|
+
if FRAMEWORKS[name] && version
|
|
96
|
+
message += " with version #{version} -- available versions #{FRAMEWORKS[name].join(', ')}"
|
|
97
|
+
end
|
|
100
98
|
raise Teaspoon::UnknownFramework, message
|
|
101
99
|
end
|
|
102
100
|
|
|
@@ -105,7 +103,6 @@ module Teaspoon
|
|
|
105
103
|
when :qunit
|
|
106
104
|
@matcher = "{test/javascripts,app/assets}/**/*_test.{js,js.coffee,coffee}"
|
|
107
105
|
@helper = "test_helper"
|
|
108
|
-
else
|
|
109
106
|
end
|
|
110
107
|
end
|
|
111
108
|
alias_method :use_framework=, :use_framework
|
|
@@ -118,15 +115,15 @@ module Teaspoon
|
|
|
118
115
|
# coverage configurations
|
|
119
116
|
|
|
120
117
|
cattr_accessor :coverage_configs
|
|
121
|
-
@@coverage_configs = {"default" => {block: proc{}}}
|
|
118
|
+
@@coverage_configs = { "default" => { block: proc {} } }
|
|
122
119
|
|
|
123
120
|
def self.coverage(name = :default, &block)
|
|
124
|
-
@@coverage_configs[name.to_s] = {block: block, instance: Coverage.new(&block)}
|
|
121
|
+
@@coverage_configs[name.to_s] = { block: block, instance: Coverage.new(&block) }
|
|
125
122
|
end
|
|
126
123
|
|
|
127
124
|
class Coverage
|
|
128
|
-
attr_accessor
|
|
129
|
-
|
|
125
|
+
attr_accessor :reports, :output_path,
|
|
126
|
+
:statements, :functions, :branches, :lines
|
|
130
127
|
|
|
131
128
|
def initialize
|
|
132
129
|
@reports = ["text-summary"]
|
|
@@ -138,7 +135,7 @@ module Teaspoon
|
|
|
138
135
|
@lines = nil
|
|
139
136
|
|
|
140
137
|
default = Teaspoon.configuration.coverage_configs["default"]
|
|
141
|
-
|
|
138
|
+
instance_eval(&default[:block]) if default
|
|
142
139
|
yield self if block_given?
|
|
143
140
|
end
|
|
144
141
|
end
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
require "singleton"
|
|
2
|
+
|
|
3
|
+
module Teaspoon
|
|
4
|
+
autoload :Formatters, "teaspoon/formatters/base"
|
|
5
|
+
autoload :Drivers, "teaspoon/drivers/base"
|
|
6
|
+
|
|
7
|
+
class Configuration
|
|
8
|
+
include Singleton
|
|
9
|
+
|
|
10
|
+
# CONTRIBUTORS:
|
|
11
|
+
# If you add a configuration option you should do the following before it will be considered for merging.
|
|
12
|
+
# - think about if it should be a suite, coverage, or global configuration
|
|
13
|
+
# - write specs for it, and add it to existing specs in spec/teaspoon/configuration_spec.rb
|
|
14
|
+
# - add it to the readme so it's documented
|
|
15
|
+
# - add it to the command_line.rb if appropriate (_only_ if it's appropriate)
|
|
16
|
+
# - add it to ENV_OVERRIDES if it can be overridden from ENV
|
|
17
|
+
# - add it to the initializers in /lib/generators/install/templates so it's documented there as well
|
|
18
|
+
|
|
19
|
+
cattr_accessor :mount_at, :root, :asset_paths, :fixture_paths
|
|
20
|
+
@@mount_at = "/teaspoon"
|
|
21
|
+
@@root = nil # will default to Rails.root
|
|
22
|
+
@@asset_paths = ["spec/javascripts", "spec/javascripts/stylesheets", "test/javascripts", "test/javascripts/stylesheets"]
|
|
23
|
+
@@fixture_paths = ["spec/javascripts/fixtures", "test/javascripts/fixtures"]
|
|
24
|
+
|
|
25
|
+
# console runner specific
|
|
26
|
+
|
|
27
|
+
cattr_accessor :driver, :driver_options, :driver_timeout, :server, :server_port, :server_timeout, :fail_fast,
|
|
28
|
+
:formatters, :color, :suppress_log,
|
|
29
|
+
:use_coverage
|
|
30
|
+
@@driver = "phantomjs"
|
|
31
|
+
@@driver_options = nil
|
|
32
|
+
@@driver_timeout = 180
|
|
33
|
+
@@server = nil
|
|
34
|
+
@@server_port = nil
|
|
35
|
+
@@server_timeout = 20
|
|
36
|
+
@@fail_fast = true
|
|
37
|
+
|
|
38
|
+
@@formatters = ["dot"]
|
|
39
|
+
@@color = true
|
|
40
|
+
@@suppress_log = false
|
|
41
|
+
|
|
42
|
+
@@use_coverage = nil
|
|
43
|
+
|
|
44
|
+
# options that can be specified in the ENV
|
|
45
|
+
|
|
46
|
+
ENV_OVERRIDES = {
|
|
47
|
+
boolean: %w(FAIL_FAST SUPPRESS_LOG COLOR),
|
|
48
|
+
integer: %w(DRIVER_TIMEOUT SERVER_TIMEOUT),
|
|
49
|
+
string: %w(DRIVER DRIVER_OPTIONS SERVER SERVER_PORT FORMATTERS USE_COVERAGE)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
# suite configurations
|
|
53
|
+
|
|
54
|
+
cattr_accessor :suite_configs
|
|
55
|
+
@@suite_configs = { "default" => { block: proc {} } }
|
|
56
|
+
|
|
57
|
+
def self.suite(name = :default, &block)
|
|
58
|
+
@@suite_configs[name.to_s] = { block: block, instance: Suite.new(&block) }
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
class Suite
|
|
62
|
+
FRAMEWORKS = {
|
|
63
|
+
jasmine: ["1.3.1", "2.0.0"],
|
|
64
|
+
mocha: ["1.10.0", "1.17.1"],
|
|
65
|
+
qunit: ["1.12.0", "1.14.0"],
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
attr_accessor :matcher, :helper, :javascripts, :stylesheets,
|
|
69
|
+
:boot_partial, :body_partial, :no_coverage, :hooks,
|
|
70
|
+
:expand_assets
|
|
71
|
+
|
|
72
|
+
def initialize
|
|
73
|
+
@matcher = "{spec/javascripts,app/assets}/**/*_spec.{js,js.coffee,coffee}"
|
|
74
|
+
@helper = "spec_helper"
|
|
75
|
+
@javascripts = ["jasmine/1.3.1", "teaspoon-jasmine"]
|
|
76
|
+
@stylesheets = ["teaspoon"]
|
|
77
|
+
|
|
78
|
+
@boot_partial = "boot"
|
|
79
|
+
@body_partial = "body"
|
|
80
|
+
|
|
81
|
+
@no_coverage = [%r{/lib/ruby/gems/}, %r{/vendor/assets/}, %r{/support/}, %r{/(.+)_helper.}]
|
|
82
|
+
|
|
83
|
+
<<<<<<< Updated upstream
|
|
84
|
+
@hooks = Hash.new { |h, k| h[k] = [] }
|
|
85
|
+
=======
|
|
86
|
+
@hooks = Hash.new{ |h, k| h[k] = [] }
|
|
87
|
+
@expand_assets = true
|
|
88
|
+
>>>>>>> Stashed changes
|
|
89
|
+
|
|
90
|
+
default = Teaspoon.configuration.suite_configs["default"]
|
|
91
|
+
instance_eval(&default[:block]) if default
|
|
92
|
+
yield self if block_given?
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def use_framework(name, version = nil)
|
|
96
|
+
name = name.to_sym
|
|
97
|
+
version ||= FRAMEWORKS[name].last if FRAMEWORKS[name]
|
|
98
|
+
unless FRAMEWORKS[name] && FRAMEWORKS[name].include?(version)
|
|
99
|
+
message = "Unknown framework \"#{name}\""
|
|
100
|
+
if FRAMEWORKS[name] && version
|
|
101
|
+
message += " with version #{version} -- available versions #{FRAMEWORKS[name].join(', ')}"
|
|
102
|
+
end
|
|
103
|
+
raise Teaspoon::UnknownFramework, message
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
@javascripts = [[name, version].join("/"), "teaspoon-#{name}"]
|
|
107
|
+
case name.to_sym
|
|
108
|
+
when :qunit
|
|
109
|
+
@matcher = "{test/javascripts,app/assets}/**/*_test.{js,js.coffee,coffee}"
|
|
110
|
+
@helper = "test_helper"
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
alias_method :use_framework=, :use_framework
|
|
114
|
+
|
|
115
|
+
def hook(group = :default, &block)
|
|
116
|
+
@hooks[group.to_s] << block
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
# coverage configurations
|
|
121
|
+
|
|
122
|
+
cattr_accessor :coverage_configs
|
|
123
|
+
@@coverage_configs = { "default" => { block: proc {} } }
|
|
124
|
+
|
|
125
|
+
def self.coverage(name = :default, &block)
|
|
126
|
+
@@coverage_configs[name.to_s] = { block: block, instance: Coverage.new(&block) }
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
class Coverage
|
|
130
|
+
attr_accessor :reports, :output_path,
|
|
131
|
+
:statements, :functions, :branches, :lines
|
|
132
|
+
|
|
133
|
+
def initialize
|
|
134
|
+
@reports = ["text-summary"]
|
|
135
|
+
@output_path = "coverage"
|
|
136
|
+
|
|
137
|
+
@statements = nil
|
|
138
|
+
@functions = nil
|
|
139
|
+
@branches = nil
|
|
140
|
+
@lines = nil
|
|
141
|
+
|
|
142
|
+
default = Teaspoon.configuration.coverage_configs["default"]
|
|
143
|
+
instance_eval(&default[:block]) if default
|
|
144
|
+
yield self if block_given?
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
# custom getters / setters
|
|
149
|
+
|
|
150
|
+
def self.root=(path)
|
|
151
|
+
@@root = Pathname.new(path.to_s) if path.present?
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
def self.formatters
|
|
155
|
+
return ["dot"] if @@formatters.blank?
|
|
156
|
+
return @@formatters if @@formatters.is_a?(Array)
|
|
157
|
+
@@formatters.to_s.split(/,\s?/)
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
# override from env or options
|
|
161
|
+
|
|
162
|
+
def self.override_from_options(options)
|
|
163
|
+
options.each { |k, v| override(k, v) }
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
def self.override_from_env(env)
|
|
167
|
+
ENV_OVERRIDES[:boolean].each { |o| override(o, env[o] == "true") if env[o].present? }
|
|
168
|
+
ENV_OVERRIDES[:integer].each { |o| override(o, env[o].to_i) if env[o].present? }
|
|
169
|
+
ENV_OVERRIDES[:string].each { |o| override(o, env[o]) if env[o].present? }
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
def self.override(config, value)
|
|
173
|
+
setter = "#{config.to_s.downcase}="
|
|
174
|
+
send(setter, value) if respond_to?(setter)
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
mattr_accessor :configured, :configuration
|
|
179
|
+
@@configured = false
|
|
180
|
+
@@configuration = Configuration
|
|
181
|
+
|
|
182
|
+
def self.configure
|
|
183
|
+
yield @@configuration
|
|
184
|
+
@@configured = true
|
|
185
|
+
@@configuration.override_from_env(ENV)
|
|
186
|
+
end
|
|
187
|
+
end
|