teaspoon 0.9.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +141 -0
- data/README.md +9 -19
- data/{vendor → app}/assets/javascripts/support/bind-poly.js +0 -0
- data/{vendor → app}/assets/javascripts/support/sinon.js +0 -0
- data/app/assets/javascripts/teaspoon-filterer.js +55 -0
- data/app/assets/javascripts/teaspoon/error.coffee +5 -0
- data/app/assets/javascripts/teaspoon/{base/fixture.coffee → fixture.coffee} +15 -15
- data/app/assets/javascripts/teaspoon/{base/hook.coffee → hook.coffee} +0 -0
- data/app/assets/javascripts/teaspoon/{base/reporters → reporters}/console.coffee +18 -10
- data/app/assets/javascripts/teaspoon/{base/reporters → reporters}/html.coffee +43 -40
- data/app/assets/javascripts/teaspoon/{base/reporters → reporters}/html/base_view.coffee +0 -0
- data/app/assets/javascripts/teaspoon/{base/reporters → reporters}/html/failure_view.coffee +2 -0
- data/app/assets/javascripts/teaspoon/reporters/html/progress_view.coffee +18 -0
- data/app/assets/javascripts/teaspoon/{base/reporters/html/progress_view.coffee → reporters/html/radial_progress_view.coffee} +1 -34
- data/app/assets/javascripts/teaspoon/reporters/html/simple_progress_view.coffee +15 -0
- data/app/assets/javascripts/teaspoon/{base/reporters → reporters}/html/spec_view.coffee +5 -3
- data/app/assets/javascripts/teaspoon/{base/reporters → reporters}/html/suite_view.coffee +4 -2
- data/app/assets/javascripts/teaspoon/{base/reporters → reporters}/html/template.coffee +0 -0
- data/app/assets/javascripts/teaspoon/{base/runner.coffee → runner.coffee} +7 -3
- data/app/assets/javascripts/teaspoon/teaspoon.coffee +90 -32
- data/app/controllers/teaspoon/suite_controller.rb +5 -0
- data/app/views/teaspoon/suite/index.html.erb +1 -1
- data/lib/generators/teaspoon/install/install_generator.rb +67 -37
- data/lib/generators/teaspoon/install/templates/MISSING_FRAMEWORK +14 -0
- data/lib/generators/teaspoon/install/{POST_INSTALL → templates/POST_INSTALL} +0 -0
- data/lib/generators/teaspoon/install/templates/env.rb.tt +14 -0
- data/lib/generators/teaspoon/install/templates/{jasmine/env_comments.rb.tt → env_comments.rb.tt} +34 -43
- data/lib/tasks/teaspoon/info.rake +17 -0
- data/lib/teaspoon-devkit.rb +61 -0
- data/lib/teaspoon.rb +2 -0
- data/lib/teaspoon/command_line.rb +19 -14
- data/lib/teaspoon/configuration.rb +24 -35
- data/lib/teaspoon/console.rb +11 -21
- data/lib/teaspoon/coverage.rb +14 -7
- data/lib/teaspoon/deprecated.rb +22 -4
- data/lib/teaspoon/driver.rb +15 -0
- data/lib/teaspoon/driver/base.rb +7 -0
- data/lib/teaspoon/{drivers/capybara_webkit_driver.rb → driver/capybara_webkit.rb} +8 -5
- data/lib/teaspoon/{drivers/phantomjs_driver.rb → driver/phantomjs.rb} +8 -4
- data/lib/teaspoon/{drivers → driver}/phantomjs/runner.js +0 -0
- data/lib/teaspoon/{drivers/selenium_driver.rb → driver/selenium.rb} +11 -9
- data/lib/teaspoon/engine.rb +38 -25
- data/lib/teaspoon/environment.rb +24 -15
- data/lib/teaspoon/exceptions.rb +154 -41
- data/lib/teaspoon/exporter.rb +2 -2
- data/lib/teaspoon/formatter.rb +30 -0
- data/lib/teaspoon/{formatters → formatter}/base.rb +2 -36
- data/lib/teaspoon/{formatters/clean_formatter.rb → formatter/clean.rb} +4 -2
- data/lib/teaspoon/{formatters/documentation_formatter.rb → formatter/documentation.rb} +4 -3
- data/lib/teaspoon/{formatters/dot_formatter.rb → formatter/dot.rb} +4 -3
- data/lib/teaspoon/{formatters/json_formatter.rb → formatter/json.rb} +4 -2
- data/lib/teaspoon/{formatters/junit_formatter.rb → formatter/junit.rb} +3 -2
- data/lib/teaspoon/{formatters → formatter}/modules/report_module.rb +1 -1
- data/lib/teaspoon/{formatters/pride_formatter.rb → formatter/pride.rb} +4 -2
- data/lib/teaspoon/{formatters/rspec_html_formatter.rb → formatter/rspec_html.rb} +3 -2
- data/lib/teaspoon/{formatters/snowday_formatter.rb → formatter/snowday.rb} +3 -2
- data/lib/teaspoon/formatter/swayze_or_oprah.rb +111 -0
- data/lib/teaspoon/{formatters/tap_formatter.rb → formatter/tap.rb} +4 -2
- data/lib/teaspoon/{formatters/tap_y_formatter.rb → formatter/tap_y.rb} +3 -2
- data/lib/teaspoon/{formatters/teamcity_formatter.rb → formatter/teamcity.rb} +4 -2
- data/lib/teaspoon/framework.rb +17 -0
- data/lib/teaspoon/framework/base.rb +88 -0
- data/lib/teaspoon/instrumentation.rb +12 -2
- data/lib/teaspoon/registry.rb +47 -0
- data/lib/teaspoon/registry/has_default.rb +11 -0
- data/lib/teaspoon/runner.rb +6 -7
- data/lib/teaspoon/server.rb +2 -2
- data/lib/teaspoon/suite.rb +28 -30
- data/lib/teaspoon/utility.rb +5 -0
- data/lib/teaspoon/version.rb +1 -1
- metadata +52 -276
- data/app/assets/javascripts/teaspoon-jasmine.js +0 -1344
- data/app/assets/javascripts/teaspoon-mocha.js +0 -1350
- data/app/assets/javascripts/teaspoon-qunit.js +0 -1415
- data/app/assets/javascripts/teaspoon-teaspoon.js +0 -51
- data/app/assets/javascripts/teaspoon/base/teaspoon.coffee +0 -69
- data/app/assets/javascripts/teaspoon/jasmine.coffee +0 -119
- data/app/assets/javascripts/teaspoon/jasmine/reporters/html.coffee +0 -11
- data/app/assets/javascripts/teaspoon/mocha.coffee +0 -90
- data/app/assets/javascripts/teaspoon/mocha/reporters/console.coffee +0 -16
- data/app/assets/javascripts/teaspoon/mocha/reporters/html.coffee +0 -27
- data/app/assets/javascripts/teaspoon/qunit.coffee +0 -81
- data/app/assets/javascripts/teaspoon/qunit/reporters/console.coffee +0 -25
- data/app/assets/javascripts/teaspoon/qunit/reporters/html.coffee +0 -80
- data/lib/generators/teaspoon/install/templates/jasmine/env.rb +0 -11
- data/lib/generators/teaspoon/install/templates/jasmine/spec_helper.coffee +0 -31
- data/lib/generators/teaspoon/install/templates/jasmine/spec_helper.js +0 -31
- data/lib/generators/teaspoon/install/templates/mocha/env.rb +0 -11
- data/lib/generators/teaspoon/install/templates/mocha/env_comments.rb.tt +0 -187
- data/lib/generators/teaspoon/install/templates/mocha/spec_helper.coffee +0 -40
- data/lib/generators/teaspoon/install/templates/mocha/spec_helper.js +0 -40
- data/lib/generators/teaspoon/install/templates/qunit/env.rb +0 -11
- data/lib/generators/teaspoon/install/templates/qunit/env_comments.rb.tt +0 -187
- data/lib/generators/teaspoon/install/templates/qunit/test_helper.coffee +0 -29
- data/lib/generators/teaspoon/install/templates/qunit/test_helper.js +0 -30
- data/lib/teaspoon/drivers/base.rb +0 -10
- data/lib/teaspoon/formatters/description.rb +0 -36
- data/lib/teaspoon/formatters/swayze_or_oprah_formatter.rb +0 -101
- data/spec/dummy/Rakefile +0 -7
- data/spec/dummy/app/assets/javascripts/instrumented1.coffee +0 -1
- data/spec/dummy/app/assets/javascripts/instrumented2.coffee +0 -1
- data/spec/dummy/app/assets/javascripts/integration/integration.coffee +0 -1
- data/spec/dummy/app/assets/javascripts/integration/integration_spec.coffee +0 -32
- data/spec/dummy/app/assets/javascripts/integration/spec_helper.coffee +0 -7
- data/spec/dummy/app/assets/javascripts/specs/asset_spec.js +0 -11
- data/spec/dummy/config.ru +0 -15
- data/spec/dummy/config/application.rb +0 -29
- data/spec/dummy/config/boot.rb +0 -3
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -41
- data/spec/dummy/config/environments/production.rb +0 -79
- data/spec/dummy/config/environments/test.rb +0 -42
- data/spec/dummy/config/routes.rb +0 -2
- data/spec/dummy/config/secrets.yml +0 -22
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +0 -6
- data/spec/features/console_reporter_spec.rb +0 -62
- data/spec/features/hooks_spec.rb +0 -60
- data/spec/features/html_reporter_spec.rb +0 -81
- data/spec/features/install_generator_spec.rb +0 -54
- data/spec/features/instrumentation_spec.rb +0 -21
- data/spec/fixtures/coverage.json +0 -243
- data/spec/javascripts/fixtures/_body.html.erb +0 -1
- data/spec/javascripts/fixtures/fixture.html.haml +0 -4
- data/spec/javascripts/fixtures/fixture.json +0 -4
- data/spec/javascripts/jasmine_helper.coffee +0 -3
- data/spec/javascripts/mocha_helper.coffee +0 -4
- data/spec/javascripts/spec_helper.coffee +0 -7
- data/spec/javascripts/stylesheets/stylesheet.css.scss +0 -0
- data/spec/javascripts/support/json2.js +0 -486
- data/spec/javascripts/support/support.js.coffee +0 -0
- data/spec/javascripts/teaspoon/base/fixture_spec.coffee +0 -93
- data/spec/javascripts/teaspoon/base/reporters/console_spec.coffee +0 -162
- data/spec/javascripts/teaspoon/base/reporters/html/base_view_spec.coffee +0 -88
- data/spec/javascripts/teaspoon/base/reporters/html/failure_view_spec.coffee +0 -28
- data/spec/javascripts/teaspoon/base/reporters/html/progress_view_spec.coffee +0 -1
- data/spec/javascripts/teaspoon/base/reporters/html/spec_view_spec.coffee +0 -1
- data/spec/javascripts/teaspoon/base/reporters/html/suite_view_spec.coffee +0 -1
- data/spec/javascripts/teaspoon/base/reporters/html_spec.coffee +0 -372
- data/spec/javascripts/teaspoon/base/runner_spec.coffee +0 -58
- data/spec/javascripts/teaspoon/base/teaspoon_spec.coffee +0 -47
- data/spec/javascripts/teaspoon/jasmine/fixture_jspec.coffee +0 -13
- data/spec/javascripts/teaspoon/jasmine/models_jspec.coffee +0 -101
- data/spec/javascripts/teaspoon/jasmine/reporters/html_jspec.coffee +0 -17
- data/spec/javascripts/teaspoon/jasmine/runner_jspec.coffee +0 -59
- data/spec/javascripts/teaspoon/jasmine/spec_jspec.coffee +0 -3
- data/spec/javascripts/teaspoon/mocha/fixture_mspec.coffee +0 -12
- data/spec/javascripts/teaspoon/mocha/models_mspec.coffee +0 -93
- data/spec/javascripts/teaspoon/mocha/reporters/console_mspec.coffee +0 -24
- data/spec/javascripts/teaspoon/mocha/reporters/html_mspec.coffee +0 -41
- data/spec/javascripts/teaspoon/mocha/runner_mspec.coffee +0 -23
- data/spec/javascripts/teaspoon/mocha/spec_mspec.coffee +0 -9
- data/spec/javascripts/teaspoon/other/erb_spec.js.coffee.erb +0 -4
- data/spec/javascripts/teaspoon/phantomjs/runner_spec.coffee +0 -161
- data/spec/javascripts/turbolinks_helper.coffee +0 -2
- data/spec/spec_helper.rb +0 -25
- data/spec/support/aruba.rb +0 -15
- data/spec/teaspoon/command_line_spec.rb +0 -157
- data/spec/teaspoon/configuration_spec.rb +0 -236
- data/spec/teaspoon/console_spec.rb +0 -224
- data/spec/teaspoon/coverage_spec.rb +0 -118
- data/spec/teaspoon/drivers/base_spec.rb +0 -5
- data/spec/teaspoon/drivers/capybara_webkit_driver_spec.rb +0 -39
- data/spec/teaspoon/drivers/phantomjs_driver_spec.rb +0 -66
- data/spec/teaspoon/drivers/selenium_driver_spec.rb +0 -68
- data/spec/teaspoon/engine_spec.rb +0 -22
- data/spec/teaspoon/environment_spec.rb +0 -109
- data/spec/teaspoon/exceptions_spec.rb +0 -57
- data/spec/teaspoon/exporter_spec.rb +0 -96
- data/spec/teaspoon/formatters/base_spec.rb +0 -259
- data/spec/teaspoon/formatters/clean_formatter_spec.rb +0 -37
- data/spec/teaspoon/formatters/documentation_formatter_spec.rb +0 -127
- data/spec/teaspoon/formatters/dot_formatter_spec.rb +0 -116
- data/spec/teaspoon/formatters/json_formatter_spec.rb +0 -77
- data/spec/teaspoon/formatters/junit_formatter_spec.rb +0 -114
- data/spec/teaspoon/formatters/pride_formatter_spec.rb +0 -37
- data/spec/teaspoon/formatters/rspec_html_formatter_spec.rb +0 -107
- data/spec/teaspoon/formatters/snowday_formatter_spec.rb +0 -35
- data/spec/teaspoon/formatters/tap_formatter_spec.rb +0 -72
- data/spec/teaspoon/formatters/tap_y_formatter_spec.rb +0 -80
- data/spec/teaspoon/formatters/teamcity_formatter_spec.rb +0 -148
- data/spec/teaspoon/instrumentation_spec.rb +0 -113
- data/spec/teaspoon/result_spec.rb +0 -98
- data/spec/teaspoon/runner_spec.rb +0 -116
- data/spec/teaspoon/server_spec.rb +0 -105
- data/spec/teaspoon/suite_spec.rb +0 -138
- data/spec/teaspoon_env.rb +0 -39
- data/test/javascripts/qunit_helper.coffee +0 -3
- data/test/javascripts/teaspoon/qunit/fixture_test.coffee +0 -10
- data/test/javascripts/teaspoon/qunit/models_test.coffee +0 -66
- data/test/javascripts/teaspoon/qunit/reporters/console_test.coffee +0 -3
- data/test/javascripts/teaspoon/qunit/reporters/html/failure_view_test.coffee +0 -3
- data/test/javascripts/teaspoon/qunit/reporters/html/spec_view_test.coffee +0 -3
- data/test/javascripts/teaspoon/qunit/reporters/html/suite_view_test.coffee +0 -3
- data/test/javascripts/teaspoon/qunit/reporters/html_test.coffee +0 -3
- data/test/javascripts/teaspoon/qunit/runner_test.coffee +0 -18
- data/vendor/assets/javascripts/jasmine/1.3.1.js +0 -2602
- data/vendor/assets/javascripts/jasmine/2.0.0.js +0 -2412
- data/vendor/assets/javascripts/jasmine/MIT.LICENSE +0 -20
- data/vendor/assets/javascripts/mocha/1.10.0.js +0 -5374
- data/vendor/assets/javascripts/mocha/1.17.1.js +0 -5813
- data/vendor/assets/javascripts/mocha/MIT.LICENSE +0 -22
- data/vendor/assets/javascripts/qunit/1.12.0.js +0 -2212
- data/vendor/assets/javascripts/qunit/1.14.0.js +0 -2288
- data/vendor/assets/javascripts/qunit/MIT.LICENSE +0 -21
- data/vendor/assets/javascripts/support/chai-1.10.0.js +0 -4800
- data/vendor/assets/javascripts/support/chai-jq-0.0.7.js +0 -524
- data/vendor/assets/javascripts/support/chai.js +0 -4782
- data/vendor/assets/javascripts/support/expect.js +0 -1284
- data/vendor/assets/javascripts/support/jasmine-jquery-1.7.0.js +0 -720
- data/vendor/assets/javascripts/support/jasmine-jquery-2.0.0.js +0 -812
- data/vendor/assets/javascripts/support/sinon-chai.js +0 -126
data/lib/teaspoon/console.rb
CHANGED
@@ -5,11 +5,12 @@ module Teaspoon
|
|
5
5
|
def initialize(options = {})
|
6
6
|
@default_options = options
|
7
7
|
@suites = {}
|
8
|
+
Teaspoon::Environment.check_env!(options[:environment])
|
8
9
|
Teaspoon::Environment.load(options)
|
9
10
|
|
10
11
|
@server = start_server
|
11
|
-
rescue Teaspoon::
|
12
|
-
abort(e.message)
|
12
|
+
rescue Teaspoon::ServerError => e
|
13
|
+
Teaspoon.abort(e.message)
|
13
14
|
end
|
14
15
|
|
15
16
|
def options
|
@@ -26,11 +27,11 @@ module Teaspoon
|
|
26
27
|
execute_without_handling(options)
|
27
28
|
rescue Teaspoon::Failure
|
28
29
|
false
|
29
|
-
rescue Teaspoon::
|
30
|
+
rescue Teaspoon::RunnerError => e
|
30
31
|
log(e.message)
|
31
32
|
false
|
32
33
|
rescue Teaspoon::Error => e
|
33
|
-
abort(e.message)
|
34
|
+
Teaspoon.abort(e.message)
|
34
35
|
end
|
35
36
|
|
36
37
|
def execute_without_handling(execute_options = {})
|
@@ -47,9 +48,7 @@ module Teaspoon
|
|
47
48
|
end
|
48
49
|
|
49
50
|
def run_specs(suite)
|
50
|
-
unless Teaspoon.configuration.suite_configs[suite.to_s]
|
51
|
-
raise Teaspoon::UnknownSuite, "Unknown suite: \"#{suite}\""
|
52
|
-
end
|
51
|
+
raise Teaspoon::UnknownSuite.new(name: suite) unless Teaspoon.configuration.suite_configs[suite.to_s]
|
53
52
|
|
54
53
|
log("Teaspoon running #{suite} suite at #{base_url_for(suite)}")
|
55
54
|
runner = Teaspoon::Runner.new(suite)
|
@@ -59,9 +58,7 @@ module Teaspoon
|
|
59
58
|
end
|
60
59
|
|
61
60
|
def export(suite)
|
62
|
-
unless Teaspoon.configuration.suite_configs[suite.to_s]
|
63
|
-
raise Teaspoon::UnknownSuite, "Unknown suite: \"#{suite}\""
|
64
|
-
end
|
61
|
+
raise Teaspoon::UnknownSuite.new(name: suite) unless Teaspoon.configuration.suite_configs[suite.to_s]
|
65
62
|
|
66
63
|
log("Teaspoon exporting #{suite} suite at #{base_url_for(suite)}")
|
67
64
|
Teaspoon::Exporter.new(suite, url_for(suite, false), options[:export]).export
|
@@ -94,10 +91,8 @@ module Teaspoon
|
|
94
91
|
|
95
92
|
def driver
|
96
93
|
return @driver if @driver
|
97
|
-
|
98
|
-
@driver =
|
99
|
-
rescue NameError
|
100
|
-
raise Teaspoon::UnknownDriver, "Unknown driver: \"#{Teaspoon.configuration.driver}\""
|
94
|
+
driver = Teaspoon::Driver.fetch(Teaspoon.configuration.driver)
|
95
|
+
@driver = driver.new(Teaspoon.configuration.driver_options)
|
101
96
|
end
|
102
97
|
|
103
98
|
def base_url_for(suite)
|
@@ -117,13 +112,8 @@ module Teaspoon
|
|
117
112
|
"#{parts.join('&')}" if parts.present?
|
118
113
|
end
|
119
114
|
|
120
|
-
def log(str
|
121
|
-
STDOUT.print("#{str}\n")
|
122
|
-
end
|
123
|
-
|
124
|
-
def abort(message = nil)
|
125
|
-
log(message, true) if message
|
126
|
-
exit(1)
|
115
|
+
def log(str)
|
116
|
+
STDOUT.print("#{str}\n") unless Teaspoon.configuration.suppress_log
|
127
117
|
end
|
128
118
|
end
|
129
119
|
end
|
data/lib/teaspoon/coverage.rb
CHANGED
@@ -1,10 +1,18 @@
|
|
1
1
|
module Teaspoon
|
2
2
|
class Coverage
|
3
|
-
def
|
3
|
+
def self.configuration(name = Teaspoon.configuration.use_coverage)
|
4
|
+
name = normalize_config_name(name)
|
5
|
+
config = Teaspoon.configuration.coverage_configs[name]
|
6
|
+
|
7
|
+
raise Teaspoon::UnknownCoverage.new(name: name) unless config.present?
|
8
|
+
config[:instance] ||= Teaspoon::Configuration::Coverage.new(&config[:block])
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize(suite_name, data)
|
4
12
|
@suite_name = suite_name
|
5
13
|
@data = data
|
6
14
|
@executable = Teaspoon::Instrumentation.executable
|
7
|
-
@config =
|
15
|
+
@config = self.class.configuration
|
8
16
|
end
|
9
17
|
|
10
18
|
def generate_reports(&block)
|
@@ -31,10 +39,9 @@ module Teaspoon
|
|
31
39
|
|
32
40
|
private
|
33
41
|
|
34
|
-
def
|
35
|
-
|
36
|
-
|
37
|
-
config[:instance] ||= Teaspoon::Configuration::Coverage.new(&config[:block])
|
42
|
+
def self.normalize_config_name(name)
|
43
|
+
return "default" if name == true
|
44
|
+
name.to_s
|
38
45
|
end
|
39
46
|
|
40
47
|
def input_path(&block)
|
@@ -49,7 +56,7 @@ module Teaspoon
|
|
49
56
|
output_path = File.join(@config.output_path, @suite_name)
|
50
57
|
result = %x{#{@executable} report --include=#{input.shellescape} --dir #{output_path} #{format} 2>&1}
|
51
58
|
return result.gsub("Done", "").gsub("Using reporter [#{format}]", "").strip if $?.exitstatus == 0
|
52
|
-
raise Teaspoon::
|
59
|
+
raise Teaspoon::DependencyError.new("Unable to generate #{format} coverage report.")
|
53
60
|
end
|
54
61
|
|
55
62
|
def threshold_args
|
data/lib/teaspoon/deprecated.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
module Teaspoon
|
2
2
|
def self.setup(&block)
|
3
|
-
Teaspoon.dep(
|
3
|
+
Teaspoon.dep(
|
4
|
+
"Teaspoon.setup is deprecated, use Teaspoon.configure instead. The /initializer/teaspoon.rb file should be " +
|
5
|
+
"removed, and a new teaspoon_env.rb file should be created by running the install generator."
|
6
|
+
)
|
4
7
|
configure(&block)
|
5
8
|
end
|
6
9
|
|
@@ -20,7 +23,10 @@ module Teaspoon
|
|
20
23
|
end
|
21
24
|
|
22
25
|
def self.fixture_path=(*args)
|
23
|
-
Teaspoon.dep(
|
26
|
+
Teaspoon.dep(
|
27
|
+
"the teaspoon fixture_path directive has been changed to fixture_paths, which expects an array, please " +
|
28
|
+
"update your configuration."
|
29
|
+
)
|
24
30
|
self.fixture_paths = args
|
25
31
|
end
|
26
32
|
|
@@ -59,12 +65,24 @@ teaspoon coverage directive has changed and is now more flexible, define coverag
|
|
59
65
|
|
60
66
|
class Suite
|
61
67
|
def js_config=(*_args)
|
62
|
-
Teaspoon.dep(
|
68
|
+
Teaspoon.dep(
|
69
|
+
"the teaspoon suite js_config directive is no longer used, use the install generator to install the boot " +
|
70
|
+
"partial and customize it instead.", :js_config
|
71
|
+
)
|
63
72
|
end
|
64
73
|
|
65
74
|
def normalize_asset_path=(*_args)
|
66
|
-
Teaspoon.dep(
|
75
|
+
Teaspoon.dep(
|
76
|
+
"the teaspoon suite normalize_asset_path directive is no longer used, reopen Teaspoon::Suite and define a " +
|
77
|
+
"normalize_js_extension method instead.", :normalize_asset_path
|
78
|
+
)
|
67
79
|
end
|
80
|
+
|
81
|
+
def no_coverage(*)
|
82
|
+
Teaspoon.dep("suite.no_coverage has been removed in Teaspoon 1.0. Please use coverage.ignore instead. https://github.com/modeset/teaspoon/blob/master/CHANGELOG.md")
|
83
|
+
[]
|
84
|
+
end
|
85
|
+
alias_method :no_coverage=, :no_coverage
|
68
86
|
end
|
69
87
|
end
|
70
88
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "teaspoon/registry"
|
2
|
+
require "teaspoon/registry/has_default"
|
3
|
+
|
4
|
+
module Teaspoon
|
5
|
+
module Driver
|
6
|
+
extend Teaspoon::Registry
|
7
|
+
extend Teaspoon::Registry::HasDefault
|
8
|
+
|
9
|
+
not_found_in_registry Teaspoon::UnknownDriver
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
Teaspoon::Driver.register(:phantomjs, "Teaspoon::Driver::Phantomjs", "teaspoon/driver/phantomjs", default: true)
|
14
|
+
Teaspoon::Driver.register(:selenium, "Teaspoon::Driver::Selenium", "teaspoon/driver/selenium")
|
15
|
+
Teaspoon::Driver.register(:capybara_webkit, "Teaspoon::Driver::CapybaraWebkit", "teaspoon/driver/capybara_webkit")
|
@@ -1,14 +1,17 @@
|
|
1
|
+
# :nocov:
|
1
2
|
begin
|
2
3
|
require "capybara-webkit"
|
3
4
|
rescue LoadError
|
4
|
-
|
5
|
-
exit(1)
|
5
|
+
Teaspoon.abort("Could not find Capybara Webkit. Install the capybara-webkit gem.")
|
6
6
|
end
|
7
|
+
# :nocov:
|
8
|
+
|
9
|
+
require "teaspoon/driver/base"
|
7
10
|
|
8
11
|
module Teaspoon
|
9
|
-
module
|
10
|
-
class
|
11
|
-
def initialize(
|
12
|
+
module Driver
|
13
|
+
class CapybaraWebkit < Base
|
14
|
+
def initialize(_options = nil)
|
12
15
|
end
|
13
16
|
|
14
17
|
def run_specs(runner, url)
|
@@ -1,12 +1,16 @@
|
|
1
|
+
# :nocov:
|
1
2
|
begin
|
2
3
|
require "phantomjs"
|
3
4
|
rescue LoadError
|
4
5
|
# if we can't load phantomjs, assume the cli is installed and in the path
|
5
6
|
end
|
7
|
+
# :nocov:
|
8
|
+
|
9
|
+
require "teaspoon/driver/base"
|
6
10
|
|
7
11
|
module Teaspoon
|
8
|
-
module
|
9
|
-
class
|
12
|
+
module Driver
|
13
|
+
class Phantomjs < Base
|
10
14
|
include Teaspoon::Utility
|
11
15
|
|
12
16
|
def initialize(options = nil)
|
@@ -15,7 +19,7 @@ module Teaspoon
|
|
15
19
|
when Array then @options = options
|
16
20
|
when String then @options = options.split(" ")
|
17
21
|
when Hash then @options = options.map { |k, v| "--#{k}=#{v}" }
|
18
|
-
else raise Teaspoon::
|
22
|
+
else raise Teaspoon::DriverOptionsError.new(types: "string, array or hash")
|
19
23
|
end
|
20
24
|
end
|
21
25
|
|
@@ -49,7 +53,7 @@ module Teaspoon
|
|
49
53
|
@executable = which("phantomjs")
|
50
54
|
@executable = Phantomjs.path if @executable.blank? && defined?(::Phantomjs)
|
51
55
|
return @executable unless @executable.blank?
|
52
|
-
raise Teaspoon::
|
56
|
+
raise Teaspoon::MissingDependencyError.new("Unable to locate phantomjs. Install it or use the phantomjs gem.")
|
53
57
|
end
|
54
58
|
|
55
59
|
def script
|
File without changes
|
@@ -1,30 +1,32 @@
|
|
1
|
+
# :nocov:
|
1
2
|
begin
|
2
3
|
require "selenium-webdriver"
|
3
4
|
rescue LoadError
|
4
|
-
|
5
|
-
exit(1)
|
5
|
+
Teaspoon.abort("Could not find Selenium Webdriver. Install the selenium-webdriver gem.")
|
6
6
|
end
|
7
|
+
# :nocov:
|
8
|
+
|
9
|
+
require "teaspoon/driver/base"
|
7
10
|
|
8
11
|
module Teaspoon
|
9
|
-
module
|
10
|
-
class
|
12
|
+
module Driver
|
13
|
+
class Selenium < Base
|
11
14
|
def initialize(options = nil)
|
12
15
|
options ||= {}
|
13
16
|
case options
|
14
17
|
when Hash then @options = options
|
15
18
|
when String then @options = JSON.parse(options)
|
16
|
-
else raise Teaspoon::
|
19
|
+
else raise Teaspoon::DriverOptionsError.new(types: "hash or json string")
|
17
20
|
end
|
18
|
-
|
19
21
|
rescue JSON::ParserError
|
20
|
-
raise Teaspoon::
|
22
|
+
raise Teaspoon::DriverOptionsError.new(types: "hash or json string")
|
21
23
|
end
|
22
24
|
|
23
25
|
def run_specs(runner, url)
|
24
|
-
driver = Selenium::WebDriver.for(driver_options[:client_driver])
|
26
|
+
driver = ::Selenium::WebDriver.for(driver_options[:client_driver])
|
25
27
|
driver.navigate.to(url)
|
26
28
|
|
27
|
-
Selenium::WebDriver::Wait.new(driver_options).until do
|
29
|
+
::Selenium::WebDriver::Wait.new(driver_options).until do
|
28
30
|
done = driver.execute_script("return window.Teaspoon && window.Teaspoon.finished")
|
29
31
|
driver.execute_script("return window.Teaspoon && window.Teaspoon.getMessages() || []").each do |line|
|
30
32
|
runner.process("#{line}\n")
|
data/lib/teaspoon/engine.rb
CHANGED
@@ -6,34 +6,11 @@ module Teaspoon
|
|
6
6
|
class Engine < ::Rails::Engine
|
7
7
|
isolate_namespace Teaspoon
|
8
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
|
-
|
32
9
|
routes do
|
33
10
|
root to: "suite#index"
|
34
11
|
match "/fixtures/*filename", to: "suite#fixtures", via: :get, as: "fixture"
|
35
12
|
match "/:suite", to: "suite#show", via: :get, as: "suite", defaults: { suite: "default" }
|
36
|
-
match "/:suite/:hook", to: "suite#hook", via: :post,
|
13
|
+
match "/:suite/:hook", to: "suite#hook", via: :post, defaults: { suite: "default", hook: "default" }
|
37
14
|
end
|
38
15
|
|
39
16
|
initializer :assets, group: :all do |app|
|
@@ -61,10 +38,15 @@ module Teaspoon
|
|
61
38
|
Teaspoon.configuration.asset_paths.each do |path|
|
62
39
|
assets.paths << Teaspoon.configuration.root.join(path).to_s
|
63
40
|
end
|
41
|
+
|
42
|
+
# TODO: This breaks lazy loading of frameworks. Another way to avoid this?
|
43
|
+
Teaspoon::Framework.available.keys.each do |framework|
|
44
|
+
assets.paths += Teaspoon::Framework.fetch(framework).asset_paths
|
45
|
+
end
|
64
46
|
end
|
65
47
|
|
66
48
|
def self.add_precompiled_assets(assets)
|
67
|
-
assets.precompile +=
|
49
|
+
assets.precompile += Teaspoon.configuration.asset_manifest
|
68
50
|
end
|
69
51
|
|
70
52
|
def self.inject_instrumentation
|
@@ -80,5 +62,36 @@ module Teaspoon
|
|
80
62
|
|
81
63
|
app.routes.prepend { mount Teaspoon::Engine => mount_at, as: "teaspoon" }
|
82
64
|
end
|
65
|
+
|
66
|
+
module ExceptionHandling
|
67
|
+
def self.add_rails_handling
|
68
|
+
return unless using_phantomjs?
|
69
|
+
|
70
|
+
# debugging should be off to display errors in the suite_controller
|
71
|
+
# Rails.application.config.assets.debug = false
|
72
|
+
|
73
|
+
# we want rails to display exceptions
|
74
|
+
Rails.application.config.action_dispatch.show_exceptions = true
|
75
|
+
|
76
|
+
# override the render exception method in ActionDispatch to raise a javascript exception
|
77
|
+
render_exceptions_with_javascript
|
78
|
+
end
|
79
|
+
|
80
|
+
private
|
81
|
+
|
82
|
+
def self.using_phantomjs?
|
83
|
+
Teaspoon::Driver.equal?(Teaspoon.configuration.driver, :phantomjs)
|
84
|
+
end
|
85
|
+
|
86
|
+
def self.render_exceptions_with_javascript
|
87
|
+
ActionDispatch::DebugExceptions.class_eval do
|
88
|
+
def render_exception(_env, exception)
|
89
|
+
message = "#{exception.class.name}: #{exception.message}"
|
90
|
+
body = "<script>throw Error(#{[message, exception.backtrace].join("\n").inspect})</script>"
|
91
|
+
[200, { "Content-Type" => "text/html;", "Content-Length" => body.bytesize.to_s }, [body]]
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
83
96
|
end
|
84
97
|
end
|
data/lib/teaspoon/environment.rb
CHANGED
@@ -3,8 +3,8 @@ require "teaspoon/exceptions"
|
|
3
3
|
module Teaspoon
|
4
4
|
module Environment
|
5
5
|
def self.load(options = {})
|
6
|
-
|
7
|
-
|
6
|
+
load_rails
|
7
|
+
Teaspoon.abort("Rails environment not found.", 1) unless rails_loaded?
|
8
8
|
|
9
9
|
require "teaspoon"
|
10
10
|
require "teaspoon/server"
|
@@ -13,38 +13,47 @@ module Teaspoon
|
|
13
13
|
require "teaspoon/exporter"
|
14
14
|
|
15
15
|
Teaspoon.configuration.override_from_options(options)
|
16
|
-
Teaspoon::ExceptionHandling.add_rails_handling
|
16
|
+
Teaspoon::Engine::ExceptionHandling.add_rails_handling
|
17
17
|
end
|
18
18
|
|
19
19
|
def self.require_environment(override = nil)
|
20
|
+
require_env(find_env(override))
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.check_env!(override = nil)
|
24
|
+
find_env(override)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def self.find_env(override = nil)
|
20
30
|
override ||= ENV["TEASPOON_ENV"]
|
21
|
-
|
22
|
-
override = File.expand_path(override, Dir.pwd)
|
23
|
-
ENV["TEASPOON_ENV"] = override
|
24
|
-
return require_env(override)
|
25
|
-
end
|
31
|
+
env_files = override ? [override] : standard_environments
|
26
32
|
|
27
|
-
|
33
|
+
env_files.each do |filename|
|
28
34
|
file = File.expand_path(filename, Dir.pwd)
|
29
|
-
|
35
|
+
ENV["TEASPOON_ENV"] = file if override
|
36
|
+
return file if File.exists?(file)
|
30
37
|
end
|
31
38
|
|
32
|
-
raise Teaspoon::EnvironmentNotFound,
|
33
|
-
"Unable to load Teaspoon environment in {#{standard_environments.join(', ')}}"
|
39
|
+
raise Teaspoon::EnvironmentNotFound.new(searched: env_files.join(", "))
|
34
40
|
end
|
35
41
|
|
36
42
|
def self.standard_environments
|
37
43
|
["spec/teaspoon_env.rb", "test/teaspoon_env.rb", "teaspoon_env.rb"]
|
38
44
|
end
|
39
45
|
|
40
|
-
private
|
41
|
-
|
42
46
|
def self.require_env(file)
|
43
47
|
::Kernel.load(file)
|
44
48
|
end
|
45
49
|
|
46
50
|
def self.rails_loaded?
|
47
|
-
defined?(Rails)
|
51
|
+
!!defined?(Rails)
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.load_rails
|
55
|
+
rails_env = ENV["TEASPOON_RAILS_ENV"] || File.expand_path("config/environment", Dir.pwd)
|
56
|
+
require rails_env
|
48
57
|
end
|
49
58
|
end
|
50
59
|
end
|