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
@@ -1,113 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require "spec_helper"
|
4
|
-
require "rack/test"
|
5
|
-
|
6
|
-
describe Teaspoon::Instrumentation do
|
7
|
-
|
8
|
-
subject { Teaspoon::Instrumentation }
|
9
|
-
|
10
|
-
let(:asset) { double(source: source, pathname: "path/to/instrument.js") }
|
11
|
-
let(:source) { "function add(a, b) { return a + b } // ☃ " }
|
12
|
-
let(:response) { [200, { "Content-Type" => "application/javascript" }, asset] }
|
13
|
-
let(:env) { { "QUERY_STRING" => "instrument=true" } }
|
14
|
-
|
15
|
-
describe ".add_to" do
|
16
|
-
|
17
|
-
before do
|
18
|
-
allow(Teaspoon::Instrumentation).to receive(:executable).and_return("/path/to/istanbul")
|
19
|
-
end
|
20
|
-
|
21
|
-
before do
|
22
|
-
allow(Teaspoon::Instrumentation).to receive(:add?).and_return(true)
|
23
|
-
expect(asset).to receive(:clone).and_return(asset)
|
24
|
-
|
25
|
-
allow(File).to receive(:open)
|
26
|
-
allow_any_instance_of(subject).to receive(:instrument).and_return(source + " // instrumented")
|
27
|
-
|
28
|
-
path = nil
|
29
|
-
Dir.mktmpdir { |p| path = p }
|
30
|
-
allow(Dir).to receive(:mktmpdir).and_yield(path)
|
31
|
-
@output = File.join(path, "instrument.js")
|
32
|
-
end
|
33
|
-
|
34
|
-
it "writes the file to a tmp path" do
|
35
|
-
file = double("file")
|
36
|
-
expect(File).to receive(:open).with(@output, "w").and_yield(file)
|
37
|
-
expect(file).to receive(:write).with("function add(a, b) { return a + b } // ☃ ")
|
38
|
-
subject.add_to(response, env)
|
39
|
-
end
|
40
|
-
|
41
|
-
it "instruments the javascript file" do
|
42
|
-
expect_any_instance_of(subject).to receive(:instrument).with(@output).and_return("_instrumented_")
|
43
|
-
subject.add_to(response, env)
|
44
|
-
end
|
45
|
-
|
46
|
-
it "replaces the response array with the appropriate information" do
|
47
|
-
response = [666, { "Content-Type" => "application/javascript" }, asset]
|
48
|
-
expected = [666, { "Content-Type" => "application/javascript", "Content-Length" => "59" }, asset]
|
49
|
-
|
50
|
-
expect(subject.add_to(response, env)).to eq(expected)
|
51
|
-
end
|
52
|
-
|
53
|
-
it "raises an exception if istanbul fails" do
|
54
|
-
`(exit 1)`
|
55
|
-
allow(subject).to receive(:`)
|
56
|
-
allow_any_instance_of(subject).to receive(:instrument).and_call_original
|
57
|
-
expect { subject.add_to(response, env) }.to raise_error(
|
58
|
-
Teaspoon::DependencyFailure, "Could not generate instrumentation for instrument.js."
|
59
|
-
)
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|
63
|
-
|
64
|
-
describe ".add?" do
|
65
|
-
|
66
|
-
before do
|
67
|
-
allow(Teaspoon::Instrumentation).to receive(:executable).and_return("/path/to/istanbul")
|
68
|
-
end
|
69
|
-
|
70
|
-
it "returns true when everything is good" do
|
71
|
-
expect(subject.add?(response, "QUERY_STRING" => "instrument=true")).to be(true)
|
72
|
-
expect(subject.add?(response, "QUERY_STRING" => "instrument=1")).to be(true)
|
73
|
-
end
|
74
|
-
|
75
|
-
it "doesn't if the query param isn't set (or isn't something we care about)" do
|
76
|
-
expect(subject.add?(response, {})).to_not be(true)
|
77
|
-
expect(subject.add?(response, "QUERY_STRING" => "instrument=foo")).to_not be(true)
|
78
|
-
end
|
79
|
-
|
80
|
-
it "doesn't if response isn't 200" do
|
81
|
-
expect(subject.add?([404, { "Content-Type" => "application/javascript" }, asset], env)).to_not be(true)
|
82
|
-
end
|
83
|
-
|
84
|
-
it "doesn't when the content type isn't application/javascript" do
|
85
|
-
expect(subject.add?([200, { "Content-Type" => "foo/bar" }, asset], env)).to_not be(true)
|
86
|
-
end
|
87
|
-
|
88
|
-
it "doesn't if there's no executable" do
|
89
|
-
expect(subject).to receive(:executable).and_return(false)
|
90
|
-
expect(subject.add?(response, env)).to_not be(true)
|
91
|
-
end
|
92
|
-
|
93
|
-
it "doesn't if there's no asset" do
|
94
|
-
expect(subject.add?([404, { "Content-Type" => "application/javascript" }, []], env)).to_not be(true)
|
95
|
-
end
|
96
|
-
|
97
|
-
end
|
98
|
-
|
99
|
-
describe "integration" do
|
100
|
-
|
101
|
-
let(:asset) { Rails.application.assets.find_asset("instrumented1.coffee") }
|
102
|
-
|
103
|
-
it "instruments a file" do
|
104
|
-
pending("needs istanbul to be installed") unless Teaspoon::Instrumentation.executable
|
105
|
-
status, headers, asset = subject.add_to(response, "QUERY_STRING" => "instrument=true")
|
106
|
-
expect(status).to eq(200)
|
107
|
-
expect(headers).to include("Content-Type" => "application/javascript")
|
108
|
-
expect(asset.source).to match(/var __cov_.+ = \(Function\('return this'\)\)\(\);/)
|
109
|
-
end
|
110
|
-
|
111
|
-
end
|
112
|
-
|
113
|
-
end
|
@@ -1,98 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "teaspoon/result"
|
3
|
-
|
4
|
-
describe Teaspoon::Result do
|
5
|
-
|
6
|
-
subject { Teaspoon::Result.build_from_json(json) }
|
7
|
-
let(:suite_name) { "My Suite" }
|
8
|
-
let(:json) do
|
9
|
-
{
|
10
|
-
"type" => "spec",
|
11
|
-
"suite" => "_suite_name_",
|
12
|
-
"label" => "_spec_name_",
|
13
|
-
"status" => "failed",
|
14
|
-
"skipped" => false,
|
15
|
-
"link" => "?grep=_spec_description_",
|
16
|
-
"message" => "_message_",
|
17
|
-
"trace" => "_trace_",
|
18
|
-
"coverage" => "_coverage_",
|
19
|
-
}
|
20
|
-
end
|
21
|
-
|
22
|
-
describe ".build_from_json" do
|
23
|
-
|
24
|
-
describe "with a results object" do
|
25
|
-
|
26
|
-
let(:json) do
|
27
|
-
{
|
28
|
-
"elapsed" => 0.01,
|
29
|
-
"failures" => 10,
|
30
|
-
"pending" => 1,
|
31
|
-
"total" => 25
|
32
|
-
}
|
33
|
-
end
|
34
|
-
|
35
|
-
it "assigns from the JSON hash" do
|
36
|
-
expect(subject.elapsed).to eq(0.01)
|
37
|
-
expect(subject.total).to eq(25)
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
describe "with a spec" do
|
43
|
-
|
44
|
-
it "assigns from the JSON hash" do
|
45
|
-
expect(subject.type).to eq("spec")
|
46
|
-
expect(subject.suite).to eq("_suite_name_")
|
47
|
-
expect(subject.label).to eq("_spec_name_")
|
48
|
-
expect(subject.description).to eq("_suite_name_ _spec_name_")
|
49
|
-
expect(subject.status).to eq("failed")
|
50
|
-
expect(subject.skipped).to be_falsey
|
51
|
-
expect(subject.link).to eq("?grep=_spec_description_")
|
52
|
-
expect(subject.message).to eq("_message_")
|
53
|
-
expect(subject.trace).to eq("_trace_")
|
54
|
-
expect(subject.coverage).to eq("_coverage_")
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
60
|
-
|
61
|
-
describe "#failing?" do
|
62
|
-
|
63
|
-
it "returns a boolean based on status" do
|
64
|
-
subject.status = "foo"
|
65
|
-
expect(subject.failing?).to be_truthy
|
66
|
-
subject.status = "bar"
|
67
|
-
expect(subject.failing?).to be_truthy
|
68
|
-
subject.status = "passed"
|
69
|
-
expect(subject.failing?).to be_falsey
|
70
|
-
subject.status = "pending"
|
71
|
-
expect(subject.failing?).to be_falsey
|
72
|
-
end
|
73
|
-
|
74
|
-
end
|
75
|
-
|
76
|
-
describe "#passing?" do
|
77
|
-
|
78
|
-
it "returns a boolean based on status" do
|
79
|
-
subject.status = "passed"
|
80
|
-
expect(subject.passing?).to be_truthy
|
81
|
-
subject.status = "foo"
|
82
|
-
expect(subject.passing?).to be_falsey
|
83
|
-
end
|
84
|
-
|
85
|
-
end
|
86
|
-
|
87
|
-
describe "#pending?" do
|
88
|
-
|
89
|
-
it "returns a boolean based on status" do
|
90
|
-
subject.status = "pending"
|
91
|
-
expect(subject.pending?).to be_truthy
|
92
|
-
subject.status = "foo"
|
93
|
-
expect(subject.pending?).to be_falsey
|
94
|
-
end
|
95
|
-
|
96
|
-
end
|
97
|
-
|
98
|
-
end
|
@@ -1,116 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "teaspoon/runner"
|
3
|
-
require "teaspoon/exceptions"
|
4
|
-
require "teaspoon/coverage"
|
5
|
-
|
6
|
-
describe Teaspoon::Runner do
|
7
|
-
|
8
|
-
before do
|
9
|
-
allow(Teaspoon.configuration).to receive(:formatters).and_return([])
|
10
|
-
end
|
11
|
-
|
12
|
-
describe "#initialize" do
|
13
|
-
|
14
|
-
it "sets @suite_name and @failure_count" do
|
15
|
-
subject = Teaspoon::Runner.new(:foo)
|
16
|
-
expect(subject.instance_variable_get(:@suite_name)).to eq(:foo)
|
17
|
-
expect(subject.failure_count).to eq(0)
|
18
|
-
end
|
19
|
-
|
20
|
-
it "instantiates formatters based on configuration" do
|
21
|
-
allow(Teaspoon.configuration).to receive(:formatters).and_return(["dot", "xml"])
|
22
|
-
Teaspoon::Formatters::XmlFormatter = Class.new do
|
23
|
-
def initialize(_suite_name = :default, _output_file = nil) end
|
24
|
-
end
|
25
|
-
expect(subject.instance_variable_get(:@formatters)[0]).to be_a(Teaspoon::Formatters::DotFormatter)
|
26
|
-
expect(subject.instance_variable_get(:@formatters)[1]).to be_a(Teaspoon::Formatters::XmlFormatter)
|
27
|
-
end
|
28
|
-
|
29
|
-
it "raises a Teaspoon::UnknownFormatter exception when a formatter isn't found" do
|
30
|
-
allow(Teaspoon.configuration).to receive(:formatters).and_return(["bar"])
|
31
|
-
expect { Teaspoon::Runner.new(:foo) }.to raise_error Teaspoon::UnknownFormatter, "Unknown formatter: \"bar\""
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
describe "#process" do
|
37
|
-
|
38
|
-
let(:formatter) { double }
|
39
|
-
let(:coverage) { double(generate_reports: nil, check_thresholds: nil) }
|
40
|
-
|
41
|
-
before do
|
42
|
-
subject.instance_variable_set(:@formatters, [formatter])
|
43
|
-
end
|
44
|
-
|
45
|
-
it "notifies formatters when it understands the log" do
|
46
|
-
expect(formatter).to receive(:foo)
|
47
|
-
expect(formatter).to_not receive(:bar)
|
48
|
-
subject.process('{"_teaspoon":true,"type":"foo"}')
|
49
|
-
subject.process('{"_teaspoon":false,"type":"bar"}')
|
50
|
-
end
|
51
|
-
|
52
|
-
it "notifies formatters of console output when it doesn't understand the log" do
|
53
|
-
expect(formatter).to receive(:console).with("_line_")
|
54
|
-
expect(subject).to receive(:result_from_line).and_return(false)
|
55
|
-
subject.process("_line_")
|
56
|
-
end
|
57
|
-
|
58
|
-
it "handles bad json" do
|
59
|
-
expect(formatter).to receive(:console).with("{bad: true}")
|
60
|
-
subject.process("{bad: true}")
|
61
|
-
end
|
62
|
-
|
63
|
-
it "handles json when it's not intended for it" do
|
64
|
-
expect(formatter).to receive(:console).with('{"good": true}')
|
65
|
-
subject.process('{"good": true}')
|
66
|
-
end
|
67
|
-
|
68
|
-
it "keeps a count of errors" do
|
69
|
-
subject.process('{"_teaspoon":true,"type":"spec"}')
|
70
|
-
subject.process('{"_teaspoon":true,"type":"spec", "status": "passed"}')
|
71
|
-
subject.process('{"_teaspoon":true,"type":"spec", "status": "pending"}')
|
72
|
-
subject.process('{"_teaspoon":true,"type":"error"}')
|
73
|
-
subject.process('{"_teaspoon":true,"type":"results"}')
|
74
|
-
expect(subject.failure_count).to be(1)
|
75
|
-
end
|
76
|
-
|
77
|
-
describe "with an exception" do
|
78
|
-
|
79
|
-
it "notifies itself, and raises Teaspoon::RunnerException" do
|
80
|
-
expect(subject).to receive(:on_exception).and_call_original
|
81
|
-
expect { subject.process('{"_teaspoon":true,"type":"exception","message":"_message_"}') }.to raise_error(
|
82
|
-
Teaspoon::RunnerException,
|
83
|
-
"_message_"
|
84
|
-
)
|
85
|
-
end
|
86
|
-
|
87
|
-
end
|
88
|
-
|
89
|
-
describe "with a result" do
|
90
|
-
|
91
|
-
before do
|
92
|
-
allow(Teaspoon::Coverage).to receive(:new).and_return(coverage)
|
93
|
-
end
|
94
|
-
|
95
|
-
it "notifies itself" do
|
96
|
-
expect(subject).to receive(:on_result)
|
97
|
-
subject.process('{"_teaspoon":true,"type":"result"}')
|
98
|
-
end
|
99
|
-
|
100
|
-
it "resolves coverage" do
|
101
|
-
expect(Teaspoon.configuration).to receive(:use_coverage).twice.and_return("_config_")
|
102
|
-
expect(Teaspoon::Coverage).to receive(:new).with(:default, "_config_", "_coverage_").and_return(coverage)
|
103
|
-
expect(coverage).to receive(:generate_reports).and_yield("_generated_reports_")
|
104
|
-
expect(coverage).to receive(:check_thresholds).and_yield("_threshold_failures_")
|
105
|
-
expect(subject).to receive(:notify_formatters).once.with("coverage", "_generated_reports_")
|
106
|
-
expect(subject).to receive(:notify_formatters).once.with("threshold_failure", "_threshold_failures_")
|
107
|
-
expect(subject).to receive(:notify_formatters).exactly(2).times.and_call_original
|
108
|
-
subject.process('{"_teaspoon":true,"type":"result","coverage":"_coverage_"}')
|
109
|
-
expect(subject.failure_count).to eq(1)
|
110
|
-
end
|
111
|
-
|
112
|
-
end
|
113
|
-
|
114
|
-
end
|
115
|
-
|
116
|
-
end
|
@@ -1,105 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "teaspoon/server"
|
3
|
-
require "net/http"
|
4
|
-
|
5
|
-
describe Teaspoon::Server do
|
6
|
-
|
7
|
-
subject { Teaspoon::Server.new }
|
8
|
-
|
9
|
-
describe "#start" do
|
10
|
-
|
11
|
-
let(:server) { double(start: nil) }
|
12
|
-
|
13
|
-
before do
|
14
|
-
allow(Thread).to receive(:new) { |&b| @block = b; "_thread_" }
|
15
|
-
allow(subject).to receive(:wait_until_started).and_return(nil)
|
16
|
-
end
|
17
|
-
|
18
|
-
it "spawns a thread" do
|
19
|
-
expect(Thread).to receive(:new)
|
20
|
-
subject.start
|
21
|
-
end
|
22
|
-
|
23
|
-
it "starts a rack server" do
|
24
|
-
expect(Rack::Server).to receive(:new).and_return(server)
|
25
|
-
expect(server).to receive(:start)
|
26
|
-
|
27
|
-
subject.start
|
28
|
-
@block.call
|
29
|
-
end
|
30
|
-
|
31
|
-
it "waits until the server is started" do
|
32
|
-
expect(Thread).to receive(:new)
|
33
|
-
expect(subject).to receive(:wait_until_started).with("_thread_")
|
34
|
-
subject.start
|
35
|
-
end
|
36
|
-
|
37
|
-
it "rescues errors" do
|
38
|
-
expect(Thread).to receive(:new).and_raise("OMG!")
|
39
|
-
expect { subject.start }.to raise_error("Cannot start server: OMG!")
|
40
|
-
end
|
41
|
-
|
42
|
-
it "creates a Rack::Server with the correct setting" do
|
43
|
-
expected_opts = {
|
44
|
-
app: Rails.application,
|
45
|
-
Port: subject.port,
|
46
|
-
environment: "test",
|
47
|
-
AccessLog: [],
|
48
|
-
Logger: Rails.logger,
|
49
|
-
server: Teaspoon.configuration.server
|
50
|
-
}
|
51
|
-
expect(Rack::Server).to receive(:new).with(expected_opts).and_return(server)
|
52
|
-
|
53
|
-
subject.start
|
54
|
-
@block.call
|
55
|
-
end
|
56
|
-
|
57
|
-
it "raises a ServerException if the timeout fails" do
|
58
|
-
expect(subject).to receive(:wait_until_started).and_call_original
|
59
|
-
expect(Timeout).to receive(:timeout).with(Teaspoon.configuration.server_timeout.to_i).and_raise(Timeout::Error)
|
60
|
-
expect { subject.start }.to raise_error(
|
61
|
-
Teaspoon::ServerException,
|
62
|
-
"Server failed to start. You may need to increase the timeout configuration."
|
63
|
-
)
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|
67
|
-
|
68
|
-
describe "#responsive?" do
|
69
|
-
|
70
|
-
let(:socket) { double(close: nil) }
|
71
|
-
|
72
|
-
it "checks a local port to see if a server is running" do
|
73
|
-
subject.port = 31337
|
74
|
-
expect(TCPSocket).to receive(:new).with("127.0.0.1", 31337).and_return(socket)
|
75
|
-
expect(socket).to receive(:close)
|
76
|
-
subject.responsive?
|
77
|
-
end
|
78
|
-
|
79
|
-
end
|
80
|
-
|
81
|
-
describe "#url" do
|
82
|
-
|
83
|
-
it "returns a url for the server that includes the port" do
|
84
|
-
subject.port = 31337
|
85
|
-
expect(subject.url).to eq("http://127.0.0.1:31337")
|
86
|
-
end
|
87
|
-
|
88
|
-
end
|
89
|
-
|
90
|
-
describe "integration" do
|
91
|
-
|
92
|
-
before do
|
93
|
-
allow(Teaspoon.configuration).to receive(:suite_configs).and_return("foo" => { block: proc {} })
|
94
|
-
allow(Teaspoon.configuration).to receive(:suppress_log).and_return(true)
|
95
|
-
end
|
96
|
-
|
97
|
-
it "really starts a server" do
|
98
|
-
subject.start
|
99
|
-
response = Net::HTTP.get_response(URI.parse("#{subject.url}/teaspoon/foo"))
|
100
|
-
expect(response.code).to eq("200")
|
101
|
-
end
|
102
|
-
|
103
|
-
end
|
104
|
-
|
105
|
-
end
|
data/spec/teaspoon/suite_spec.rb
DELETED
@@ -1,138 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Teaspoon::Suite do
|
4
|
-
|
5
|
-
before do
|
6
|
-
allow(Teaspoon.configuration).to receive(:suite_configs).and_return("default" => { block: proc {} })
|
7
|
-
end
|
8
|
-
|
9
|
-
describe ".all" do
|
10
|
-
|
11
|
-
before do
|
12
|
-
Teaspoon::Suite.instance_variable_set(:@all, nil)
|
13
|
-
suites = { "default" => { block: proc {} }, "foo" => { block: proc {} } }
|
14
|
-
allow(Teaspoon.configuration).to receive(:suite_configs).and_return(suites)
|
15
|
-
end
|
16
|
-
|
17
|
-
it "returns all the suites" do
|
18
|
-
result = Teaspoon::Suite.all
|
19
|
-
expect(result.first).to be_a(Teaspoon::Suite)
|
20
|
-
expect(result.length).to be(2)
|
21
|
-
expect(result.first.name).to eq("default")
|
22
|
-
expect(result.last.name).to eq("foo")
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
describe ".resolve_spec_for" do
|
28
|
-
|
29
|
-
it "return a hash with the suite name and path" do
|
30
|
-
result = Teaspoon::Suite.resolve_spec_for("fixture_spec")
|
31
|
-
expect(result[:suite]).to eq("default")
|
32
|
-
expect(result[:path].first).to include("base/fixture_spec.")
|
33
|
-
end
|
34
|
-
|
35
|
-
it "returns a hash with the suite name and an array of paths if a directory is given" do
|
36
|
-
result = Teaspoon::Suite.resolve_spec_for("base")
|
37
|
-
expect(result[:suite]).to eq("default")
|
38
|
-
dirs = ["base/fixture_spec.", "base/runner_spec.", "base/teaspoon_spec"]
|
39
|
-
expect(dirs.all? { |path| result[:path].grep(/#{path}/)[0] }).to be_truthy
|
40
|
-
end
|
41
|
-
|
42
|
-
it "returns false if the spec wasn't found" do
|
43
|
-
expect(Teaspoon::Suite.resolve_spec_for("foo")).to be_falsey
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
|
-
describe "#initialize" do
|
49
|
-
|
50
|
-
it "uses default suite configuration" do
|
51
|
-
expect(subject.name).to eq("default")
|
52
|
-
expect(subject.config.helper).to eq("spec_helper")
|
53
|
-
end
|
54
|
-
|
55
|
-
it "accepts a suite in the options" do
|
56
|
-
suite = { "test" => { block: proc { |s| s.helper = "helper_file" } } }
|
57
|
-
expect(Teaspoon.configuration).to receive(:suite_configs).and_return(suite)
|
58
|
-
subject = Teaspoon::Suite.new(suite: :test)
|
59
|
-
expect(subject.name).to eql("test")
|
60
|
-
expect(subject.config.helper).to eq("helper_file")
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|
64
|
-
|
65
|
-
describe "#spec_files" do
|
66
|
-
|
67
|
-
it "returns an array of hashes with the filename and the asset name" do
|
68
|
-
file = Teaspoon::Engine.root.join("spec/javascripts/teaspoon/base/reporters/console_spec.js").to_s
|
69
|
-
expect(subject).to receive(:glob).and_return([file])
|
70
|
-
expect(subject.spec_files[0]).to eql(path: file, name: "teaspoon/base/reporters/console_spec.js")
|
71
|
-
end
|
72
|
-
|
73
|
-
it "raises an exception if the file isn't servable (in an asset path)" do
|
74
|
-
expect(subject).to receive(:glob).and_return(["/foo"])
|
75
|
-
expect { subject.spec_files[0] }.to raise_error Teaspoon::AssetNotServable
|
76
|
-
end
|
77
|
-
|
78
|
-
end
|
79
|
-
|
80
|
-
describe "#spec_assets" do
|
81
|
-
|
82
|
-
it "returns an array of assets" do
|
83
|
-
result = subject.spec_assets
|
84
|
-
expect(result).to include("spec_helper.js?body=1")
|
85
|
-
expect(result).to include("teaspoon/base/reporters/console_spec.js?body=1")
|
86
|
-
end
|
87
|
-
|
88
|
-
it "returns just a file if one was requested" do
|
89
|
-
subject.instance_variable_set(:@options, file: "spec/javascripts/foo.js")
|
90
|
-
result = subject.spec_assets(false)
|
91
|
-
expect(result).to eql(["foo.js"])
|
92
|
-
end
|
93
|
-
|
94
|
-
it "returns the asset tree (all dependencies resolved) if we want coverage" do
|
95
|
-
allow(subject).to receive(:no_coverage).and_return([%r{support/}, "spec_helper.coffee"])
|
96
|
-
subject.instance_variable_set(:@options, coverage: true)
|
97
|
-
result = subject.spec_assets(true)
|
98
|
-
expect(result).to include("support/json2.js?body=1")
|
99
|
-
expect(result).to include("spec_helper.js?body=1")
|
100
|
-
expect(result).to include("drivers/phantomjs/runner.js?body=1&instrument=1")
|
101
|
-
end
|
102
|
-
|
103
|
-
it "returns only the top level assets in the asset tree if config/expand_assets is set to false" do
|
104
|
-
allow(subject.config).to receive(:expand_assets).and_return(false)
|
105
|
-
result = subject.spec_assets(true)
|
106
|
-
expect(result.any? { |file| file =~ /body=1/ }).to eq(false)
|
107
|
-
end
|
108
|
-
|
109
|
-
end
|
110
|
-
|
111
|
-
describe "#include_spec?" do
|
112
|
-
|
113
|
-
it "returns true if the spec was found in the suite" do
|
114
|
-
files = subject.send(:glob)
|
115
|
-
expect(subject.include_spec?(files.first)).to eq(true)
|
116
|
-
end
|
117
|
-
|
118
|
-
end
|
119
|
-
|
120
|
-
describe "#include_spec_for?" do
|
121
|
-
|
122
|
-
it "returns the spec if an exact match was found" do
|
123
|
-
files = subject.send(:glob)
|
124
|
-
expect(subject.include_spec_for?(files.first)).to eq(files.first)
|
125
|
-
end
|
126
|
-
|
127
|
-
it "returns a list of specs when the file name looks like it could be a match" do
|
128
|
-
files = subject.include_spec_for?("fixture_spec")
|
129
|
-
expect(files.any? { |file| file.include?("fixture_spec.coffee") }).to be_truthy
|
130
|
-
end
|
131
|
-
|
132
|
-
it "returns false if a matching spec isn't found" do
|
133
|
-
expect(subject.include_spec_for?("_not_a_match_")).to eq(false)
|
134
|
-
end
|
135
|
-
|
136
|
-
end
|
137
|
-
|
138
|
-
end
|