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
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe Teaspoon::Drivers::CapybaraWebkitDriver do
|
|
4
|
+
|
|
5
|
+
describe "#run_specs" do
|
|
6
|
+
|
|
7
|
+
let(:runner) { double }
|
|
8
|
+
let(:document) { double }
|
|
9
|
+
let(:session) { instance_double(Capybara::Session) }
|
|
10
|
+
|
|
11
|
+
before do
|
|
12
|
+
allow(subject).to receive(:session).and_return session
|
|
13
|
+
allow(session).to receive(:visit)
|
|
14
|
+
allow(session).to receive(:document).and_return(document)
|
|
15
|
+
allow(session).to receive(:evaluate_script)
|
|
16
|
+
allow(document).to receive(:synchronize).and_yield
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "navigates to the correct url" do
|
|
20
|
+
expect(session).to receive(:visit).with("_url_")
|
|
21
|
+
subject.run_specs(runner, "_url_")
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "waits for the specs to complete setting the timeout" do
|
|
25
|
+
expect(document).to receive(:synchronize).with(180).and_yield
|
|
26
|
+
subject.run_specs(runner, "_url_")
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "waits until it's done (checking Teaspoon.finished) and processes each line" do
|
|
30
|
+
expect(document).to receive(:synchronize).with(180).and_yield
|
|
31
|
+
expect(session).to receive(:evaluate_script).with("window.Teaspoon && window.Teaspoon.finished").and_return(true)
|
|
32
|
+
expect(session).to receive(:evaluate_script).with("window.Teaspoon && window.Teaspoon.getMessages()").and_return(["_line_"])
|
|
33
|
+
expect(runner).to receive(:process).with("_line_\n")
|
|
34
|
+
subject.run_specs(runner, "_url_")
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end
|
|
@@ -32,15 +32,20 @@ describe Teaspoon::Drivers::PhantomjsDriver do
|
|
|
32
32
|
let(:runner) { double }
|
|
33
33
|
|
|
34
34
|
before do
|
|
35
|
-
subject.
|
|
35
|
+
allow(subject).to receive(:run)
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
it "calls #run and calls runner.process with each line of output" do
|
|
39
39
|
subject.instance_variable_set(:@options, ["--foo", "--bar"])
|
|
40
|
-
args = [
|
|
41
|
-
|
|
40
|
+
args = [
|
|
41
|
+
"--foo",
|
|
42
|
+
"--bar",
|
|
43
|
+
%{"#{Teaspoon::Engine.root.join("lib/teaspoon/drivers/phantomjs/runner.js").to_s}"},
|
|
44
|
+
'"_url_"',
|
|
45
|
+
180]
|
|
46
|
+
expect(runner).to receive(:process).with("_line_")
|
|
42
47
|
@block = nil
|
|
43
|
-
subject.
|
|
48
|
+
expect(subject).to receive(:run).with(*args) { |&b| @block = b }
|
|
44
49
|
subject.run_specs(runner, "_url_")
|
|
45
50
|
@block.call("_line_")
|
|
46
51
|
end
|
|
@@ -50,7 +55,7 @@ describe Teaspoon::Drivers::PhantomjsDriver do
|
|
|
50
55
|
context "without phantomjs" do
|
|
51
56
|
|
|
52
57
|
it "raises a MissingDependency exception" do
|
|
53
|
-
subject.
|
|
58
|
+
expect(subject).to receive(:which).and_return(nil)
|
|
54
59
|
expect { subject.run_specs(:default, "_url_") }.to raise_error Teaspoon::MissingDependency
|
|
55
60
|
end
|
|
56
61
|
|
|
@@ -30,35 +30,35 @@ describe Teaspoon::Drivers::SeleniumDriver do
|
|
|
30
30
|
|
|
31
31
|
before do
|
|
32
32
|
@driver = double(quit: nil, navigate: @navigate = double(to: nil), execute_script: nil)
|
|
33
|
-
Selenium::WebDriver.
|
|
34
|
-
Selenium::WebDriver::Wait.
|
|
33
|
+
allow(Selenium::WebDriver).to receive(:for).and_return(@driver)
|
|
34
|
+
allow(Selenium::WebDriver::Wait).to receive(:new).and_return(@wait = double(until: nil))
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
it "loads firefox for the webdriver" do
|
|
38
|
-
Selenium::WebDriver.
|
|
38
|
+
expect(Selenium::WebDriver).to receive(:for).with(:firefox)
|
|
39
39
|
subject.run_specs(runner, "_url_")
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
it "navigates to the correct url" do
|
|
43
|
-
@navigate.
|
|
43
|
+
expect(@navigate).to receive(:to).with("_url_")
|
|
44
44
|
subject.run_specs(runner, "_url_")
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
it "ensures quit is called on the driver" do
|
|
48
|
-
@driver.
|
|
48
|
+
expect(@driver).to receive(:quit)
|
|
49
49
|
subject.run_specs(runner, "_url_")
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
it "waits for the specs to complete, setting the interval, timeout and message" do
|
|
53
|
-
Selenium::WebDriver::Wait.
|
|
53
|
+
expect(Selenium::WebDriver::Wait).to receive(:new).with(HashWithIndifferentAccess.new(client_driver: :firefox, timeout: 180, interval: 0.01, message: "Timed out"))
|
|
54
54
|
subject.run_specs(runner, "_url_")
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
it "waits until it's done (checking Teaspoon.finished) and processes each line" do
|
|
58
|
-
@wait.
|
|
59
|
-
@driver.
|
|
60
|
-
@driver.
|
|
61
|
-
runner.
|
|
58
|
+
expect(@wait).to receive(:until) { |&b| @block = b }
|
|
59
|
+
expect(@driver).to receive(:execute_script).with("return window.Teaspoon && window.Teaspoon.finished").and_return(true)
|
|
60
|
+
expect(@driver).to receive(:execute_script).with("return window.Teaspoon && window.Teaspoon.getMessages() || []").and_return(["_line_"])
|
|
61
|
+
expect(runner).to receive(:process).with("_line_\n")
|
|
62
62
|
subject.run_specs(runner, "_url_")
|
|
63
63
|
@block.call
|
|
64
64
|
end
|
|
@@ -8,20 +8,20 @@ describe Teaspoon::Environment do
|
|
|
8
8
|
describe ".load" do
|
|
9
9
|
|
|
10
10
|
it "calls require_environment" do
|
|
11
|
-
subject.
|
|
12
|
-
subject.
|
|
11
|
+
expect(subject).to receive(:require_environment)
|
|
12
|
+
expect(subject).to receive(:rails_loaded?).and_return(true)
|
|
13
13
|
Teaspoon::Environment.load
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
it "raises if Rails can't be found" do
|
|
17
|
-
subject.
|
|
18
|
-
subject.
|
|
17
|
+
expect(subject).to receive(:require_environment)
|
|
18
|
+
expect(subject).to receive(:rails_loaded?).and_return(false)
|
|
19
19
|
expect{ Teaspoon::Environment.load }.to raise_error("Rails environment not found.")
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
it "configures teaspoon from options if the environment is ready" do
|
|
23
|
-
subject.
|
|
24
|
-
Teaspoon.configuration.
|
|
23
|
+
expect(subject).to receive(:rails_loaded?).and_return(true)
|
|
24
|
+
expect(Teaspoon.configuration).to receive(:override_from_options).with(foo: "bar")
|
|
25
25
|
Teaspoon::Environment.load(foo: "bar")
|
|
26
26
|
end
|
|
27
27
|
|
|
@@ -30,8 +30,8 @@ describe Teaspoon::Environment do
|
|
|
30
30
|
describe ".require_environment" do
|
|
31
31
|
|
|
32
32
|
before do
|
|
33
|
-
File.
|
|
34
|
-
subject.
|
|
33
|
+
allow(File).to receive(:exists?)
|
|
34
|
+
allow(subject).to receive(:require_env)
|
|
35
35
|
Teaspoon.configured = false
|
|
36
36
|
@orig_teaspoon_env = ENV['TEASPOON_ENV']
|
|
37
37
|
ENV['TEASPOON_ENV'] = nil
|
|
@@ -45,18 +45,18 @@ describe Teaspoon::Environment do
|
|
|
45
45
|
describe "when loading with an override" do
|
|
46
46
|
|
|
47
47
|
before do
|
|
48
|
-
subject.
|
|
48
|
+
expect(subject).to receive(:require_env).and_call_original
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
it "allows passing an override" do
|
|
52
52
|
expanded = File.expand_path("_override_", Dir.pwd)
|
|
53
|
-
::Kernel.
|
|
53
|
+
expect(::Kernel).to receive(:load).with(expanded)
|
|
54
54
|
subject.require_environment("_override_")
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
it "sets the TEASPOON_ENV" do
|
|
58
58
|
expanded = File.expand_path("../../_override_file_", Dir.pwd)
|
|
59
|
-
::Kernel.
|
|
59
|
+
expect(::Kernel).to receive(:load).with(expanded)
|
|
60
60
|
subject.require_environment("../../_override_file_")
|
|
61
61
|
expect(ENV["TEASPOON_ENV"]).to eq(expanded)
|
|
62
62
|
end
|
|
@@ -66,19 +66,19 @@ describe Teaspoon::Environment do
|
|
|
66
66
|
describe "when loading from defaults" do
|
|
67
67
|
|
|
68
68
|
it "looks for the standard files" do
|
|
69
|
-
File.
|
|
70
|
-
subject.
|
|
69
|
+
expect(File).to receive(:exists?).with(File.expand_path("spec/teaspoon_env.rb", Dir.pwd)).and_return(true)
|
|
70
|
+
expect(subject).to receive(:require_env).with(File.expand_path("spec/teaspoon_env.rb", Dir.pwd))
|
|
71
71
|
subject.require_environment
|
|
72
72
|
|
|
73
|
-
File.
|
|
74
|
-
File.
|
|
75
|
-
subject.
|
|
73
|
+
expect(File).to receive(:exists?).with(File.expand_path("spec/teaspoon_env.rb", Dir.pwd)).and_return(false)
|
|
74
|
+
expect(File).to receive(:exists?).with(File.expand_path("test/teaspoon_env.rb", Dir.pwd)).and_return(true)
|
|
75
|
+
expect(subject).to receive(:require_env).with(File.expand_path("test/teaspoon_env.rb", Dir.pwd))
|
|
76
76
|
subject.require_environment
|
|
77
77
|
|
|
78
|
-
File.
|
|
79
|
-
File.
|
|
80
|
-
File.
|
|
81
|
-
subject.
|
|
78
|
+
expect(File).to receive(:exists?).with(File.expand_path("spec/teaspoon_env.rb", Dir.pwd)).and_return(false)
|
|
79
|
+
expect(File).to receive(:exists?).with(File.expand_path("test/teaspoon_env.rb", Dir.pwd)).and_return(false)
|
|
80
|
+
expect(File).to receive(:exists?).with(File.expand_path("teaspoon_env.rb", Dir.pwd)).and_return(true)
|
|
81
|
+
expect(subject).to receive(:require_env).with(File.expand_path("teaspoon_env.rb", Dir.pwd))
|
|
82
82
|
subject.require_environment
|
|
83
83
|
end
|
|
84
84
|
|
|
@@ -98,4 +98,12 @@ describe Teaspoon::Environment do
|
|
|
98
98
|
|
|
99
99
|
end
|
|
100
100
|
|
|
101
|
+
describe ".rails_loaded?" do
|
|
102
|
+
|
|
103
|
+
it "returns a boolean based on if Rails is defined" do
|
|
104
|
+
expect(subject.send(:rails_loaded?)).to be_truthy
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
end
|
|
108
|
+
|
|
101
109
|
end
|
|
@@ -17,21 +17,21 @@ describe Teaspoon::ExceptionHandling do
|
|
|
17
17
|
describe ".add_rails_handling" do
|
|
18
18
|
|
|
19
19
|
before do
|
|
20
|
-
subject.
|
|
20
|
+
allow(subject).to receive(:render_exceptions_with_javascript)
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
it "sets config.assets.debug to false" do
|
|
24
24
|
subject.add_rails_handling
|
|
25
|
-
expect(Rails.application.config.assets.debug).to
|
|
25
|
+
expect(Rails.application.config.assets.debug).to be_falsey
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
it "sets config.action_dispatch.show_exceptions to true" do
|
|
29
29
|
subject.add_rails_handling
|
|
30
|
-
expect(Rails.application.config.action_dispatch.show_exceptions).to
|
|
30
|
+
expect(Rails.application.config.action_dispatch.show_exceptions).to be_truthy
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
it "calls #render_exceptions_with_javascript" do
|
|
34
|
-
subject.
|
|
34
|
+
expect(subject).to receive(:render_exceptions_with_javascript)
|
|
35
35
|
subject.add_rails_handling
|
|
36
36
|
end
|
|
37
37
|
|
|
@@ -22,34 +22,34 @@ describe Teaspoon::Exporter do
|
|
|
22
22
|
describe "#export" do
|
|
23
23
|
|
|
24
24
|
before do
|
|
25
|
-
Dir.
|
|
26
|
-
subject.
|
|
27
|
-
subject.
|
|
25
|
+
expect(Dir).to receive(:mktmpdir).and_yield("_temp_path_")
|
|
26
|
+
allow(subject).to receive(:executable).and_return("/path/to/executable")
|
|
27
|
+
allow(subject).to receive(:`)
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
it "makes a temp directory and cds to it" do
|
|
31
|
-
Dir.
|
|
31
|
+
expect(Dir).to receive(:chdir).with("_temp_path_")
|
|
32
32
|
subject.export
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
it "executes the wget call and creates the export" do
|
|
36
36
|
`(exit 0)`
|
|
37
|
-
Dir.
|
|
38
|
-
subject.
|
|
39
|
-
subject.
|
|
37
|
+
expect(Dir).to receive(:chdir).with("_temp_path_").and_yield
|
|
38
|
+
expect(subject).to receive(:`).with("/path/to/executable --convert-links --adjust-extension --page-requisites --span-hosts http://666.420.42.0:31337/url/to/teaspoon 2>&1")
|
|
39
|
+
expect(subject).to receive(:create_export).with("_temp_path_/666.420.42.0:31337")
|
|
40
40
|
subject.export
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
it "raises a Teaspoon::ExporterException if the command failed for some reason" do
|
|
44
44
|
`(exit 1)`
|
|
45
|
-
Dir.
|
|
45
|
+
expect(Dir).to receive(:chdir).with("_temp_path_").and_yield
|
|
46
46
|
expect { subject.export }.to raise_error Teaspoon::ExporterException, "Unable to export suite_name suite."
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
it "raises a Teaspoon::MissingDependency if wget wasn't found" do
|
|
50
|
-
Dir.
|
|
51
|
-
subject.
|
|
52
|
-
subject.
|
|
50
|
+
expect(Dir).to receive(:chdir).with("_temp_path_").and_yield
|
|
51
|
+
expect(subject).to receive(:executable).and_call_original
|
|
52
|
+
expect(subject).to receive(:which).with("wget").and_return(nil)
|
|
53
53
|
expect { subject.export }.to raise_error Teaspoon::MissingDependency, "Could not find wget for exporting."
|
|
54
54
|
end
|
|
55
55
|
|
|
@@ -57,35 +57,35 @@ describe Teaspoon::Exporter do
|
|
|
57
57
|
|
|
58
58
|
before do
|
|
59
59
|
`(exit 0)`
|
|
60
|
-
Dir.
|
|
61
|
-
Dir.
|
|
62
|
-
|
|
63
|
-
File.
|
|
64
|
-
File.
|
|
65
|
-
FileUtils.
|
|
66
|
-
FileUtils.
|
|
67
|
-
FileUtils.
|
|
60
|
+
expect(Dir).to receive(:chdir).with("_temp_path_").and_yield
|
|
61
|
+
expect(Dir).to receive(:chdir).with("_temp_path_/666.420.42.0:31337").and_yield
|
|
62
|
+
|
|
63
|
+
allow(File).to receive(:read).and_return("")
|
|
64
|
+
allow(File).to receive(:write)
|
|
65
|
+
allow(FileUtils).to receive(:mkdir_p)
|
|
66
|
+
allow(FileUtils).to receive(:rm_r)
|
|
67
|
+
allow(FileUtils).to receive(:mv)
|
|
68
68
|
end
|
|
69
69
|
|
|
70
70
|
it "updates the relative paths" do
|
|
71
|
-
File.
|
|
72
|
-
File.
|
|
71
|
+
expect(File).to receive(:read).with(".#{Teaspoon.configuration.mount_at}/suite_name.html").and_return('"../../path/to/asset')
|
|
72
|
+
expect(File).to receive(:write).with("index.html", '"../path/to/asset')
|
|
73
73
|
subject.export
|
|
74
74
|
end
|
|
75
75
|
|
|
76
76
|
it "cleans up the old files" do
|
|
77
|
-
subject.
|
|
78
|
-
Dir.
|
|
79
|
-
FileUtils.
|
|
77
|
+
allow(subject).to receive(:move_output)
|
|
78
|
+
expect(Dir).to receive(:[]).once.with("{.#{Teaspoon.configuration.mount_at},robots.txt.html}").and_return(["./teaspoon", "robots.txt.html"])
|
|
79
|
+
expect(FileUtils).to receive(:rm_r).with(["./teaspoon", "robots.txt.html"])
|
|
80
80
|
subject.export
|
|
81
81
|
end
|
|
82
82
|
|
|
83
83
|
it "moves the files into the output path" do
|
|
84
|
-
subject.
|
|
84
|
+
allow(subject).to receive(:cleanup_output)
|
|
85
85
|
output_path = subject.instance_variable_get(:@output_path)
|
|
86
|
-
Dir.
|
|
87
|
-
FileUtils.
|
|
88
|
-
FileUtils.
|
|
86
|
+
expect(Dir).to receive(:[]).and_return(["1", "2"])
|
|
87
|
+
expect(FileUtils).to receive(:mkdir_p).with(output_path)
|
|
88
|
+
expect(FileUtils).to receive(:mv).with(["1", "2"], output_path, force: true)
|
|
89
89
|
subject.export
|
|
90
90
|
end
|
|
91
91
|
|
|
@@ -9,7 +9,7 @@ describe Teaspoon::Formatters::Base do
|
|
|
9
9
|
|
|
10
10
|
before do
|
|
11
11
|
@log = ""
|
|
12
|
-
STDOUT.
|
|
12
|
+
allow(STDOUT).to receive(:print) { |s| @log << s }
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
describe "#initialize" do
|
|
@@ -17,7 +17,7 @@ describe Teaspoon::Formatters::Base do
|
|
|
17
17
|
subject { Teaspoon::Formatters::Base.new(:foo, "_output_file_") }
|
|
18
18
|
|
|
19
19
|
before do
|
|
20
|
-
File.
|
|
20
|
+
allow(File).to receive(:open)
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
it "assigns various instance vars" do
|
|
@@ -38,7 +38,7 @@ describe Teaspoon::Formatters::Base do
|
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
it "writes a new output file if one is specified" do
|
|
41
|
-
File.
|
|
41
|
+
expect(File).to receive(:open).with("_output_file_", "w")
|
|
42
42
|
subject
|
|
43
43
|
end
|
|
44
44
|
|
|
@@ -54,10 +54,10 @@ describe Teaspoon::Formatters::Base do
|
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
it "calls #log_runner when appropriate" do
|
|
57
|
-
subject.
|
|
57
|
+
expect(subject).to receive(:log_runner).with(result)
|
|
58
58
|
subject.runner(result)
|
|
59
59
|
|
|
60
|
-
subject.
|
|
60
|
+
expect(subject).to_not receive(:log_runner)
|
|
61
61
|
subject.runner(result, false)
|
|
62
62
|
end
|
|
63
63
|
|
|
@@ -72,10 +72,10 @@ describe Teaspoon::Formatters::Base do
|
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
it "calls #log_suite when appropriate" do
|
|
75
|
-
subject.
|
|
75
|
+
expect(subject).to receive(:log_suite).with(result)
|
|
76
76
|
subject.suite(result)
|
|
77
77
|
|
|
78
|
-
subject.
|
|
78
|
+
expect(subject).to_not receive(:log_suite)
|
|
79
79
|
subject.suite(result, false)
|
|
80
80
|
end
|
|
81
81
|
|
|
@@ -109,10 +109,10 @@ describe Teaspoon::Formatters::Base do
|
|
|
109
109
|
end
|
|
110
110
|
|
|
111
111
|
it "calls #log_spec when appropriate" do
|
|
112
|
-
subject.
|
|
112
|
+
expect(subject).to receive(:log_spec).with(failing_spec)
|
|
113
113
|
subject.spec(failing_spec)
|
|
114
114
|
|
|
115
|
-
subject.
|
|
115
|
+
expect(subject).to_not receive(:log_spec)
|
|
116
116
|
subject.spec(failing_spec, false)
|
|
117
117
|
end
|
|
118
118
|
|
|
@@ -132,10 +132,10 @@ describe Teaspoon::Formatters::Base do
|
|
|
132
132
|
end
|
|
133
133
|
|
|
134
134
|
it "calls #log_error when appropriate" do
|
|
135
|
-
subject.
|
|
135
|
+
expect(subject).to receive(:log_error).with(result)
|
|
136
136
|
subject.error(result)
|
|
137
137
|
|
|
138
|
-
subject.
|
|
138
|
+
expect(subject).to_not receive(:log_error)
|
|
139
139
|
subject.error(result, false)
|
|
140
140
|
end
|
|
141
141
|
|
|
@@ -144,10 +144,10 @@ describe Teaspoon::Formatters::Base do
|
|
|
144
144
|
describe "#exception" do
|
|
145
145
|
|
|
146
146
|
it "calls #log_exception when appropriate" do
|
|
147
|
-
subject.
|
|
147
|
+
expect(subject).to receive(:log_exception).with(result)
|
|
148
148
|
subject.exception(result)
|
|
149
149
|
|
|
150
|
-
subject.
|
|
150
|
+
expect(subject).to_not receive(:log_exception)
|
|
151
151
|
subject.exception(result, false)
|
|
152
152
|
end
|
|
153
153
|
|
|
@@ -162,10 +162,10 @@ describe Teaspoon::Formatters::Base do
|
|
|
162
162
|
end
|
|
163
163
|
|
|
164
164
|
it "calls #log_console when appropriate" do
|
|
165
|
-
subject.
|
|
165
|
+
expect(subject).to receive(:log_console).with("_message_")
|
|
166
166
|
subject.console("_message_")
|
|
167
167
|
|
|
168
|
-
subject.
|
|
168
|
+
expect(subject).to_not receive(:log_console)
|
|
169
169
|
subject.console("_message_", false)
|
|
170
170
|
end
|
|
171
171
|
|
|
@@ -176,10 +176,10 @@ describe Teaspoon::Formatters::Base do
|
|
|
176
176
|
let(:result) { double(coverage: nil) }
|
|
177
177
|
|
|
178
178
|
it "calls #log_result when appropriate" do
|
|
179
|
-
subject.
|
|
179
|
+
expect(subject).to receive(:log_result).with(result)
|
|
180
180
|
subject.result(result)
|
|
181
181
|
|
|
182
|
-
subject.
|
|
182
|
+
expect(subject).to_not receive(:log_result)
|
|
183
183
|
subject.result(result, false)
|
|
184
184
|
end
|
|
185
185
|
|
|
@@ -188,10 +188,10 @@ describe Teaspoon::Formatters::Base do
|
|
|
188
188
|
describe "#coverage" do
|
|
189
189
|
|
|
190
190
|
it "calls #log_coverage when appropriate" do
|
|
191
|
-
subject.
|
|
191
|
+
expect(subject).to receive(:log_coverage).with("_message_")
|
|
192
192
|
subject.coverage("_message_")
|
|
193
193
|
|
|
194
|
-
subject.
|
|
194
|
+
expect(subject).to receive(:log_coverage).with("_message_")
|
|
195
195
|
subject.coverage("_message_")
|
|
196
196
|
end
|
|
197
197
|
|
|
@@ -200,10 +200,10 @@ describe Teaspoon::Formatters::Base do
|
|
|
200
200
|
describe "#threshold_failure" do
|
|
201
201
|
|
|
202
202
|
it "calls #log_threshold_failure when appropriate" do
|
|
203
|
-
subject.
|
|
203
|
+
expect(subject).to receive(:log_threshold_failure).with("_message_")
|
|
204
204
|
subject.threshold_failure("_message_")
|
|
205
205
|
|
|
206
|
-
subject.
|
|
206
|
+
expect(subject).to receive(:log_threshold_failure).with("_message_")
|
|
207
207
|
subject.threshold_failure("_message_")
|
|
208
208
|
end
|
|
209
209
|
|
|
@@ -212,10 +212,10 @@ describe Teaspoon::Formatters::Base do
|
|
|
212
212
|
describe "#complete" do
|
|
213
213
|
|
|
214
214
|
it "calls #log_complete when appropriate" do
|
|
215
|
-
subject.
|
|
215
|
+
expect(subject).to receive(:log_complete).with(42)
|
|
216
216
|
subject.complete(42)
|
|
217
217
|
|
|
218
|
-
subject.
|
|
218
|
+
expect(subject).to receive(:log_complete).with(0)
|
|
219
219
|
subject.complete(0)
|
|
220
220
|
end
|
|
221
221
|
|
|
@@ -224,17 +224,17 @@ describe Teaspoon::Formatters::Base do
|
|
|
224
224
|
describe "#log_spec" do
|
|
225
225
|
|
|
226
226
|
it "calls #log_passing_spec on passing results" do
|
|
227
|
-
subject.
|
|
227
|
+
expect(subject).to receive(:log_passing_spec).with(passing_spec)
|
|
228
228
|
subject.send(:log_spec, passing_spec)
|
|
229
229
|
end
|
|
230
230
|
|
|
231
231
|
it "calls #log_pending_spec on pending results" do
|
|
232
|
-
subject.
|
|
232
|
+
expect(subject).to receive(:log_pending_spec).with(pending_spec)
|
|
233
233
|
subject.send(:log_spec, pending_spec)
|
|
234
234
|
end
|
|
235
235
|
|
|
236
236
|
it "calls #log_failing_spec on failing results" do
|
|
237
|
-
subject.
|
|
237
|
+
expect(subject).to receive(:log_failing_spec).with(failing_spec)
|
|
238
238
|
subject.send(:log_spec, failing_spec)
|
|
239
239
|
end
|
|
240
240
|
|
|
@@ -244,13 +244,13 @@ describe Teaspoon::Formatters::Base do
|
|
|
244
244
|
|
|
245
245
|
it "logs to a file" do
|
|
246
246
|
handle = double(write: nil)
|
|
247
|
-
File.
|
|
248
|
-
handle.
|
|
247
|
+
expect(File).to receive(:open).with("_output_file_", "a").and_yield(handle)
|
|
248
|
+
expect(handle).to receive(:write).with("_str_")
|
|
249
249
|
subject.send(:log_to_file, "_str_", "_output_file_")
|
|
250
250
|
end
|
|
251
251
|
|
|
252
252
|
it "raises a Teaspoon::FileNotWritable exception if the file can't be written to" do
|
|
253
|
-
File.
|
|
253
|
+
expect(File).to receive(:open).and_raise(IOError, "_io_error_message_")
|
|
254
254
|
expect { subject.send(:log_to_file, "_str_", "_output_file_") }.to raise_error(Teaspoon::FileNotWritable, "_io_error_message_")
|
|
255
255
|
end
|
|
256
256
|
|