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
|
@@ -4,29 +4,33 @@ require "teaspoon/result"
|
|
|
4
4
|
describe Teaspoon::Result do
|
|
5
5
|
|
|
6
6
|
subject { Teaspoon::Result.build_from_json(json) }
|
|
7
|
-
let(:suite_name) {
|
|
8
|
-
let(:json)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
|
19
21
|
|
|
20
22
|
describe ".build_from_json" do
|
|
21
23
|
|
|
22
24
|
describe "with a results object" do
|
|
23
25
|
|
|
24
|
-
let(:json)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
let(:json) do
|
|
27
|
+
{
|
|
28
|
+
"elapsed" => 0.01,
|
|
29
|
+
"failures" => 10,
|
|
30
|
+
"pending" => 1,
|
|
31
|
+
"total" => 25
|
|
32
|
+
}
|
|
33
|
+
end
|
|
30
34
|
|
|
31
35
|
it "assigns from the JSON hash" do
|
|
32
36
|
expect(subject.elapsed).to eq(0.01)
|
|
@@ -38,16 +42,16 @@ describe Teaspoon::Result do
|
|
|
38
42
|
describe "with a spec" do
|
|
39
43
|
|
|
40
44
|
it "assigns from the JSON hash" do
|
|
41
|
-
expect(subject.type).to eq(
|
|
42
|
-
expect(subject.suite).to eq(
|
|
43
|
-
expect(subject.label).to eq(
|
|
44
|
-
expect(subject.description).to eq(
|
|
45
|
-
expect(subject.status).to eq(
|
|
46
|
-
expect(subject.skipped).to
|
|
47
|
-
expect(subject.link).to eq(
|
|
48
|
-
expect(subject.message).to eq(
|
|
49
|
-
expect(subject.trace).to eq(
|
|
50
|
-
expect(subject.coverage).to eq(
|
|
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_")
|
|
51
55
|
end
|
|
52
56
|
|
|
53
57
|
end
|
|
@@ -58,13 +62,13 @@ describe Teaspoon::Result do
|
|
|
58
62
|
|
|
59
63
|
it "returns a boolean based on status" do
|
|
60
64
|
subject.status = "foo"
|
|
61
|
-
expect(subject.failing?).to
|
|
65
|
+
expect(subject.failing?).to be_truthy
|
|
62
66
|
subject.status = "bar"
|
|
63
|
-
expect(subject.failing?).to
|
|
67
|
+
expect(subject.failing?).to be_truthy
|
|
64
68
|
subject.status = "passed"
|
|
65
|
-
expect(subject.failing?).to
|
|
69
|
+
expect(subject.failing?).to be_falsey
|
|
66
70
|
subject.status = "pending"
|
|
67
|
-
expect(subject.failing?).to
|
|
71
|
+
expect(subject.failing?).to be_falsey
|
|
68
72
|
end
|
|
69
73
|
|
|
70
74
|
end
|
|
@@ -73,9 +77,9 @@ describe Teaspoon::Result do
|
|
|
73
77
|
|
|
74
78
|
it "returns a boolean based on status" do
|
|
75
79
|
subject.status = "passed"
|
|
76
|
-
expect(subject.passing?).to
|
|
80
|
+
expect(subject.passing?).to be_truthy
|
|
77
81
|
subject.status = "foo"
|
|
78
|
-
expect(subject.passing?).to
|
|
82
|
+
expect(subject.passing?).to be_falsey
|
|
79
83
|
end
|
|
80
84
|
|
|
81
85
|
end
|
|
@@ -84,9 +88,9 @@ describe Teaspoon::Result do
|
|
|
84
88
|
|
|
85
89
|
it "returns a boolean based on status" do
|
|
86
90
|
subject.status = "pending"
|
|
87
|
-
expect(subject.pending?).to
|
|
91
|
+
expect(subject.pending?).to be_truthy
|
|
88
92
|
subject.status = "foo"
|
|
89
|
-
expect(subject.pending?).to
|
|
93
|
+
expect(subject.pending?).to be_falsey
|
|
90
94
|
end
|
|
91
95
|
|
|
92
96
|
end
|
|
@@ -6,7 +6,7 @@ require "teaspoon/coverage"
|
|
|
6
6
|
describe Teaspoon::Runner do
|
|
7
7
|
|
|
8
8
|
before do
|
|
9
|
-
Teaspoon.configuration.
|
|
9
|
+
allow(Teaspoon.configuration).to receive(:formatters).and_return([])
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
describe "#initialize" do
|
|
@@ -18,7 +18,7 @@ describe Teaspoon::Runner do
|
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
it "instantiates formatters based on configuration" do
|
|
21
|
-
Teaspoon.configuration.
|
|
21
|
+
allow(Teaspoon.configuration).to receive(:formatters).and_return(["dot", "xml"])
|
|
22
22
|
Teaspoon::Formatters::XmlFormatter = Class.new do
|
|
23
23
|
def initialize(_suite_name = :default, _output_file = nil) end
|
|
24
24
|
end
|
|
@@ -27,7 +27,7 @@ describe Teaspoon::Runner do
|
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
it "raises a Teaspoon::UnknownFormatter exception when a formatter isn't found" do
|
|
30
|
-
Teaspoon.configuration.
|
|
30
|
+
allow(Teaspoon.configuration).to receive(:formatters).and_return(["bar"])
|
|
31
31
|
expect { Teaspoon::Runner.new(:foo) }.to raise_error Teaspoon::UnknownFormatter, "Unknown formatter: \"bar\""
|
|
32
32
|
end
|
|
33
33
|
|
|
@@ -43,25 +43,25 @@ describe Teaspoon::Runner do
|
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
it "notifies formatters when it understands the log" do
|
|
46
|
-
formatter.
|
|
47
|
-
formatter.
|
|
46
|
+
expect(formatter).to receive(:foo)
|
|
47
|
+
expect(formatter).to_not receive(:bar)
|
|
48
48
|
subject.process('{"_teaspoon":true,"type":"foo"}')
|
|
49
49
|
subject.process('{"_teaspoon":false,"type":"bar"}')
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
it "notifies formatters of console output when it doesn't understand the log" do
|
|
53
|
-
formatter.
|
|
54
|
-
subject.
|
|
53
|
+
expect(formatter).to receive(:console).with("_line_")
|
|
54
|
+
expect(subject).to receive(:result_from_line).and_return(false)
|
|
55
55
|
subject.process("_line_")
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
it "handles bad json" do
|
|
59
|
-
formatter.
|
|
59
|
+
expect(formatter).to receive(:console).with("{bad: true}")
|
|
60
60
|
subject.process("{bad: true}")
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
it "handles json when it's not intended for it" do
|
|
64
|
-
formatter.
|
|
64
|
+
expect(formatter).to receive(:console).with('{"good": true}')
|
|
65
65
|
subject.process('{"good": true}')
|
|
66
66
|
end
|
|
67
67
|
|
|
@@ -77,8 +77,11 @@ describe Teaspoon::Runner do
|
|
|
77
77
|
describe "with an exception" do
|
|
78
78
|
|
|
79
79
|
it "notifies itself, and raises Teaspoon::RunnerException" do
|
|
80
|
-
subject.
|
|
81
|
-
expect { subject.process('{"_teaspoon":true,"type":"exception","message":"_message_"}') }.to raise_error
|
|
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
|
+
)
|
|
82
85
|
end
|
|
83
86
|
|
|
84
87
|
end
|
|
@@ -86,22 +89,22 @@ describe Teaspoon::Runner do
|
|
|
86
89
|
describe "with a result" do
|
|
87
90
|
|
|
88
91
|
before do
|
|
89
|
-
Teaspoon::Coverage.
|
|
92
|
+
allow(Teaspoon::Coverage).to receive(:new).and_return(coverage)
|
|
90
93
|
end
|
|
91
94
|
|
|
92
95
|
it "notifies itself" do
|
|
93
|
-
subject.
|
|
96
|
+
expect(subject).to receive(:on_result)
|
|
94
97
|
subject.process('{"_teaspoon":true,"type":"result"}')
|
|
95
98
|
end
|
|
96
99
|
|
|
97
100
|
it "resolves coverage" do
|
|
98
|
-
Teaspoon.configuration.
|
|
99
|
-
Teaspoon::Coverage.
|
|
100
|
-
coverage.
|
|
101
|
-
coverage.
|
|
102
|
-
subject.
|
|
103
|
-
subject.
|
|
104
|
-
subject.
|
|
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
|
|
105
108
|
subject.process('{"_teaspoon":true,"type":"result","coverage":"_coverage_"}')
|
|
106
109
|
expect(subject.failure_count).to eq(1)
|
|
107
110
|
end
|
|
@@ -11,31 +11,31 @@ describe Teaspoon::Server do
|
|
|
11
11
|
let(:server) { double(start: nil) }
|
|
12
12
|
|
|
13
13
|
before do
|
|
14
|
-
Thread.
|
|
15
|
-
subject.
|
|
14
|
+
allow(Thread).to receive(:new) { |&b| @block = b; "_thread_" }
|
|
15
|
+
allow(subject).to receive(:wait_until_started).and_return(nil)
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
it "spawns a thread" do
|
|
19
|
-
Thread.
|
|
19
|
+
expect(Thread).to receive(:new)
|
|
20
20
|
subject.start
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
it "starts a rack server" do
|
|
24
|
-
Rack::Server.
|
|
25
|
-
server.
|
|
24
|
+
expect(Rack::Server).to receive(:new).and_return(server)
|
|
25
|
+
expect(server).to receive(:start)
|
|
26
26
|
|
|
27
27
|
subject.start
|
|
28
28
|
@block.call
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
it "waits until the server is started" do
|
|
32
|
-
Thread.
|
|
33
|
-
subject.
|
|
32
|
+
expect(Thread).to receive(:new)
|
|
33
|
+
expect(subject).to receive(:wait_until_started).with("_thread_")
|
|
34
34
|
subject.start
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
it "rescues errors" do
|
|
38
|
-
Thread.
|
|
38
|
+
expect(Thread).to receive(:new).and_raise("OMG!")
|
|
39
39
|
expect { subject.start }.to raise_error("Cannot start server: OMG!")
|
|
40
40
|
end
|
|
41
41
|
|
|
@@ -48,16 +48,19 @@ describe Teaspoon::Server do
|
|
|
48
48
|
Logger: Rails.logger,
|
|
49
49
|
server: Teaspoon.configuration.server
|
|
50
50
|
}
|
|
51
|
-
Rack::Server.
|
|
51
|
+
expect(Rack::Server).to receive(:new).with(expected_opts).and_return(server)
|
|
52
52
|
|
|
53
53
|
subject.start
|
|
54
54
|
@block.call
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
it "raises a ServerException if the timeout fails" do
|
|
58
|
-
subject.
|
|
59
|
-
Timeout.
|
|
60
|
-
expect{ subject.start }.to raise_error
|
|
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
|
+
)
|
|
61
64
|
end
|
|
62
65
|
|
|
63
66
|
end
|
|
@@ -68,8 +71,8 @@ describe Teaspoon::Server do
|
|
|
68
71
|
|
|
69
72
|
it "checks a local port to see if a server is running" do
|
|
70
73
|
subject.port = 31337
|
|
71
|
-
TCPSocket.
|
|
72
|
-
socket.
|
|
74
|
+
expect(TCPSocket).to receive(:new).with("127.0.0.1", 31337).and_return(socket)
|
|
75
|
+
expect(socket).to receive(:close)
|
|
73
76
|
subject.responsive?
|
|
74
77
|
end
|
|
75
78
|
|
|
@@ -87,8 +90,8 @@ describe Teaspoon::Server do
|
|
|
87
90
|
describe "integration" do
|
|
88
91
|
|
|
89
92
|
before do
|
|
90
|
-
Teaspoon.configuration.
|
|
91
|
-
Teaspoon.configuration.
|
|
93
|
+
allow(Teaspoon.configuration).to receive(:suite_configs).and_return("foo" => { block: proc {} })
|
|
94
|
+
allow(Teaspoon.configuration).to receive(:suppress_log).and_return(true)
|
|
92
95
|
end
|
|
93
96
|
|
|
94
97
|
it "really starts a server" do
|
data/spec/teaspoon/suite_spec.rb
CHANGED
|
@@ -3,14 +3,15 @@ require "spec_helper"
|
|
|
3
3
|
describe Teaspoon::Suite do
|
|
4
4
|
|
|
5
5
|
before do
|
|
6
|
-
Teaspoon.configuration.
|
|
6
|
+
allow(Teaspoon.configuration).to receive(:suite_configs).and_return("default" => { block: proc {} })
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
describe ".all" do
|
|
10
10
|
|
|
11
11
|
before do
|
|
12
12
|
Teaspoon::Suite.instance_variable_set(:@all, nil)
|
|
13
|
-
|
|
13
|
+
suites = { "default" => { block: proc {} }, "foo" => { block: proc {} } }
|
|
14
|
+
allow(Teaspoon.configuration).to receive(:suite_configs).and_return(suites)
|
|
14
15
|
end
|
|
15
16
|
|
|
16
17
|
it "returns all the suites" do
|
|
@@ -35,7 +36,11 @@ describe Teaspoon::Suite do
|
|
|
35
36
|
result = Teaspoon::Suite.resolve_spec_for("base")
|
|
36
37
|
expect(result[:suite]).to eq("default")
|
|
37
38
|
dirs = ["base/fixture_spec.", "base/runner_spec.", "base/teaspoon_spec"]
|
|
38
|
-
expect(dirs.all? { |path| result[:path].grep(/#{path}/)[0] }).to
|
|
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
|
|
39
44
|
end
|
|
40
45
|
|
|
41
46
|
end
|
|
@@ -48,7 +53,8 @@ describe Teaspoon::Suite do
|
|
|
48
53
|
end
|
|
49
54
|
|
|
50
55
|
it "accepts a suite in the options" do
|
|
51
|
-
|
|
56
|
+
suite = { "test" => { block: proc { |s| s.helper = "helper_file" } } }
|
|
57
|
+
expect(Teaspoon.configuration).to receive(:suite_configs).and_return(suite)
|
|
52
58
|
subject = Teaspoon::Suite.new(suite: :test)
|
|
53
59
|
expect(subject.name).to eql("test")
|
|
54
60
|
expect(subject.config.helper).to eq("helper_file")
|
|
@@ -60,12 +66,12 @@ describe Teaspoon::Suite do
|
|
|
60
66
|
|
|
61
67
|
it "returns an array of hashes with the filename and the asset name" do
|
|
62
68
|
file = Teaspoon::Engine.root.join("spec/javascripts/teaspoon/base/reporters/console_spec.js").to_s
|
|
63
|
-
subject.
|
|
69
|
+
expect(subject).to receive(:glob).and_return([file])
|
|
64
70
|
expect(subject.spec_files[0]).to eql(path: file, name: "teaspoon/base/reporters/console_spec.js")
|
|
65
71
|
end
|
|
66
72
|
|
|
67
73
|
it "raises an exception if the file isn't servable (in an asset path)" do
|
|
68
|
-
subject.
|
|
74
|
+
expect(subject).to receive(:glob).and_return(["/foo"])
|
|
69
75
|
expect { subject.spec_files[0] }.to raise_error Teaspoon::AssetNotServable
|
|
70
76
|
end
|
|
71
77
|
|
|
@@ -79,13 +85,14 @@ describe Teaspoon::Suite do
|
|
|
79
85
|
expect(result).to include("teaspoon/base/reporters/console_spec.js?body=1")
|
|
80
86
|
end
|
|
81
87
|
|
|
82
|
-
it "returns just a file if one was
|
|
88
|
+
it "returns just a file if one was requested" do
|
|
83
89
|
subject.instance_variable_set(:@options, file: "spec/javascripts/foo.js")
|
|
84
90
|
result = subject.spec_assets(false)
|
|
85
91
|
expect(result).to eql(["foo.js"])
|
|
86
92
|
end
|
|
87
93
|
|
|
88
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"])
|
|
89
96
|
subject.instance_variable_set(:@options, coverage: true)
|
|
90
97
|
result = subject.spec_assets(true)
|
|
91
98
|
expect(result).to include("support/json2.js?body=1")
|
|
@@ -93,6 +100,12 @@ describe Teaspoon::Suite do
|
|
|
93
100
|
expect(result).to include("drivers/phantomjs/runner.js?body=1&instrument=1")
|
|
94
101
|
end
|
|
95
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
|
+
|
|
96
109
|
end
|
|
97
110
|
|
|
98
111
|
describe "#include_spec?" do
|
|
@@ -112,11 +125,12 @@ describe Teaspoon::Suite do
|
|
|
112
125
|
end
|
|
113
126
|
|
|
114
127
|
it "returns a list of specs when the file name looks like it could be a match" do
|
|
115
|
-
|
|
128
|
+
files = subject.include_spec_for?("fixture_spec")
|
|
129
|
+
expect(files.any? { |file| file.include?("fixture_spec.coffee") }).to be_truthy
|
|
116
130
|
end
|
|
117
131
|
|
|
118
132
|
it "returns false if a matching spec isn't found" do
|
|
119
|
-
expect(subject.include_spec_for?(
|
|
133
|
+
expect(subject.include_spec_for?("_not_a_match_")).to eq(false)
|
|
120
134
|
end
|
|
121
135
|
|
|
122
136
|
end
|
data/spec/teaspoon_env.rb
CHANGED
|
@@ -6,10 +6,11 @@ end
|
|
|
6
6
|
|
|
7
7
|
Teaspoon.configure do |config|
|
|
8
8
|
config.root = Teaspoon::Engine.root
|
|
9
|
-
config.asset_paths << Teaspoon::Engine.root.join(
|
|
9
|
+
config.asset_paths << Teaspoon::Engine.root.join("lib/teaspoon")
|
|
10
10
|
|
|
11
11
|
config.suite do |suite|
|
|
12
|
-
|
|
12
|
+
roots = "spec/javascripts,spec/dummy/app/assets/javascripts/specs"
|
|
13
|
+
suite.matcher = "{#{roots}}/**/*_spec.{js,js.coffee,coffee,js.coffee.erb}"
|
|
13
14
|
suite.javascripts = ["jasmine/1.3.1", "teaspoon/jasmine"]
|
|
14
15
|
end
|
|
15
16
|
|
|
@@ -31,14 +32,8 @@ Teaspoon.configure do |config|
|
|
|
31
32
|
suite.helper = "qunit_helper"
|
|
32
33
|
end
|
|
33
34
|
|
|
34
|
-
config.suite :
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
#config.suite :integration do |suite|
|
|
41
|
-
# suite.matcher = "spec/dummy/app/assets/javascripts/integration/*_spec.{js,js.coffee,coffee}"
|
|
42
|
-
# suite.helper = nil
|
|
43
|
-
#end
|
|
35
|
+
# config.suite :integration do |suite|
|
|
36
|
+
# suite.matcher = "spec/dummy/app/assets/javascripts/integration/*_spec.{js,js.coffee,coffee}"
|
|
37
|
+
# suite.helper = nil
|
|
38
|
+
# end
|
|
44
39
|
end
|
|
@@ -3,6 +3,8 @@ module "QUnit Teaspoon.Spec",
|
|
|
3
3
|
@mockAssertions = [
|
|
4
4
|
{message: "_qunit_message1_", source: "_source1_"}
|
|
5
5
|
{message: "_qunit_message2_", source: "_source2_"}
|
|
6
|
+
{source: "_source3_", expected: 1, actual: 2}
|
|
7
|
+
{source: "_source4_"}
|
|
6
8
|
]
|
|
7
9
|
@mockSpec =
|
|
8
10
|
module: "_full qunit name_"
|
|
@@ -23,11 +25,13 @@ test "constructor", 7, ->
|
|
|
23
25
|
ok(spec.viewId == 420, "sets viewId")
|
|
24
26
|
ok(spec.pending == false, "sets pending to false") # no pending support
|
|
25
27
|
|
|
26
|
-
test "#errors",
|
|
28
|
+
test "#errors", 5, ->
|
|
27
29
|
errors = new Teaspoon.Spec(@mockSpec).errors()
|
|
28
|
-
ok(errors.length ==
|
|
30
|
+
ok(errors.length == 4, "returns the correct length array")
|
|
29
31
|
equal(errors[0].message, "_qunit_message1_", "the first item in the returned array is correct")
|
|
30
32
|
equal(errors[0].stack, "_source1_", "the first item in the returned array is correct")
|
|
33
|
+
equal(errors[2].message, "Expected 2 to equal 1", "a nice fallback message is provided if QUnit does not provide one")
|
|
34
|
+
equal(errors[3].message, "failed", "some fallback message is provided if QUnit does not provide any information")
|
|
31
35
|
|
|
32
36
|
test "#getParents", 3, ->
|
|
33
37
|
spec = new Teaspoon.Spec(@mockSpec)
|