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
data/lib/teaspoon/console.rb
CHANGED
@@ -2,17 +2,22 @@ require "teaspoon/environment"
|
|
2
2
|
|
3
3
|
module Teaspoon
|
4
4
|
class Console
|
5
|
-
|
6
5
|
def initialize(options = {})
|
7
|
-
@
|
6
|
+
@default_options = options
|
8
7
|
@suites = {}
|
9
|
-
Teaspoon::Environment.load(
|
8
|
+
Teaspoon::Environment.load(options)
|
10
9
|
|
11
10
|
@server = start_server
|
12
11
|
rescue Teaspoon::ServerException => e
|
13
12
|
abort(e.message)
|
14
13
|
end
|
15
14
|
|
15
|
+
def options
|
16
|
+
@execute_options ||= {}
|
17
|
+
@default_options ||= {}
|
18
|
+
@default_options.merge(@execute_options)
|
19
|
+
end
|
20
|
+
|
16
21
|
def failures?
|
17
22
|
!execute
|
18
23
|
end
|
@@ -21,17 +26,20 @@ module Teaspoon
|
|
21
26
|
execute_without_handling(options)
|
22
27
|
rescue Teaspoon::Failure
|
23
28
|
false
|
29
|
+
rescue Teaspoon::RunnerException => e
|
30
|
+
log(e.message)
|
31
|
+
false
|
24
32
|
rescue Teaspoon::Error => e
|
25
33
|
abort(e.message)
|
26
34
|
end
|
27
35
|
|
28
|
-
def execute_without_handling(
|
29
|
-
@
|
36
|
+
def execute_without_handling(execute_options = {})
|
37
|
+
@execute_options = execute_options
|
30
38
|
@suites = {}
|
31
|
-
resolve(
|
39
|
+
resolve(options[:files])
|
32
40
|
|
33
41
|
0 == suites.inject(0) do |failures, suite|
|
34
|
-
export(suite) if
|
42
|
+
export(suite) if options.include?(:export)
|
35
43
|
failures += run_specs(suite)
|
36
44
|
log("") # empty line for space
|
37
45
|
failures
|
@@ -39,7 +47,10 @@ module Teaspoon
|
|
39
47
|
end
|
40
48
|
|
41
49
|
def run_specs(suite)
|
42
|
-
|
50
|
+
unless Teaspoon.configuration.suite_configs[suite.to_s]
|
51
|
+
raise Teaspoon::UnknownSuite, "Unknown suite: \"#{suite}\""
|
52
|
+
end
|
53
|
+
|
43
54
|
log("Teaspoon running #{suite} suite at #{base_url_for(suite)}")
|
44
55
|
runner = Teaspoon::Runner.new(suite)
|
45
56
|
driver.run_specs(runner, url_for(suite))
|
@@ -48,9 +59,12 @@ module Teaspoon
|
|
48
59
|
end
|
49
60
|
|
50
61
|
def export(suite)
|
51
|
-
|
62
|
+
unless Teaspoon.configuration.suite_configs[suite.to_s]
|
63
|
+
raise Teaspoon::UnknownSuite, "Unknown suite: \"#{suite}\""
|
64
|
+
end
|
65
|
+
|
52
66
|
log("Teaspoon exporting #{suite} suite at #{base_url_for(suite)}")
|
53
|
-
Teaspoon::Exporter.new(suite, url_for(suite, false),
|
67
|
+
Teaspoon::Exporter.new(suite, url_for(suite, false), options[:export]).export
|
54
68
|
end
|
55
69
|
|
56
70
|
protected
|
@@ -66,14 +80,14 @@ module Teaspoon
|
|
66
80
|
end
|
67
81
|
|
68
82
|
def start_server
|
69
|
-
log("Starting the Teaspoon server...")
|
70
83
|
server = Teaspoon::Server.new
|
84
|
+
log("Starting the Teaspoon server...") unless server.responsive?
|
71
85
|
server.start
|
72
86
|
server
|
73
87
|
end
|
74
88
|
|
75
89
|
def suites
|
76
|
-
return [
|
90
|
+
return [options[:suite]] if options[:suite].present?
|
77
91
|
return @suites.keys if @suites.present?
|
78
92
|
Teaspoon.configuration.suite_configs.keys
|
79
93
|
end
|
@@ -87,19 +101,19 @@ module Teaspoon
|
|
87
101
|
end
|
88
102
|
|
89
103
|
def base_url_for(suite)
|
90
|
-
["#{@server.url}#{Teaspoon.configuration.mount_at}", suite].join(
|
104
|
+
["#{@server.url}#{Teaspoon.configuration.mount_at}", suite].join("/")
|
91
105
|
end
|
92
106
|
|
93
107
|
def url_for(suite, console = true)
|
94
|
-
url = [base_url_for(suite), filter(suite)].compact.join(
|
95
|
-
url += "#{(url.include?(
|
108
|
+
url = [base_url_for(suite), filter(suite)].compact.join("?")
|
109
|
+
url += "#{(url.include?('?') ? '&' : '?')}reporter=Console" if console
|
96
110
|
url
|
97
111
|
end
|
98
112
|
|
99
113
|
def filter(suite)
|
100
114
|
parts = []
|
101
|
-
parts << "grep=#{URI::encode(
|
102
|
-
(@suites[suite] ||
|
115
|
+
parts << "grep=#{URI::encode(options[:filter])}" if options[:filter].present?
|
116
|
+
(@suites[suite] || options[:files] || []).flatten.each { |file| parts << "file[]=#{URI::encode(file)}" }
|
103
117
|
"#{parts.join('&')}" if parts.present?
|
104
118
|
end
|
105
119
|
|
data/lib/teaspoon/coverage.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
module Teaspoon
|
2
2
|
class Coverage
|
3
|
-
|
4
3
|
def initialize(suite_name, config_name, data)
|
5
4
|
@suite_name = suite_name
|
6
5
|
@data = data
|
@@ -11,7 +10,7 @@ module Teaspoon
|
|
11
10
|
def generate_reports(&block)
|
12
11
|
input_path do |input|
|
13
12
|
results = []
|
14
|
-
|
13
|
+
@config.reports.each do |format|
|
15
14
|
result = generate_report(input, format)
|
16
15
|
results << result if ["text", "text-summary"].include?(format.to_s)
|
17
16
|
end
|
@@ -48,7 +47,7 @@ module Teaspoon
|
|
48
47
|
|
49
48
|
def generate_report(input, format)
|
50
49
|
output_path = File.join(@config.output_path, @suite_name)
|
51
|
-
result = %x{#{@executable} report
|
50
|
+
result = %x{#{@executable} report --include=#{input.shellescape} --dir #{output_path} #{format} 2>&1}
|
52
51
|
return result.gsub("Done", "").gsub("Using reporter [#{format}]", "").strip if $?.exitstatus == 0
|
53
52
|
raise Teaspoon::DependencyFailure, "Could not generate coverage report for #{format}"
|
54
53
|
end
|
data/lib/teaspoon/deprecated.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
module Teaspoon
|
2
|
-
|
3
2
|
def self.setup(&block)
|
4
3
|
Teaspoon.dep("Teaspoon.setup is deprecated, use Teaspoon.configure instead. The /initializer/teaspoon.rb file should be removed, and a new teaspoon_env.rb file should be created by running the install generator.")
|
5
4
|
configure(&block)
|
@@ -16,8 +15,7 @@ module Teaspoon
|
|
16
15
|
end
|
17
16
|
|
18
17
|
class Configuration
|
19
|
-
|
20
|
-
def self.context=(*args)
|
18
|
+
def self.context=(*_args)
|
21
19
|
Teaspoon.dep("the teaspoon context directive is no longer used, remove it from your configuration.")
|
22
20
|
end
|
23
21
|
|
@@ -45,19 +43,26 @@ teaspoon coverage directive has changed and is now more flexible, define coverag
|
|
45
43
|
> set: config.use_coverage = "CI"
|
46
44
|
MESSAGE
|
47
45
|
|
48
|
-
|
49
|
-
|
46
|
+
[
|
47
|
+
"coverage",
|
48
|
+
"coverage_reports",
|
49
|
+
"coverage_output_dir",
|
50
|
+
"statements_coverage_threshold",
|
51
|
+
"functions_coverage_threshold",
|
52
|
+
"branches_coverage_threshold",
|
53
|
+
"lines_coverage_threshold"
|
54
|
+
].each do |method|
|
55
|
+
define_singleton_method("#{method}=") do |*_args|
|
50
56
|
Teaspoon.dep(@coverage_dep_message, :coverage)
|
51
57
|
end
|
52
58
|
end
|
53
59
|
|
54
60
|
class Suite
|
55
|
-
|
56
|
-
def js_config=(*args)
|
61
|
+
def js_config=(*_args)
|
57
62
|
Teaspoon.dep("the teaspoon suite js_config directive is no longer used, use the install generator to install the boot partial and customize it instead.", :js_config)
|
58
63
|
end
|
59
64
|
|
60
|
-
def normalize_asset_path=(*
|
65
|
+
def normalize_asset_path=(*_args)
|
61
66
|
Teaspoon.dep("the teaspoon suite normalize_asset_path directive is no longer used, reopen Teaspoon::Suite and define a normalize_js_extension method instead.", :normalize_asset_path)
|
62
67
|
end
|
63
68
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module Teaspoon
|
2
2
|
module Drivers
|
3
|
-
|
4
3
|
autoload :PhantomjsDriver, "teaspoon/drivers/phantomjs_driver"
|
5
|
-
autoload :SeleniumDriver,
|
4
|
+
autoload :SeleniumDriver, "teaspoon/drivers/selenium_driver"
|
5
|
+
autoload :CapybaraWebkitDriver, "teaspoon/drivers/capybara_webkit_driver"
|
6
6
|
|
7
7
|
class Base
|
8
8
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
begin
|
2
|
+
require "capybara-webkit"
|
3
|
+
rescue LoadError
|
4
|
+
STDOUT.print("Could not find Capybara Webkit. Install the capybara-webkit gem.\n")
|
5
|
+
exit(1)
|
6
|
+
end
|
7
|
+
|
8
|
+
module Teaspoon
|
9
|
+
module Drivers
|
10
|
+
class CapybaraWebkitDriver < Base
|
11
|
+
def initialize(_ = nil)
|
12
|
+
end
|
13
|
+
|
14
|
+
def run_specs(runner, url)
|
15
|
+
session.visit(url)
|
16
|
+
|
17
|
+
session.document.synchronize(Teaspoon.configuration.driver_timeout.to_i) do
|
18
|
+
done = session.evaluate_script("window.Teaspoon && window.Teaspoon.finished")
|
19
|
+
(session.evaluate_script("window.Teaspoon && window.Teaspoon.getMessages()") || []).each do |line|
|
20
|
+
runner.process("#{line}\n")
|
21
|
+
end
|
22
|
+
done
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def session
|
29
|
+
@session ||= Capybara::Session.new(:webkit)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -76,8 +76,8 @@
|
|
76
76
|
if (_this.errorTimeout) clearTimeout(_this.errorTimeout);
|
77
77
|
if (_this.errored) {
|
78
78
|
_this.errorTimeout = setTimeout((function() {
|
79
|
-
return _this.fail("Javascript error has
|
80
|
-
}),
|
79
|
+
return _this.fail("Javascript error has caused a timeout.");
|
80
|
+
}), _this.timeout);
|
81
81
|
return _this.errored = false;
|
82
82
|
}
|
83
83
|
},
|
@@ -12,9 +12,9 @@ module Teaspoon
|
|
12
12
|
def initialize(options = nil)
|
13
13
|
options ||= []
|
14
14
|
case options
|
15
|
-
when Array
|
15
|
+
when Array then @options = options
|
16
16
|
when String then @options = options.split(" ")
|
17
|
-
when Hash
|
17
|
+
when Hash then @options = options.map { |k, v| "--#{k}=#{v}" }
|
18
18
|
else raise Teaspoon::UnknownDriverOptions, "Unknown driver options -- supply a string, array or hash"
|
19
19
|
end
|
20
20
|
end
|
@@ -28,11 +28,20 @@ module Teaspoon
|
|
28
28
|
protected
|
29
29
|
|
30
30
|
def run(*args, &block)
|
31
|
-
IO.popen([executable, *args].join(
|
31
|
+
IO.popen([executable, *args].join(" ")) { |io| io.each(&block) }
|
32
32
|
end
|
33
33
|
|
34
34
|
def driver_options(url)
|
35
|
-
[
|
35
|
+
[
|
36
|
+
@options,
|
37
|
+
escape_quotes(script),
|
38
|
+
escape_quotes(url),
|
39
|
+
Teaspoon.configuration.driver_timeout
|
40
|
+
].flatten.compact
|
41
|
+
end
|
42
|
+
|
43
|
+
def escape_quotes(string)
|
44
|
+
%{"#{string.gsub('"', '\"')}"}
|
36
45
|
end
|
37
46
|
|
38
47
|
def executable
|
@@ -8,11 +8,10 @@ end
|
|
8
8
|
module Teaspoon
|
9
9
|
module Drivers
|
10
10
|
class SeleniumDriver < Base
|
11
|
-
|
12
11
|
def initialize(options = nil)
|
13
12
|
options ||= {}
|
14
13
|
case options
|
15
|
-
when Hash
|
14
|
+
when Hash then @options = options
|
16
15
|
when String then @options = JSON.parse(options)
|
17
16
|
else raise Teaspoon::UnknownDriverOptions, "Unknown driver options -- supply a hash or json string"
|
18
17
|
end
|
@@ -39,14 +38,13 @@ module Teaspoon
|
|
39
38
|
protected
|
40
39
|
|
41
40
|
def driver_options
|
42
|
-
@driver_options ||= HashWithIndifferentAccess.new(
|
41
|
+
@driver_options ||= HashWithIndifferentAccess.new(
|
43
42
|
client_driver: :firefox,
|
44
43
|
timeout: Teaspoon.configuration.driver_timeout.to_i,
|
45
44
|
interval: 0.01,
|
46
45
|
message: "Timed out"
|
47
|
-
|
46
|
+
).merge(@options)
|
48
47
|
end
|
49
48
|
end
|
50
49
|
end
|
51
50
|
end
|
52
|
-
|
data/lib/teaspoon/engine.rb
CHANGED
@@ -4,9 +4,31 @@ require "teaspoon/instrumentation"
|
|
4
4
|
|
5
5
|
module Teaspoon
|
6
6
|
class Engine < ::Rails::Engine
|
7
|
-
|
8
7
|
isolate_namespace Teaspoon
|
9
8
|
|
9
|
+
ASSET_MANIFEST = [
|
10
|
+
# core library
|
11
|
+
'teaspoon.css',
|
12
|
+
'teaspoon-teaspoon.js',
|
13
|
+
|
14
|
+
# framework ties
|
15
|
+
'teaspoon/*.js',
|
16
|
+
'teaspoon-jasmine.js',
|
17
|
+
'teaspoon-mocha.js',
|
18
|
+
'teaspoon-qunit.js',
|
19
|
+
|
20
|
+
# frameworks
|
21
|
+
'jasmine/1.3.1.js',
|
22
|
+
'jasmine/2.0.0.js',
|
23
|
+
'mocha/1.10.0.js',
|
24
|
+
'mocha/1.17.1.js',
|
25
|
+
'qunit/1.12.0.js',
|
26
|
+
'qunit/1.14.0.js',
|
27
|
+
|
28
|
+
# all support libraries
|
29
|
+
'support/*.js'
|
30
|
+
]
|
31
|
+
|
10
32
|
initializer :assets, group: :all do |app|
|
11
33
|
begin
|
12
34
|
Teaspoon::Environment.require_environment
|
@@ -16,6 +38,7 @@ module Teaspoon
|
|
16
38
|
|
17
39
|
Teaspoon::Engine.default_root_path(app.root) # default the root if it's not set
|
18
40
|
Teaspoon::Engine.append_asset_paths(app.config.assets) # append the asset paths from the configuration
|
41
|
+
Teaspoon::Engine.add_precompiled_assets(app.config.assets)
|
19
42
|
end
|
20
43
|
|
21
44
|
config.after_initialize do |app|
|
@@ -23,8 +46,6 @@ module Teaspoon
|
|
23
46
|
Teaspoon::Engine.prepend_routes(app) # prepend routes so a catchall doesn't get in the way
|
24
47
|
end
|
25
48
|
|
26
|
-
private
|
27
|
-
|
28
49
|
def self.default_root_path(root)
|
29
50
|
Teaspoon.configuration.root ||= root
|
30
51
|
end
|
@@ -35,16 +56,23 @@ module Teaspoon
|
|
35
56
|
end
|
36
57
|
end
|
37
58
|
|
59
|
+
def self.add_precompiled_assets(assets)
|
60
|
+
assets.precompile += ASSET_MANIFEST
|
61
|
+
end
|
62
|
+
|
38
63
|
def self.inject_instrumentation
|
39
64
|
Sprockets::Environment.send(:include, Teaspoon::SprocketsInstrumentation)
|
65
|
+
Sprockets::Index.send(:include, Teaspoon::SprocketsInstrumentation)
|
40
66
|
end
|
41
67
|
|
42
68
|
def self.prepend_routes(app)
|
43
|
-
|
69
|
+
mount_at = Teaspoon.configuration.mount_at
|
70
|
+
|
71
|
+
return if app.routes.recognize_path(mount_at)[:action] != "routing_error" rescue nil
|
44
72
|
require Teaspoon::Engine.root.join("app/controllers/teaspoon/suite_controller")
|
45
73
|
|
46
74
|
app.routes.prepend do
|
47
|
-
mount Teaspoon::Engine =>
|
75
|
+
mount Teaspoon::Engine => mount_at, as: "teaspoon"
|
48
76
|
end
|
49
77
|
end
|
50
78
|
end
|
data/lib/teaspoon/environment.rb
CHANGED
@@ -2,7 +2,6 @@ require "teaspoon/exceptions"
|
|
2
2
|
|
3
3
|
module Teaspoon
|
4
4
|
module Environment
|
5
|
-
|
6
5
|
def self.load(options = {})
|
7
6
|
require_environment(options[:environment])
|
8
7
|
raise "Rails environment not found." unless rails_loaded?
|
@@ -28,11 +27,10 @@ module Teaspoon
|
|
28
27
|
standard_environments.each do |filename|
|
29
28
|
file = File.expand_path(filename, Dir.pwd)
|
30
29
|
return require_env(file) if File.exists?(file)
|
31
|
-
#file = File.expand_path(filename, File.join(Dir.pwd, '../..'))
|
32
|
-
#return require_env(file) if File.exists?(file)
|
33
30
|
end
|
34
31
|
|
35
|
-
raise Teaspoon::EnvironmentNotFound,
|
32
|
+
raise Teaspoon::EnvironmentNotFound,
|
33
|
+
"Unable to load Teaspoon environment in {#{standard_environments.join(', ')}}"
|
36
34
|
end
|
37
35
|
|
38
36
|
def self.standard_environments
|
data/lib/teaspoon/exceptions.rb
CHANGED
@@ -6,6 +6,7 @@ module Teaspoon
|
|
6
6
|
class RunnerException < Teaspoon::Error; end
|
7
7
|
class ExporterException < Teaspoon::Error; end
|
8
8
|
class UnknownFramework < Teaspoon::Error; end
|
9
|
+
class UnknownCoverage < Teaspoon::Error; end
|
9
10
|
class UnknownDriver < Teaspoon::Error; end
|
10
11
|
class UnknownDriverOptions < Teaspoon::Error; end
|
11
12
|
class UnknownFormatter < Teaspoon::Error; end
|
@@ -17,12 +18,14 @@ module Teaspoon
|
|
17
18
|
class FileNotWritable < Teaspoon::Error; end
|
18
19
|
|
19
20
|
module ExceptionHandling
|
20
|
-
|
21
21
|
def self.add_rails_handling
|
22
22
|
return unless Teaspoon.configuration.driver == "phantomjs"
|
23
23
|
|
24
|
-
#
|
25
|
-
Rails.application.config.
|
24
|
+
# debugging should be off to display errors in the suite_controller
|
25
|
+
# Rails.application.config.assets.debug = false
|
26
|
+
|
27
|
+
# we want rails to display exceptions
|
28
|
+
Rails.application.config.action_dispatch.show_exceptions = true
|
26
29
|
|
27
30
|
# override the render exception method in ActionDispatch to raise a javascript exception
|
28
31
|
render_exceptions_with_javascript
|
@@ -32,10 +35,10 @@ module Teaspoon
|
|
32
35
|
|
33
36
|
def self.render_exceptions_with_javascript
|
34
37
|
ActionDispatch::DebugExceptions.class_eval do
|
35
|
-
def render_exception(
|
38
|
+
def render_exception(_env, exception)
|
36
39
|
message = "#{exception.class.name}: #{exception.message}"
|
37
40
|
body = "<script>throw Error(#{[message, exception.backtrace].join("\n").inspect})</script>"
|
38
|
-
[200, {
|
41
|
+
[200, { "Content-Type" => "text/html;", "Content-Length" => body.bytesize.to_s }, [body]]
|
39
42
|
end
|
40
43
|
end
|
41
44
|
end
|