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
|
@@ -19,11 +19,11 @@ describe Teaspoon do
|
|
|
19
19
|
it "sets configured to true" do
|
|
20
20
|
subject.configured = false
|
|
21
21
|
subject.configure { }
|
|
22
|
-
expect(subject.configured).to
|
|
22
|
+
expect(subject.configured).to be_truthy
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
it "overrides configuration from ENV" do
|
|
26
|
-
subject.configuration.
|
|
26
|
+
expect(subject.configuration).to receive(:override_from_env).with(ENV)
|
|
27
27
|
subject.configure { }
|
|
28
28
|
end
|
|
29
29
|
|
|
@@ -32,7 +32,8 @@ describe Teaspoon do
|
|
|
32
32
|
describe ".setup" do
|
|
33
33
|
|
|
34
34
|
it "calls configure" do
|
|
35
|
-
|
|
35
|
+
block = proc{}
|
|
36
|
+
expect(subject).to receive(:configure).with(no_args) { |&arg| expect(arg).to eq(block) }
|
|
36
37
|
subject.setup(&block)
|
|
37
38
|
end
|
|
38
39
|
|
|
@@ -75,9 +76,9 @@ describe Teaspoon::Configuration do
|
|
|
75
76
|
expect(subject.server_timeout).to eq(20)
|
|
76
77
|
expect(subject.formatters).to eq(['dot'])
|
|
77
78
|
expect(subject.use_coverage).to be_nil
|
|
78
|
-
expect(subject.fail_fast).to
|
|
79
|
-
expect(subject.suppress_log).to
|
|
80
|
-
expect(subject.color).to
|
|
79
|
+
expect(subject.fail_fast).to be_truthy
|
|
80
|
+
expect(subject.suppress_log).to be_falsey
|
|
81
|
+
expect(subject.color).to be_truthy
|
|
81
82
|
|
|
82
83
|
expect(subject.suite_configs).to be_a(Hash)
|
|
83
84
|
expect(subject.coverage_configs).to be_a(Hash)
|
|
@@ -127,9 +128,9 @@ describe Teaspoon::Configuration do
|
|
|
127
128
|
describe ".override_from_options" do
|
|
128
129
|
|
|
129
130
|
it "allows overriding from options" do
|
|
130
|
-
subject.
|
|
131
|
-
subject.
|
|
132
|
-
subject.
|
|
131
|
+
expect(subject).to receive(:fail_fast=).with(true)
|
|
132
|
+
expect(subject).to receive(:driver_timeout=).with(123)
|
|
133
|
+
expect(subject).to receive(:driver=).with("driver")
|
|
133
134
|
|
|
134
135
|
subject.send(:override_from_options, fail_fast: true, driver_timeout: 123, driver: "driver")
|
|
135
136
|
end
|
|
@@ -139,9 +140,9 @@ describe Teaspoon::Configuration do
|
|
|
139
140
|
describe ".override_from_env" do
|
|
140
141
|
|
|
141
142
|
it "allows overriding from the env" do
|
|
142
|
-
subject.
|
|
143
|
-
subject.
|
|
144
|
-
subject.
|
|
143
|
+
expect(subject).to receive(:fail_fast=).with(true)
|
|
144
|
+
expect(subject).to receive(:driver_timeout=).with(123)
|
|
145
|
+
expect(subject).to receive(:driver=).with("driver")
|
|
145
146
|
|
|
146
147
|
subject.send(:override_from_env, "FAIL_FAST" => "true", "DRIVER_TIMEOUT" => "123", "DRIVER" => "driver")
|
|
147
148
|
end
|
|
@@ -161,6 +162,7 @@ describe Teaspoon::Configuration::Suite do
|
|
|
161
162
|
expect(subject.javascripts).to eq(["jasmine/1.3.1", "teaspoon/jasmine"])
|
|
162
163
|
expect(subject.stylesheets).to eq(["teaspoon"])
|
|
163
164
|
expect(subject.no_coverage).to eq([%r{/lib/ruby/gems/}, %r{/vendor/assets/}, %r{/support/}, %r{/(.+)_helper.}])
|
|
165
|
+
expect(subject.expand_assets).to eq(true)
|
|
164
166
|
end
|
|
165
167
|
|
|
166
168
|
it "accepts a block that can override defaults" do
|
|
@@ -192,12 +194,18 @@ describe Teaspoon::Configuration::Suite do
|
|
|
192
194
|
|
|
193
195
|
it "shows an error for unknown frameworks" do
|
|
194
196
|
@suite = proc{ |s| s.use_framework :foo }
|
|
195
|
-
expect{ subject }.to raise_error
|
|
197
|
+
expect{ subject }.to raise_error(
|
|
198
|
+
Teaspoon::UnknownFramework,
|
|
199
|
+
"Unknown framework \"foo\""
|
|
200
|
+
)
|
|
196
201
|
end
|
|
197
202
|
|
|
198
203
|
it "shows an error for unknown versions" do
|
|
199
204
|
@suite = proc{ |s| s.use_framework :qunit, "666" }
|
|
200
|
-
expect{ subject }.to raise_error
|
|
205
|
+
expect{ subject }.to raise_error(
|
|
206
|
+
Teaspoon::UnknownFramework,
|
|
207
|
+
"Unknown framework \"qunit\" with version 666 -- available versions 1.12.0, 1.14.0"
|
|
208
|
+
)
|
|
201
209
|
end
|
|
202
210
|
|
|
203
211
|
end
|
|
@@ -7,44 +7,51 @@ require "teaspoon/exporter"
|
|
|
7
7
|
describe Teaspoon::Console do
|
|
8
8
|
|
|
9
9
|
let(:driver) { double(run_specs: 0) }
|
|
10
|
-
let(:server) { double(start: nil, url: "http://url.com") }
|
|
10
|
+
let(:server) { double(start: nil, url: "http://url.com", responsive?: false) }
|
|
11
11
|
let(:runner) { double(failure_count: 2) }
|
|
12
12
|
|
|
13
13
|
before do
|
|
14
|
-
Teaspoon::Environment.
|
|
15
|
-
Teaspoon::Server.
|
|
16
|
-
Teaspoon::Runner.
|
|
14
|
+
allow(Teaspoon::Environment).to receive(:load)
|
|
15
|
+
allow(Teaspoon::Server).to receive(:new).and_return(server)
|
|
16
|
+
allow(Teaspoon::Runner).to receive(:new).and_return(runner)
|
|
17
17
|
|
|
18
|
-
Teaspoon::Console.
|
|
19
|
-
Teaspoon::Console.
|
|
18
|
+
allow_any_instance_of(Teaspoon::Console).to receive(:driver).and_return(driver)
|
|
19
|
+
allow_any_instance_of(Teaspoon::Console).to receive(:log)
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
describe "#initialize" do
|
|
23
23
|
|
|
24
|
-
it "assigns @
|
|
24
|
+
it "assigns @default_options" do
|
|
25
25
|
subject = Teaspoon::Console.new(foo: "bar")
|
|
26
|
-
expect(subject.instance_variable_get(:@
|
|
26
|
+
expect(subject.instance_variable_get(:@default_options)).to eql(foo: "bar")
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
it "loads the environment" do
|
|
30
|
-
Teaspoon::Environment.
|
|
30
|
+
expect(Teaspoon::Environment).to receive(:load)
|
|
31
31
|
Teaspoon::Console.new
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
it "starts the server" do
|
|
35
|
-
Teaspoon::Console.
|
|
36
|
-
Teaspoon::Console.
|
|
37
|
-
Teaspoon::Server.
|
|
38
|
-
server.
|
|
35
|
+
expect_any_instance_of(Teaspoon::Console).to receive(:log).with("Starting the Teaspoon server...")
|
|
36
|
+
expect_any_instance_of(Teaspoon::Console).to receive(:start_server) .and_call_original
|
|
37
|
+
expect(Teaspoon::Server).to receive(:new).and_return(server)
|
|
38
|
+
expect(server).to receive(:start)
|
|
39
39
|
Teaspoon::Console.new
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
+
it "does not log a message about starting the server if one has already been started" do
|
|
43
|
+
allow(server).to receive(:responsive?).and_return(true)
|
|
44
|
+
expect_any_instance_of(Teaspoon::Console).not_to receive(:log).with("Starting the Teaspoon server...")
|
|
45
|
+
Teaspoon::Console.new
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
|
|
42
49
|
it "aborts (displaying a message) on Teaspoon::ServerException" do
|
|
43
|
-
STDOUT.
|
|
44
|
-
Teaspoon::Console.
|
|
45
|
-
Teaspoon::Console.
|
|
46
|
-
Teaspoon::Console.
|
|
47
|
-
expect{ Teaspoon::Console.new }.to raise_error
|
|
50
|
+
expect(STDOUT).to receive(:print).with("_message_\n")
|
|
51
|
+
expect_any_instance_of(Teaspoon::Console).to receive(:log).and_call_original
|
|
52
|
+
expect_any_instance_of(Teaspoon::Console).to receive(:start_server).and_raise(Teaspoon::ServerException, "_message_")
|
|
53
|
+
expect_any_instance_of(Teaspoon::Console).to receive(:abort).with("_message_").and_call_original
|
|
54
|
+
expect{ Teaspoon::Console.new }.to raise_error(SystemExit)
|
|
48
55
|
end
|
|
49
56
|
|
|
50
57
|
end
|
|
@@ -52,11 +59,11 @@ describe Teaspoon::Console do
|
|
|
52
59
|
describe "#failures?" do
|
|
53
60
|
|
|
54
61
|
it "calls #execute and returns the inverse of #executes return value" do
|
|
55
|
-
subject.
|
|
56
|
-
expect(subject.failures?).to
|
|
62
|
+
expect(subject).to receive(:execute).and_return(false)
|
|
63
|
+
expect(subject.failures?).to be_truthy
|
|
57
64
|
|
|
58
|
-
subject.
|
|
59
|
-
expect(subject.failures?).to
|
|
65
|
+
expect(subject).to receive(:execute).and_return(true)
|
|
66
|
+
expect(subject.failures?).to be_falsey
|
|
60
67
|
end
|
|
61
68
|
|
|
62
69
|
end
|
|
@@ -64,19 +71,25 @@ describe Teaspoon::Console do
|
|
|
64
71
|
describe "#execute" do
|
|
65
72
|
|
|
66
73
|
it "calls #execute_without_handling and returns its value" do
|
|
67
|
-
subject.
|
|
68
|
-
expect(subject.execute(foo: "bar")).to
|
|
74
|
+
expect(subject).to receive(:execute_without_handling).with(foo: "bar").and_return(true)
|
|
75
|
+
expect(subject.execute(foo: "bar")).to be_truthy
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
it "handles Teaspoon::RunnerException exceptions" do
|
|
79
|
+
expect(subject).to receive(:log).with("_runner_error_")
|
|
80
|
+
expect(subject).to receive(:execute_without_handling).and_raise(Teaspoon::RunnerException, "_runner_error_")
|
|
81
|
+
expect(subject.execute).to be_falsey
|
|
69
82
|
end
|
|
70
83
|
|
|
71
84
|
it "handles Teaspoon::Error exceptions" do
|
|
72
|
-
subject.
|
|
73
|
-
subject.
|
|
85
|
+
expect(subject).to receive(:abort).with("_unknown_error_")
|
|
86
|
+
expect(subject).to receive(:execute_without_handling).and_raise(Teaspoon::Error, "_unknown_error_")
|
|
74
87
|
subject.execute
|
|
75
88
|
end
|
|
76
89
|
|
|
77
90
|
it "returns false on Teaspoon::Failure" do
|
|
78
|
-
subject.
|
|
79
|
-
expect(subject.execute).to
|
|
91
|
+
expect(subject).to receive(:execute_without_handling).and_raise(Teaspoon::Failure)
|
|
92
|
+
expect(subject.execute).to be_falsey
|
|
80
93
|
end
|
|
81
94
|
|
|
82
95
|
end
|
|
@@ -84,14 +97,14 @@ describe Teaspoon::Console do
|
|
|
84
97
|
describe "#execute_without_handling" do
|
|
85
98
|
|
|
86
99
|
before do
|
|
87
|
-
subject.
|
|
88
|
-
subject.
|
|
100
|
+
allow(subject).to receive(:run_specs).and_return(0)
|
|
101
|
+
allow(subject).to receive(:export)
|
|
89
102
|
end
|
|
90
103
|
|
|
91
|
-
it "merges
|
|
92
|
-
subject.instance_variable_set(:@
|
|
104
|
+
it "merges options" do
|
|
105
|
+
subject.instance_variable_set(:@default_options, foo: "bar")
|
|
93
106
|
subject.execute_without_handling(bar: "baz")
|
|
94
|
-
expect(subject.
|
|
107
|
+
expect(subject.options).to eql(foo: "bar", bar: "baz")
|
|
95
108
|
end
|
|
96
109
|
|
|
97
110
|
it "clears any @suites" do
|
|
@@ -101,7 +114,7 @@ describe Teaspoon::Console do
|
|
|
101
114
|
end
|
|
102
115
|
|
|
103
116
|
it "resolves the files" do
|
|
104
|
-
Teaspoon::Suite.
|
|
117
|
+
expect(Teaspoon::Suite).to receive(:resolve_spec_for).with("file").and_return(suite: "foo", path: "file2")
|
|
105
118
|
subject.execute_without_handling(files: ["file"])
|
|
106
119
|
|
|
107
120
|
expect(subject.send(:suites)).to eq(["foo"])
|
|
@@ -110,35 +123,35 @@ describe Teaspoon::Console do
|
|
|
110
123
|
|
|
111
124
|
it "resolves the files if a directory was given" do
|
|
112
125
|
resolve_spec_for_output = ['test/javascripts/foo.coffee', 'test/javascripts/bar.coffee']
|
|
113
|
-
Teaspoon::Suite.
|
|
126
|
+
expect(Teaspoon::Suite).to receive(:resolve_spec_for).with("full/path").and_return(suite: "foo", path: resolve_spec_for_output)
|
|
114
127
|
subject.execute_without_handling(files: ["full/path"])
|
|
115
128
|
expect(subject.send(:suites)).to eq(["foo"])
|
|
116
129
|
expect(subject.send(:filter, "foo")).to eq("file[]=#{resolve_spec_for_output.join('&file[]=')}")
|
|
117
130
|
end
|
|
118
131
|
|
|
119
132
|
it "runs the tests" do
|
|
120
|
-
subject.
|
|
121
|
-
subject.
|
|
122
|
-
expect(subject.execute_without_handling).to
|
|
133
|
+
expect(subject).to receive(:suites).and_return([:default, :foo])
|
|
134
|
+
expect(subject).to receive(:run_specs).twice.and_return(2)
|
|
135
|
+
expect(subject.execute_without_handling).to be_falsey
|
|
123
136
|
end
|
|
124
137
|
|
|
125
138
|
it "returns true if no failure count" do
|
|
126
|
-
subject.
|
|
127
|
-
subject.
|
|
128
|
-
expect(subject.execute_without_handling).to
|
|
139
|
+
expect(subject).to receive(:suites).and_return([:default, :foo])
|
|
140
|
+
expect(subject).to receive(:run_specs).twice.and_return(0)
|
|
141
|
+
expect(subject.execute_without_handling).to be_truthy
|
|
129
142
|
end
|
|
130
143
|
|
|
131
144
|
it "returns true if there were failures" do
|
|
132
|
-
subject.
|
|
133
|
-
subject.
|
|
134
|
-
expect(subject.execute_without_handling).to
|
|
145
|
+
expect(subject).to receive(:suites).and_return([:default])
|
|
146
|
+
expect(subject).to receive(:run_specs).once.and_return(1)
|
|
147
|
+
expect(subject.execute_without_handling).to be_falsey
|
|
135
148
|
end
|
|
136
149
|
|
|
137
150
|
it "calls export if the options include :export" do
|
|
138
|
-
subject.
|
|
139
|
-
subject.instance_variable_set(:@
|
|
140
|
-
subject.
|
|
141
|
-
subject.
|
|
151
|
+
expect(subject).to receive(:suites).and_return([:default, :foo])
|
|
152
|
+
subject.instance_variable_set(:@default_options, export: true)
|
|
153
|
+
expect(subject).to receive(:export).with(:default)
|
|
154
|
+
expect(subject).to receive(:export).with(:foo)
|
|
142
155
|
subject.execute
|
|
143
156
|
end
|
|
144
157
|
|
|
@@ -147,33 +160,36 @@ describe Teaspoon::Console do
|
|
|
147
160
|
describe "#run_specs" do
|
|
148
161
|
|
|
149
162
|
before do
|
|
150
|
-
Teaspoon.configuration.
|
|
151
|
-
Teaspoon.configuration.
|
|
163
|
+
allow(Teaspoon.configuration).to receive(:fail_fast).and_return(false)
|
|
164
|
+
expect(Teaspoon.configuration).to receive(:suite_configs).and_return("_suite_" => proc{}, "suite_name" => proc{})
|
|
152
165
|
end
|
|
153
166
|
|
|
154
167
|
it "raises a Teaspoon::UnknownSuite exception when the suite isn't known" do
|
|
155
|
-
expect { subject.run_specs("_unknown_") }.to raise_error
|
|
168
|
+
expect { subject.run_specs("_unknown_") }.to raise_error(
|
|
169
|
+
Teaspoon::UnknownSuite,
|
|
170
|
+
%{Unknown suite: "_unknown_"}
|
|
171
|
+
)
|
|
156
172
|
end
|
|
157
173
|
|
|
158
174
|
it "logs that the suite is being run" do
|
|
159
|
-
subject.
|
|
175
|
+
expect(subject).to receive(:log).with("Teaspoon running _suite_ suite at http://url.com/teaspoon/_suite_")
|
|
160
176
|
subject.run_specs("_suite_")
|
|
161
177
|
end
|
|
162
178
|
|
|
163
179
|
it "calls #run_specs on the driver" do
|
|
164
|
-
subject.
|
|
165
|
-
driver.
|
|
180
|
+
expect(subject).to receive(:driver).and_return(driver)
|
|
181
|
+
expect(driver).to receive(:run_specs).with(runner, "http://url.com/teaspoon/suite_name?reporter=Console")
|
|
166
182
|
expect(subject.run_specs(:suite_name)).to eq(2)
|
|
167
183
|
end
|
|
168
184
|
|
|
169
185
|
it "raises a Teaspoon::Failure exception on failures when set to fail_fast" do
|
|
170
|
-
Teaspoon.configuration.
|
|
186
|
+
allow(Teaspoon.configuration).to receive(:fail_fast).and_return(true)
|
|
171
187
|
expect { subject.run_specs(:suite_name) }.to raise_error Teaspoon::Failure
|
|
172
188
|
end
|
|
173
189
|
|
|
174
190
|
it "raises a Teaspoon:UnknownDriver when an unknown driver is being used" do
|
|
175
|
-
Teaspoon.configuration.
|
|
176
|
-
subject.
|
|
191
|
+
expect(Teaspoon.configuration).to receive(:driver).twice.and_return(:foo)
|
|
192
|
+
expect(subject).to receive(:driver).and_call_original
|
|
177
193
|
expect { subject.run_specs(:suite_name) }.to raise_error Teaspoon::UnknownDriver
|
|
178
194
|
end
|
|
179
195
|
|
|
@@ -182,8 +198,8 @@ describe Teaspoon::Console do
|
|
|
182
198
|
describe "#export" do
|
|
183
199
|
|
|
184
200
|
before do
|
|
185
|
-
Teaspoon.configuration.
|
|
186
|
-
Teaspoon::Exporter.
|
|
201
|
+
expect(Teaspoon.configuration).to receive(:suite_configs).and_return("_suite_" => proc{}, "suite_name" => proc{})
|
|
202
|
+
allow(Teaspoon::Exporter).to receive(:new).and_return(double(export: nil))
|
|
187
203
|
end
|
|
188
204
|
|
|
189
205
|
it "raises a Teaspoon::UnknownSuite exception when the suite isn't known" do
|
|
@@ -191,15 +207,15 @@ describe Teaspoon::Console do
|
|
|
191
207
|
end
|
|
192
208
|
|
|
193
209
|
it "logs that the suite is being exported" do
|
|
194
|
-
subject.
|
|
210
|
+
expect(subject).to receive(:log).with("Teaspoon exporting _suite_ suite at http://url.com/teaspoon/_suite_")
|
|
195
211
|
subject.export("_suite_")
|
|
196
212
|
end
|
|
197
213
|
|
|
198
214
|
it "calls #export on the exporter" do
|
|
199
|
-
subject.instance_variable_set(:@
|
|
215
|
+
subject.instance_variable_set(:@default_options, export: "_output_path_")
|
|
200
216
|
exporter = double(export: nil)
|
|
201
|
-
Teaspoon::Exporter.
|
|
202
|
-
exporter.
|
|
217
|
+
expect(Teaspoon::Exporter).to receive(:new).with("_suite_", "http://url.com/teaspoon/_suite_", "_output_path_").and_return(exporter)
|
|
218
|
+
expect(exporter).to receive(:export)
|
|
203
219
|
subject.export("_suite_")
|
|
204
220
|
end
|
|
205
221
|
|
|
@@ -8,9 +8,9 @@ describe Teaspoon::Coverage do
|
|
|
8
8
|
let(:config) { double }
|
|
9
9
|
|
|
10
10
|
before do
|
|
11
|
-
Teaspoon::Instrumentation.
|
|
12
|
-
subject.
|
|
13
|
-
subject.
|
|
11
|
+
allow(Teaspoon::Instrumentation).to receive(:executable).and_return("/path/to/executable")
|
|
12
|
+
allow(subject).to receive(:`).and_return("")
|
|
13
|
+
allow(subject).to receive(:input_path).and_yield("/temp_path/coverage.json")
|
|
14
14
|
subject.instance_variable_set(:@config, config)
|
|
15
15
|
end
|
|
16
16
|
|
|
@@ -25,8 +25,8 @@ describe Teaspoon::Coverage do
|
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
it "gets the coverage configuration" do
|
|
28
|
-
Teaspoon::Coverage.
|
|
29
|
-
|
|
28
|
+
expect_any_instance_of(Teaspoon::Coverage).to receive(:coverage_configuration).with("default")
|
|
29
|
+
Teaspoon::Coverage.new("_suite_", :default, data)
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
end
|
|
@@ -37,12 +37,12 @@ describe Teaspoon::Coverage do
|
|
|
37
37
|
|
|
38
38
|
it "generates reports using istanbul and passes them to the block provided" do
|
|
39
39
|
`(exit 0)`
|
|
40
|
-
html_report = "/path/to/executable report
|
|
41
|
-
text1_report = "/path/to/executable report
|
|
42
|
-
text2_report = "/path/to/executable report
|
|
43
|
-
subject.
|
|
44
|
-
subject.
|
|
45
|
-
subject.
|
|
40
|
+
html_report = "/path/to/executable report --include=/temp_path/coverage.json --dir output/path/_suite_ html 2>&1"
|
|
41
|
+
text1_report = "/path/to/executable report --include=/temp_path/coverage.json --dir output/path/_suite_ text 2>&1"
|
|
42
|
+
text2_report = "/path/to/executable report --include=/temp_path/coverage.json --dir output/path/_suite_ text-summary 2>&1"
|
|
43
|
+
expect(subject).to receive(:`).with(html_report).and_return("_html_report_")
|
|
44
|
+
expect(subject).to receive(:`).with(text1_report).and_return("_text1_report_")
|
|
45
|
+
expect(subject).to receive(:`).with(text2_report).and_return("_text2_report_")
|
|
46
46
|
subject.generate_reports { |r| @result = r }
|
|
47
47
|
expect(@result).to eq("_text1_report_\n\n_text2_report_")
|
|
48
48
|
end
|
|
@@ -59,24 +59,24 @@ describe Teaspoon::Coverage do
|
|
|
59
59
|
let(:config) { double(statements: 42, functions: 66.6, branches: 0, lines: 100) }
|
|
60
60
|
|
|
61
61
|
it "does nothing if there are no threshold checks to make" do
|
|
62
|
-
subject.
|
|
63
|
-
subject.
|
|
62
|
+
expect(subject).to receive(:threshold_args).and_return(nil)
|
|
63
|
+
expect(subject).to_not receive(:input_path)
|
|
64
64
|
subject.check_thresholds {}
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
it "checks the coverage using istanbul and passes them to the block provided" do
|
|
68
68
|
`(exit 1)`
|
|
69
69
|
check_coverage = "/path/to/executable check-coverage --statements=42 --functions=66.6 --branches=0 --lines=100 /temp_path/coverage.json 2>&1"
|
|
70
|
-
subject.
|
|
70
|
+
expect(subject).to receive(:`).with(check_coverage).and_return("some mumbo jumbo\nERROR: _failure1_\nmore garbage\nERROR: _failure2_")
|
|
71
71
|
subject.check_thresholds { |r| @result = r }
|
|
72
72
|
expect(@result).to eq("_failure1_\n_failure2_")
|
|
73
73
|
end
|
|
74
74
|
|
|
75
75
|
it "doesn't call the callback if the exit status is 0" do
|
|
76
76
|
`(exit 0)`
|
|
77
|
-
subject.
|
|
77
|
+
expect(subject).to receive(:`).and_return("ERROR: _failure1_")
|
|
78
78
|
subject.check_thresholds { |r| @called = true }
|
|
79
|
-
expect(@called).to
|
|
79
|
+
expect(@called).to be_falsey
|
|
80
80
|
end
|
|
81
81
|
|
|
82
82
|
end
|
|
@@ -88,9 +88,9 @@ describe Teaspoon::Coverage do
|
|
|
88
88
|
before do
|
|
89
89
|
Teaspoon::Instrumentation.instance_variable_set(:@executable, nil)
|
|
90
90
|
Teaspoon::Instrumentation.instance_variable_set(:@executable_checked, nil)
|
|
91
|
-
Teaspoon::Instrumentation.
|
|
92
|
-
subject.
|
|
93
|
-
subject.
|
|
91
|
+
expect(Teaspoon::Instrumentation).to receive(:executable).and_call_original
|
|
92
|
+
expect(subject).to receive(:input_path).and_call_original
|
|
93
|
+
expect(subject).to receive(:`).and_call_original
|
|
94
94
|
|
|
95
95
|
executable = Teaspoon::Instrumentation.executable
|
|
96
96
|
pending('needs istanbul to be installed') unless executable
|
|
@@ -101,15 +101,15 @@ describe Teaspoon::Coverage do
|
|
|
101
101
|
it "generates coverage reports" do
|
|
102
102
|
subject.generate_reports { |r| @report = r }
|
|
103
103
|
expect(@report).to eq <<-RESULT.strip_heredoc + "\n"
|
|
104
|
-
|
|
104
|
+
-------------------------|-----------|-----------|-----------|-----------|
|
|
105
105
|
File | % Stmts |% Branches | % Funcs | % Lines |
|
|
106
|
-
|
|
106
|
+
-------------------------|-----------|-----------|-----------|-----------|
|
|
107
107
|
integration/ | 90.91 | 100 | 75 | 90.91 |
|
|
108
108
|
integration.coffee | 75 | 100 | 50 | 75 |
|
|
109
109
|
spec_helper.coffee | 100 | 100 | 100 | 100 |
|
|
110
|
-
|
|
110
|
+
-------------------------|-----------|-----------|-----------|-----------|
|
|
111
111
|
All files | 90.91 | 100 | 75 | 90.91 |
|
|
112
|
-
|
|
112
|
+
-------------------------|-----------|-----------|-----------|-----------|
|
|
113
113
|
RESULT
|
|
114
114
|
end
|
|
115
115
|
|