teaspoon 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/MIT.LICENSE +1 -1
  3. data/README.md +46 -377
  4. data/app/assets/javascripts/teaspoon-jasmine.js +200 -194
  5. data/app/assets/javascripts/teaspoon-mocha.js +183 -185
  6. data/app/assets/javascripts/teaspoon-qunit.js +201 -193
  7. data/app/assets/javascripts/teaspoon-teaspoon.js +10 -10
  8. data/app/assets/javascripts/teaspoon/base/fixture.coffee +0 -1
  9. data/app/assets/javascripts/teaspoon/base/hook.coffee +7 -6
  10. data/app/assets/javascripts/teaspoon/qunit.coffee +10 -0
  11. data/app/controllers/teaspoon/suite_controller.rb +3 -4
  12. data/app/views/teaspoon/suite/_boot.html.erb +1 -1
  13. data/app/views/teaspoon/suite/_boot_require_js.html.erb +1 -0
  14. data/bin/teaspoon +1 -1
  15. data/config/routes.rb +4 -14
  16. data/lib/generators/teaspoon/install/install_generator.rb +22 -11
  17. data/lib/generators/teaspoon/install/templates/jasmine/{env_comments.rb → env_comments.rb.tt} +10 -5
  18. data/lib/generators/teaspoon/install/templates/jasmine/spec_helper.coffee +5 -5
  19. data/lib/generators/teaspoon/install/templates/jasmine/spec_helper.js +5 -5
  20. data/lib/generators/teaspoon/install/templates/mocha/{env_comments.rb → env_comments.rb.tt} +10 -5
  21. data/lib/generators/teaspoon/install/templates/mocha/spec_helper.coffee +6 -5
  22. data/lib/generators/teaspoon/install/templates/mocha/spec_helper.js +6 -5
  23. data/lib/generators/teaspoon/install/templates/qunit/{env_comments.rb → env_comments.rb.tt} +10 -5
  24. data/lib/generators/teaspoon/install/templates/qunit/test_helper.coffee +5 -5
  25. data/lib/generators/teaspoon/install/templates/qunit/test_helper.js +5 -5
  26. data/lib/tasks/teaspoon.rake +1 -1
  27. data/lib/teaspoon/command_line.rb +37 -40
  28. data/lib/teaspoon/configuration.rb +27 -30
  29. data/lib/teaspoon/configuration.rb.orig +187 -0
  30. data/lib/teaspoon/console.rb +31 -17
  31. data/lib/teaspoon/coverage.rb +2 -3
  32. data/lib/teaspoon/deprecated.rb +13 -8
  33. data/lib/teaspoon/drivers/base.rb +2 -2
  34. data/lib/teaspoon/drivers/capybara_webkit_driver.rb +33 -0
  35. data/lib/teaspoon/drivers/phantomjs/runner.js +2 -2
  36. data/lib/teaspoon/drivers/phantomjs_driver.rb +13 -4
  37. data/lib/teaspoon/drivers/selenium_driver.rb +3 -5
  38. data/lib/teaspoon/engine.rb +33 -5
  39. data/lib/teaspoon/environment.rb +2 -4
  40. data/lib/teaspoon/exceptions.rb +8 -5
  41. data/lib/teaspoon/formatters/base.rb +39 -27
  42. data/lib/teaspoon/formatters/clean_formatter.rb +0 -1
  43. data/lib/teaspoon/formatters/description.rb +36 -0
  44. data/lib/teaspoon/formatters/documentation_formatter.rb +2 -2
  45. data/lib/teaspoon/formatters/json_formatter.rb +1 -2
  46. data/lib/teaspoon/formatters/junit_formatter.rb +20 -20
  47. data/lib/teaspoon/formatters/modules/report_module.rb +4 -4
  48. data/lib/teaspoon/formatters/pride_formatter.rb +0 -1
  49. data/lib/teaspoon/formatters/rspec_html_formatter.rb +463 -0
  50. data/lib/teaspoon/formatters/snowday_formatter.rb +0 -1
  51. data/lib/teaspoon/formatters/swayze_or_oprah_formatter.rb +5 -4
  52. data/lib/teaspoon/formatters/tap_formatter.rb +2 -3
  53. data/lib/teaspoon/formatters/tap_y_formatter.rb +20 -21
  54. data/lib/teaspoon/formatters/teamcity_formatter.rb +4 -5
  55. data/lib/teaspoon/instrumentation.rb +7 -7
  56. data/lib/teaspoon/result.rb +1 -3
  57. data/lib/teaspoon/runner.rb +1 -2
  58. data/lib/teaspoon/server.rb +2 -1
  59. data/lib/teaspoon/suite.rb +20 -17
  60. data/lib/teaspoon/utility.rb +1 -3
  61. data/lib/teaspoon/version.rb +1 -1
  62. data/spec/dummy/config/application.rb +14 -18
  63. data/spec/dummy/config/boot.rb +2 -6
  64. data/spec/dummy/config/environment.rb +3 -3
  65. data/spec/dummy/config/environments/development.rb +27 -13
  66. data/spec/dummy/config/environments/production.rb +79 -0
  67. data/spec/dummy/config/environments/test.rb +26 -13
  68. data/spec/dummy/config/routes.rb +1 -1
  69. data/spec/dummy/config/secrets.yml +22 -0
  70. data/spec/features/console_reporter_spec.rb +3 -8
  71. data/spec/features/hooks_spec.rb +17 -4
  72. data/spec/features/html_reporter_spec.rb +12 -1
  73. data/spec/features/install_generator_spec.rb +2 -3
  74. data/spec/features/instrumentation_spec.rb +11 -11
  75. data/spec/javascripts/teaspoon/base/teaspoon_spec.coffee +14 -1
  76. data/spec/spec_helper.rb +7 -4
  77. data/spec/teaspoon/command_line_spec.rb +19 -28
  78. data/spec/teaspoon/configuration_spec.rb +22 -14
  79. data/spec/teaspoon/console_spec.rb +79 -63
  80. data/spec/teaspoon/coverage_spec.rb +23 -23
  81. data/spec/teaspoon/drivers/capybara_webkit_driver_spec.rb +39 -0
  82. data/spec/teaspoon/drivers/phantomjs_driver_spec.rb +10 -5
  83. data/spec/teaspoon/drivers/selenium_driver_spec.rb +10 -10
  84. data/spec/teaspoon/environment_spec.rb +28 -20
  85. data/spec/teaspoon/exceptions_spec.rb +4 -4
  86. data/spec/teaspoon/exporter_spec.rb +28 -28
  87. data/spec/teaspoon/formatters/base_spec.rb +29 -29
  88. data/spec/teaspoon/formatters/clean_formatter_spec.rb +1 -1
  89. data/spec/teaspoon/formatters/documentation_formatter_spec.rb +1 -1
  90. data/spec/teaspoon/formatters/dot_formatter_spec.rb +1 -1
  91. data/spec/teaspoon/formatters/json_formatter_spec.rb +7 -7
  92. data/spec/teaspoon/formatters/junit_formatter_spec.rb +10 -10
  93. data/spec/teaspoon/formatters/pride_formatter_spec.rb +1 -1
  94. data/spec/teaspoon/formatters/rspec_html_formatter_spec.rb +107 -0
  95. data/spec/teaspoon/formatters/snowday_formatter_spec.rb +1 -1
  96. data/spec/teaspoon/formatters/tap_formatter_spec.rb +1 -1
  97. data/spec/teaspoon/formatters/tap_y_formatter_spec.rb +1 -1
  98. data/spec/teaspoon/formatters/teamcity_formatter_spec.rb +27 -27
  99. data/spec/teaspoon/instrumentation_spec.rb +35 -29
  100. data/spec/teaspoon/result_spec.rb +40 -36
  101. data/spec/teaspoon/runner_spec.rb +23 -20
  102. data/spec/teaspoon/server_spec.rb +19 -16
  103. data/spec/teaspoon/suite_spec.rb +23 -9
  104. data/spec/teaspoon_env.rb +7 -12
  105. data/test/javascripts/teaspoon/qunit/models_test.coffee +6 -2
  106. data/vendor/assets/javascripts/support/chai-1.10.0.js +4800 -0
  107. data/vendor/assets/javascripts/support/chai-jq-0.0.7.js +524 -0
  108. data/vendor/assets/javascripts/support/chai.js +4435 -4349
  109. metadata +57 -54
  110. data/app/assets/javascripts/teaspoon-angular.js +0 -1299
  111. data/app/assets/javascripts/teaspoon/angular.coffee +0 -55
  112. data/app/assets/javascripts/teaspoon/angular/reporters/console.coffee +0 -11
  113. data/app/assets/javascripts/teaspoon/angular/reporters/html.coffee +0 -21
  114. data/spec/javascripts/angular_helper.coffee +0 -5
  115. data/spec/javascripts/teaspoon/angular/models_aspec.coffee +0 -95
  116. data/spec/javascripts/teaspoon/angular/reporters/html_aspec.coffee +0 -9
  117. data/vendor/assets/javascripts/angular/1.0.5.js +0 -26195
  118. 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.stub(:run)
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 = ["--foo", "--bar", Teaspoon::Engine.root.join("lib/teaspoon/drivers/phantomjs/runner.js").to_s, "_url_", 180]
41
- runner.should_receive(:process).with("_line_")
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.should_receive(:run).with(*args) { |&b| @block = b }
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.should_receive(:which).and_return(nil)
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.stub(:for).and_return(@driver)
34
- Selenium::WebDriver::Wait.stub(:new).and_return(@wait = double(until: nil))
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.should_receive(:for).with(:firefox)
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.should_receive(:to).with("_url_")
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.should_receive(:quit)
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.should_receive(:new).with(HashWithIndifferentAccess.new(client_driver: :firefox, timeout: 180, interval: 0.01, message: "Timed out"))
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.should_receive(:until) { |&b| @block = b }
59
- @driver.should_receive(:execute_script).with("return window.Teaspoon && window.Teaspoon.finished").and_return(true)
60
- @driver.should_receive(:execute_script).with("return window.Teaspoon && window.Teaspoon.getMessages() || []").and_return(["_line_"])
61
- runner.should_receive(:process).with("_line_\n")
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.should_receive(:require_environment)
12
- subject.should_receive(:rails_loaded?).and_return(true)
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.should_receive(:require_environment)
18
- subject.should_receive(:rails_loaded?).and_return(false)
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.should_receive(:rails_loaded?).and_return(true)
24
- Teaspoon.configuration.should_receive(:override_from_options).with(foo: "bar")
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.stub(:exists?)
34
- subject.stub(:require_env)
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.should_receive(:require_env).and_call_original
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.should_receive(:load).with(expanded)
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.should_receive(:load).with(expanded)
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.should_receive(:exists?).with(File.expand_path("spec/teaspoon_env.rb", Dir.pwd)).and_return(true)
70
- subject.should_receive(:require_env).with(File.expand_path("spec/teaspoon_env.rb", Dir.pwd))
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.should_receive(:exists?).with(File.expand_path("spec/teaspoon_env.rb", Dir.pwd)).and_return(false)
74
- File.should_receive(:exists?).with(File.expand_path("test/teaspoon_env.rb", Dir.pwd)).and_return(true)
75
- subject.should_receive(:require_env).with(File.expand_path("test/teaspoon_env.rb", Dir.pwd))
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.should_receive(:exists?).with(File.expand_path("spec/teaspoon_env.rb", Dir.pwd)).and_return(false)
79
- File.should_receive(:exists?).with(File.expand_path("test/teaspoon_env.rb", Dir.pwd)).and_return(false)
80
- File.should_receive(:exists?).with(File.expand_path("teaspoon_env.rb", Dir.pwd)).and_return(true)
81
- subject.should_receive(:require_env).with(File.expand_path("teaspoon_env.rb", Dir.pwd))
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.stub(:render_exceptions_with_javascript)
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 be_false
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 be_true
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.should_receive(:render_exceptions_with_javascript)
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.should_receive(:mktmpdir).and_yield("_temp_path_")
26
- subject.stub(:executable).and_return("/path/to/executable")
27
- subject.stub(:`)
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.should_receive(:chdir).with("_temp_path_")
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.should_receive(:chdir).with("_temp_path_").and_yield
38
- subject.should_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
- subject.should_receive(:create_export).with("_temp_path_/666.420.42.0:31337")
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.should_receive(:chdir).with("_temp_path_").and_yield
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.should_receive(:chdir).with("_temp_path_").and_yield
51
- subject.should_receive(:executable).and_call_original
52
- subject.should_receive(:which).with("wget").and_return(nil)
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.should_receive(:chdir).with("_temp_path_").and_yield
61
- Dir.should_receive(:chdir).with("_temp_path_/666.420.42.0:31337").and_yield
62
-
63
- File.stub(:read).and_return("")
64
- File.stub(:write)
65
- FileUtils.stub(:mkdir_p)
66
- FileUtils.stub(:rm_r)
67
- FileUtils.stub(:mv)
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.should_receive(:read).with(".#{Teaspoon.configuration.mount_at}/suite_name.html").and_return('"../../path/to/asset')
72
- File.should_receive(:write).with("index.html", '"../path/to/asset')
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.stub(:move_output)
78
- Dir.should_receive(:[]).once.with("{.#{Teaspoon.configuration.mount_at},robots.txt.html}").and_return(["./teaspoon", "robots.txt.html"])
79
- FileUtils.should_receive(:rm_r).with(["./teaspoon", "robots.txt.html"])
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.stub(:cleanup_output)
84
+ allow(subject).to receive(:cleanup_output)
85
85
  output_path = subject.instance_variable_get(:@output_path)
86
- Dir.should_receive(:[]).and_return(["1", "2"])
87
- FileUtils.should_receive(:mkdir_p).with(output_path)
88
- FileUtils.should_receive(:mv).with(["1", "2"], output_path, force: true)
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.stub(:print) { |s| @log << s }
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.stub(:open)
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.should_receive(:open).with("_output_file_", "w")
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.should_receive(:log_runner).with(result)
57
+ expect(subject).to receive(:log_runner).with(result)
58
58
  subject.runner(result)
59
59
 
60
- subject.should_not_receive(:log_runner)
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.should_receive(:log_suite).with(result)
75
+ expect(subject).to receive(:log_suite).with(result)
76
76
  subject.suite(result)
77
77
 
78
- subject.should_not_receive(:log_suite)
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.should_receive(:log_spec).with(failing_spec)
112
+ expect(subject).to receive(:log_spec).with(failing_spec)
113
113
  subject.spec(failing_spec)
114
114
 
115
- subject.should_not_receive(:log_spec)
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.should_receive(:log_error).with(result)
135
+ expect(subject).to receive(:log_error).with(result)
136
136
  subject.error(result)
137
137
 
138
- subject.should_not_receive(:log_error)
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.should_receive(:log_exception).with(result)
147
+ expect(subject).to receive(:log_exception).with(result)
148
148
  subject.exception(result)
149
149
 
150
- subject.should_not_receive(:log_exception)
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.should_receive(:log_console).with("_message_")
165
+ expect(subject).to receive(:log_console).with("_message_")
166
166
  subject.console("_message_")
167
167
 
168
- subject.should_not_receive(:log_console)
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.should_receive(:log_result).with(result)
179
+ expect(subject).to receive(:log_result).with(result)
180
180
  subject.result(result)
181
181
 
182
- subject.should_not_receive(:log_result)
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.should_receive(:log_coverage).with("_message_")
191
+ expect(subject).to receive(:log_coverage).with("_message_")
192
192
  subject.coverage("_message_")
193
193
 
194
- subject.should_receive(:log_coverage).with("_message_")
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.should_receive(:log_threshold_failure).with("_message_")
203
+ expect(subject).to receive(:log_threshold_failure).with("_message_")
204
204
  subject.threshold_failure("_message_")
205
205
 
206
- subject.should_receive(:log_threshold_failure).with("_message_")
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.should_receive(:log_complete).with(42)
215
+ expect(subject).to receive(:log_complete).with(42)
216
216
  subject.complete(42)
217
217
 
218
- subject.should_receive(:log_complete).with(0)
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.should_receive(:log_passing_spec).with(passing_spec)
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.should_receive(:log_pending_spec).with(pending_spec)
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.should_receive(:log_failing_spec).with(failing_spec)
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.should_receive(:open).with("_output_file_", "a").and_yield(handle)
248
- handle.should_receive(:write).with("_str_")
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.should_receive(:open).and_raise(IOError, "_io_error_message_")
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