teaspoon 0.9.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (214) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +141 -0
  3. data/README.md +9 -19
  4. data/{vendor → app}/assets/javascripts/support/bind-poly.js +0 -0
  5. data/{vendor → app}/assets/javascripts/support/sinon.js +0 -0
  6. data/app/assets/javascripts/teaspoon-filterer.js +55 -0
  7. data/app/assets/javascripts/teaspoon/error.coffee +5 -0
  8. data/app/assets/javascripts/teaspoon/{base/fixture.coffee → fixture.coffee} +15 -15
  9. data/app/assets/javascripts/teaspoon/{base/hook.coffee → hook.coffee} +0 -0
  10. data/app/assets/javascripts/teaspoon/{base/reporters → reporters}/console.coffee +18 -10
  11. data/app/assets/javascripts/teaspoon/{base/reporters → reporters}/html.coffee +43 -40
  12. data/app/assets/javascripts/teaspoon/{base/reporters → reporters}/html/base_view.coffee +0 -0
  13. data/app/assets/javascripts/teaspoon/{base/reporters → reporters}/html/failure_view.coffee +2 -0
  14. data/app/assets/javascripts/teaspoon/reporters/html/progress_view.coffee +18 -0
  15. data/app/assets/javascripts/teaspoon/{base/reporters/html/progress_view.coffee → reporters/html/radial_progress_view.coffee} +1 -34
  16. data/app/assets/javascripts/teaspoon/reporters/html/simple_progress_view.coffee +15 -0
  17. data/app/assets/javascripts/teaspoon/{base/reporters → reporters}/html/spec_view.coffee +5 -3
  18. data/app/assets/javascripts/teaspoon/{base/reporters → reporters}/html/suite_view.coffee +4 -2
  19. data/app/assets/javascripts/teaspoon/{base/reporters → reporters}/html/template.coffee +0 -0
  20. data/app/assets/javascripts/teaspoon/{base/runner.coffee → runner.coffee} +7 -3
  21. data/app/assets/javascripts/teaspoon/teaspoon.coffee +90 -32
  22. data/app/controllers/teaspoon/suite_controller.rb +5 -0
  23. data/app/views/teaspoon/suite/index.html.erb +1 -1
  24. data/lib/generators/teaspoon/install/install_generator.rb +67 -37
  25. data/lib/generators/teaspoon/install/templates/MISSING_FRAMEWORK +14 -0
  26. data/lib/generators/teaspoon/install/{POST_INSTALL → templates/POST_INSTALL} +0 -0
  27. data/lib/generators/teaspoon/install/templates/env.rb.tt +14 -0
  28. data/lib/generators/teaspoon/install/templates/{jasmine/env_comments.rb.tt → env_comments.rb.tt} +34 -43
  29. data/lib/tasks/teaspoon/info.rake +17 -0
  30. data/lib/teaspoon-devkit.rb +61 -0
  31. data/lib/teaspoon.rb +2 -0
  32. data/lib/teaspoon/command_line.rb +19 -14
  33. data/lib/teaspoon/configuration.rb +24 -35
  34. data/lib/teaspoon/console.rb +11 -21
  35. data/lib/teaspoon/coverage.rb +14 -7
  36. data/lib/teaspoon/deprecated.rb +22 -4
  37. data/lib/teaspoon/driver.rb +15 -0
  38. data/lib/teaspoon/driver/base.rb +7 -0
  39. data/lib/teaspoon/{drivers/capybara_webkit_driver.rb → driver/capybara_webkit.rb} +8 -5
  40. data/lib/teaspoon/{drivers/phantomjs_driver.rb → driver/phantomjs.rb} +8 -4
  41. data/lib/teaspoon/{drivers → driver}/phantomjs/runner.js +0 -0
  42. data/lib/teaspoon/{drivers/selenium_driver.rb → driver/selenium.rb} +11 -9
  43. data/lib/teaspoon/engine.rb +38 -25
  44. data/lib/teaspoon/environment.rb +24 -15
  45. data/lib/teaspoon/exceptions.rb +154 -41
  46. data/lib/teaspoon/exporter.rb +2 -2
  47. data/lib/teaspoon/formatter.rb +30 -0
  48. data/lib/teaspoon/{formatters → formatter}/base.rb +2 -36
  49. data/lib/teaspoon/{formatters/clean_formatter.rb → formatter/clean.rb} +4 -2
  50. data/lib/teaspoon/{formatters/documentation_formatter.rb → formatter/documentation.rb} +4 -3
  51. data/lib/teaspoon/{formatters/dot_formatter.rb → formatter/dot.rb} +4 -3
  52. data/lib/teaspoon/{formatters/json_formatter.rb → formatter/json.rb} +4 -2
  53. data/lib/teaspoon/{formatters/junit_formatter.rb → formatter/junit.rb} +3 -2
  54. data/lib/teaspoon/{formatters → formatter}/modules/report_module.rb +1 -1
  55. data/lib/teaspoon/{formatters/pride_formatter.rb → formatter/pride.rb} +4 -2
  56. data/lib/teaspoon/{formatters/rspec_html_formatter.rb → formatter/rspec_html.rb} +3 -2
  57. data/lib/teaspoon/{formatters/snowday_formatter.rb → formatter/snowday.rb} +3 -2
  58. data/lib/teaspoon/formatter/swayze_or_oprah.rb +111 -0
  59. data/lib/teaspoon/{formatters/tap_formatter.rb → formatter/tap.rb} +4 -2
  60. data/lib/teaspoon/{formatters/tap_y_formatter.rb → formatter/tap_y.rb} +3 -2
  61. data/lib/teaspoon/{formatters/teamcity_formatter.rb → formatter/teamcity.rb} +4 -2
  62. data/lib/teaspoon/framework.rb +17 -0
  63. data/lib/teaspoon/framework/base.rb +88 -0
  64. data/lib/teaspoon/instrumentation.rb +12 -2
  65. data/lib/teaspoon/registry.rb +47 -0
  66. data/lib/teaspoon/registry/has_default.rb +11 -0
  67. data/lib/teaspoon/runner.rb +6 -7
  68. data/lib/teaspoon/server.rb +2 -2
  69. data/lib/teaspoon/suite.rb +28 -30
  70. data/lib/teaspoon/utility.rb +5 -0
  71. data/lib/teaspoon/version.rb +1 -1
  72. metadata +52 -276
  73. data/app/assets/javascripts/teaspoon-jasmine.js +0 -1344
  74. data/app/assets/javascripts/teaspoon-mocha.js +0 -1350
  75. data/app/assets/javascripts/teaspoon-qunit.js +0 -1415
  76. data/app/assets/javascripts/teaspoon-teaspoon.js +0 -51
  77. data/app/assets/javascripts/teaspoon/base/teaspoon.coffee +0 -69
  78. data/app/assets/javascripts/teaspoon/jasmine.coffee +0 -119
  79. data/app/assets/javascripts/teaspoon/jasmine/reporters/html.coffee +0 -11
  80. data/app/assets/javascripts/teaspoon/mocha.coffee +0 -90
  81. data/app/assets/javascripts/teaspoon/mocha/reporters/console.coffee +0 -16
  82. data/app/assets/javascripts/teaspoon/mocha/reporters/html.coffee +0 -27
  83. data/app/assets/javascripts/teaspoon/qunit.coffee +0 -81
  84. data/app/assets/javascripts/teaspoon/qunit/reporters/console.coffee +0 -25
  85. data/app/assets/javascripts/teaspoon/qunit/reporters/html.coffee +0 -80
  86. data/lib/generators/teaspoon/install/templates/jasmine/env.rb +0 -11
  87. data/lib/generators/teaspoon/install/templates/jasmine/spec_helper.coffee +0 -31
  88. data/lib/generators/teaspoon/install/templates/jasmine/spec_helper.js +0 -31
  89. data/lib/generators/teaspoon/install/templates/mocha/env.rb +0 -11
  90. data/lib/generators/teaspoon/install/templates/mocha/env_comments.rb.tt +0 -187
  91. data/lib/generators/teaspoon/install/templates/mocha/spec_helper.coffee +0 -40
  92. data/lib/generators/teaspoon/install/templates/mocha/spec_helper.js +0 -40
  93. data/lib/generators/teaspoon/install/templates/qunit/env.rb +0 -11
  94. data/lib/generators/teaspoon/install/templates/qunit/env_comments.rb.tt +0 -187
  95. data/lib/generators/teaspoon/install/templates/qunit/test_helper.coffee +0 -29
  96. data/lib/generators/teaspoon/install/templates/qunit/test_helper.js +0 -30
  97. data/lib/teaspoon/drivers/base.rb +0 -10
  98. data/lib/teaspoon/formatters/description.rb +0 -36
  99. data/lib/teaspoon/formatters/swayze_or_oprah_formatter.rb +0 -101
  100. data/spec/dummy/Rakefile +0 -7
  101. data/spec/dummy/app/assets/javascripts/instrumented1.coffee +0 -1
  102. data/spec/dummy/app/assets/javascripts/instrumented2.coffee +0 -1
  103. data/spec/dummy/app/assets/javascripts/integration/integration.coffee +0 -1
  104. data/spec/dummy/app/assets/javascripts/integration/integration_spec.coffee +0 -32
  105. data/spec/dummy/app/assets/javascripts/integration/spec_helper.coffee +0 -7
  106. data/spec/dummy/app/assets/javascripts/specs/asset_spec.js +0 -11
  107. data/spec/dummy/config.ru +0 -15
  108. data/spec/dummy/config/application.rb +0 -29
  109. data/spec/dummy/config/boot.rb +0 -3
  110. data/spec/dummy/config/environment.rb +0 -5
  111. data/spec/dummy/config/environments/development.rb +0 -41
  112. data/spec/dummy/config/environments/production.rb +0 -79
  113. data/spec/dummy/config/environments/test.rb +0 -42
  114. data/spec/dummy/config/routes.rb +0 -2
  115. data/spec/dummy/config/secrets.yml +0 -22
  116. data/spec/dummy/log/.gitkeep +0 -0
  117. data/spec/dummy/public/favicon.ico +0 -0
  118. data/spec/dummy/script/rails +0 -6
  119. data/spec/features/console_reporter_spec.rb +0 -62
  120. data/spec/features/hooks_spec.rb +0 -60
  121. data/spec/features/html_reporter_spec.rb +0 -81
  122. data/spec/features/install_generator_spec.rb +0 -54
  123. data/spec/features/instrumentation_spec.rb +0 -21
  124. data/spec/fixtures/coverage.json +0 -243
  125. data/spec/javascripts/fixtures/_body.html.erb +0 -1
  126. data/spec/javascripts/fixtures/fixture.html.haml +0 -4
  127. data/spec/javascripts/fixtures/fixture.json +0 -4
  128. data/spec/javascripts/jasmine_helper.coffee +0 -3
  129. data/spec/javascripts/mocha_helper.coffee +0 -4
  130. data/spec/javascripts/spec_helper.coffee +0 -7
  131. data/spec/javascripts/stylesheets/stylesheet.css.scss +0 -0
  132. data/spec/javascripts/support/json2.js +0 -486
  133. data/spec/javascripts/support/support.js.coffee +0 -0
  134. data/spec/javascripts/teaspoon/base/fixture_spec.coffee +0 -93
  135. data/spec/javascripts/teaspoon/base/reporters/console_spec.coffee +0 -162
  136. data/spec/javascripts/teaspoon/base/reporters/html/base_view_spec.coffee +0 -88
  137. data/spec/javascripts/teaspoon/base/reporters/html/failure_view_spec.coffee +0 -28
  138. data/spec/javascripts/teaspoon/base/reporters/html/progress_view_spec.coffee +0 -1
  139. data/spec/javascripts/teaspoon/base/reporters/html/spec_view_spec.coffee +0 -1
  140. data/spec/javascripts/teaspoon/base/reporters/html/suite_view_spec.coffee +0 -1
  141. data/spec/javascripts/teaspoon/base/reporters/html_spec.coffee +0 -372
  142. data/spec/javascripts/teaspoon/base/runner_spec.coffee +0 -58
  143. data/spec/javascripts/teaspoon/base/teaspoon_spec.coffee +0 -47
  144. data/spec/javascripts/teaspoon/jasmine/fixture_jspec.coffee +0 -13
  145. data/spec/javascripts/teaspoon/jasmine/models_jspec.coffee +0 -101
  146. data/spec/javascripts/teaspoon/jasmine/reporters/html_jspec.coffee +0 -17
  147. data/spec/javascripts/teaspoon/jasmine/runner_jspec.coffee +0 -59
  148. data/spec/javascripts/teaspoon/jasmine/spec_jspec.coffee +0 -3
  149. data/spec/javascripts/teaspoon/mocha/fixture_mspec.coffee +0 -12
  150. data/spec/javascripts/teaspoon/mocha/models_mspec.coffee +0 -93
  151. data/spec/javascripts/teaspoon/mocha/reporters/console_mspec.coffee +0 -24
  152. data/spec/javascripts/teaspoon/mocha/reporters/html_mspec.coffee +0 -41
  153. data/spec/javascripts/teaspoon/mocha/runner_mspec.coffee +0 -23
  154. data/spec/javascripts/teaspoon/mocha/spec_mspec.coffee +0 -9
  155. data/spec/javascripts/teaspoon/other/erb_spec.js.coffee.erb +0 -4
  156. data/spec/javascripts/teaspoon/phantomjs/runner_spec.coffee +0 -161
  157. data/spec/javascripts/turbolinks_helper.coffee +0 -2
  158. data/spec/spec_helper.rb +0 -25
  159. data/spec/support/aruba.rb +0 -15
  160. data/spec/teaspoon/command_line_spec.rb +0 -157
  161. data/spec/teaspoon/configuration_spec.rb +0 -236
  162. data/spec/teaspoon/console_spec.rb +0 -224
  163. data/spec/teaspoon/coverage_spec.rb +0 -118
  164. data/spec/teaspoon/drivers/base_spec.rb +0 -5
  165. data/spec/teaspoon/drivers/capybara_webkit_driver_spec.rb +0 -39
  166. data/spec/teaspoon/drivers/phantomjs_driver_spec.rb +0 -66
  167. data/spec/teaspoon/drivers/selenium_driver_spec.rb +0 -68
  168. data/spec/teaspoon/engine_spec.rb +0 -22
  169. data/spec/teaspoon/environment_spec.rb +0 -109
  170. data/spec/teaspoon/exceptions_spec.rb +0 -57
  171. data/spec/teaspoon/exporter_spec.rb +0 -96
  172. data/spec/teaspoon/formatters/base_spec.rb +0 -259
  173. data/spec/teaspoon/formatters/clean_formatter_spec.rb +0 -37
  174. data/spec/teaspoon/formatters/documentation_formatter_spec.rb +0 -127
  175. data/spec/teaspoon/formatters/dot_formatter_spec.rb +0 -116
  176. data/spec/teaspoon/formatters/json_formatter_spec.rb +0 -77
  177. data/spec/teaspoon/formatters/junit_formatter_spec.rb +0 -114
  178. data/spec/teaspoon/formatters/pride_formatter_spec.rb +0 -37
  179. data/spec/teaspoon/formatters/rspec_html_formatter_spec.rb +0 -107
  180. data/spec/teaspoon/formatters/snowday_formatter_spec.rb +0 -35
  181. data/spec/teaspoon/formatters/tap_formatter_spec.rb +0 -72
  182. data/spec/teaspoon/formatters/tap_y_formatter_spec.rb +0 -80
  183. data/spec/teaspoon/formatters/teamcity_formatter_spec.rb +0 -148
  184. data/spec/teaspoon/instrumentation_spec.rb +0 -113
  185. data/spec/teaspoon/result_spec.rb +0 -98
  186. data/spec/teaspoon/runner_spec.rb +0 -116
  187. data/spec/teaspoon/server_spec.rb +0 -105
  188. data/spec/teaspoon/suite_spec.rb +0 -138
  189. data/spec/teaspoon_env.rb +0 -39
  190. data/test/javascripts/qunit_helper.coffee +0 -3
  191. data/test/javascripts/teaspoon/qunit/fixture_test.coffee +0 -10
  192. data/test/javascripts/teaspoon/qunit/models_test.coffee +0 -66
  193. data/test/javascripts/teaspoon/qunit/reporters/console_test.coffee +0 -3
  194. data/test/javascripts/teaspoon/qunit/reporters/html/failure_view_test.coffee +0 -3
  195. data/test/javascripts/teaspoon/qunit/reporters/html/spec_view_test.coffee +0 -3
  196. data/test/javascripts/teaspoon/qunit/reporters/html/suite_view_test.coffee +0 -3
  197. data/test/javascripts/teaspoon/qunit/reporters/html_test.coffee +0 -3
  198. data/test/javascripts/teaspoon/qunit/runner_test.coffee +0 -18
  199. data/vendor/assets/javascripts/jasmine/1.3.1.js +0 -2602
  200. data/vendor/assets/javascripts/jasmine/2.0.0.js +0 -2412
  201. data/vendor/assets/javascripts/jasmine/MIT.LICENSE +0 -20
  202. data/vendor/assets/javascripts/mocha/1.10.0.js +0 -5374
  203. data/vendor/assets/javascripts/mocha/1.17.1.js +0 -5813
  204. data/vendor/assets/javascripts/mocha/MIT.LICENSE +0 -22
  205. data/vendor/assets/javascripts/qunit/1.12.0.js +0 -2212
  206. data/vendor/assets/javascripts/qunit/1.14.0.js +0 -2288
  207. data/vendor/assets/javascripts/qunit/MIT.LICENSE +0 -21
  208. data/vendor/assets/javascripts/support/chai-1.10.0.js +0 -4800
  209. data/vendor/assets/javascripts/support/chai-jq-0.0.7.js +0 -524
  210. data/vendor/assets/javascripts/support/chai.js +0 -4782
  211. data/vendor/assets/javascripts/support/expect.js +0 -1284
  212. data/vendor/assets/javascripts/support/jasmine-jquery-1.7.0.js +0 -720
  213. data/vendor/assets/javascripts/support/jasmine-jquery-2.0.0.js +0 -812
  214. data/vendor/assets/javascripts/support/sinon-chai.js +0 -126
@@ -1,68 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Teaspoon::Drivers::SeleniumDriver do
4
-
5
- describe "#initialize" do
6
-
7
- it "assigns @options" do
8
- subject = Teaspoon::Drivers::SeleniumDriver.new(foo: "bar")
9
- expect(subject.instance_variable_get(:@options)).to eq(foo: "bar")
10
- end
11
-
12
- it "accepts a string for options" do
13
- subject = Teaspoon::Drivers::SeleniumDriver.new('{"foo":"bar"}')
14
- expect(subject.instance_variable_get(:@options)).to eq("foo" => "bar")
15
- end
16
-
17
- it "raises a Teaspoon::UnknownDriverOptions exception if the options aren't understood" do
18
- expect { Teaspoon::Drivers::SeleniumDriver.new(true) }.to raise_error(Teaspoon::UnknownDriverOptions)
19
- end
20
-
21
- it "raises a Teaspoon::UnknownDriverOptions exception if the options aren't parseable" do
22
- expect { Teaspoon::Drivers::SeleniumDriver.new("{foo:bar}") }.to raise_error(Teaspoon::UnknownDriverOptions)
23
- end
24
-
25
- end
26
-
27
- describe "#run_specs" do
28
-
29
- let(:runner) { double }
30
-
31
- before do
32
- @driver = double(quit: nil, navigate: @navigate = double(to: nil), execute_script: 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
- end
36
-
37
- it "loads firefox for the webdriver" do
38
- expect(Selenium::WebDriver).to receive(:for).with(:firefox)
39
- subject.run_specs(runner, "_url_")
40
- end
41
-
42
- it "navigates to the correct url" do
43
- expect(@navigate).to receive(:to).with("_url_")
44
- subject.run_specs(runner, "_url_")
45
- end
46
-
47
- it "ensures quit is called on the driver" do
48
- expect(@driver).to receive(:quit)
49
- subject.run_specs(runner, "_url_")
50
- end
51
-
52
- it "waits for the specs to complete, setting the interval, timeout and message" do
53
- expect(Selenium::WebDriver::Wait).to receive(:new).with(HashWithIndifferentAccess.new(client_driver: :firefox, timeout: 180, interval: 0.01, message: "Timed out"))
54
- subject.run_specs(runner, "_url_")
55
- end
56
-
57
- it "waits until it's done (checking Teaspoon.finished) and processes each line" do
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
- subject.run_specs(runner, "_url_")
63
- @block.call
64
- end
65
-
66
- end
67
-
68
- end
@@ -1,22 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Teaspoon::Engine do
4
-
5
- subject { Teaspoon::Engine }
6
-
7
- it "has been isolated with a name" do
8
- expect(subject.isolated?).to be(true)
9
- expect(subject.railtie_name).to eql("teaspoon")
10
- end
11
-
12
- it "defaults the root path" do
13
- # this has to add spec/dummy as we set it manually
14
- expect(Teaspoon.configuration.root.join('spec/dummy').to_s).to eq(Rails.root.to_s)
15
- end
16
-
17
- it "adds asset paths from configuration" do
18
- expect(Rails.application.config.assets.paths).to include(Teaspoon.configuration.root.join("spec/javascripts").to_s)
19
- expect(Rails.application.config.assets.paths).to include(Teaspoon.configuration.root.join("spec/javascripts/stylesheets").to_s)
20
- end
21
-
22
- end
@@ -1,109 +0,0 @@
1
- require "spec_helper"
2
- require "teaspoon/environment"
3
-
4
- describe Teaspoon::Environment do
5
-
6
- subject { Teaspoon::Environment }
7
-
8
- describe ".load" do
9
-
10
- it "calls require_environment" do
11
- expect(subject).to receive(:require_environment)
12
- expect(subject).to receive(:rails_loaded?).and_return(true)
13
- Teaspoon::Environment.load
14
- end
15
-
16
- it "raises if Rails can't be found" do
17
- expect(subject).to receive(:require_environment)
18
- expect(subject).to receive(:rails_loaded?).and_return(false)
19
- expect{ Teaspoon::Environment.load }.to raise_error("Rails environment not found.")
20
- end
21
-
22
- it "configures teaspoon from options if the environment is ready" do
23
- expect(subject).to receive(:rails_loaded?).and_return(true)
24
- expect(Teaspoon.configuration).to receive(:override_from_options).with(foo: "bar")
25
- Teaspoon::Environment.load(foo: "bar")
26
- end
27
-
28
- end
29
-
30
- describe ".require_environment" do
31
-
32
- before do
33
- allow(File).to receive(:exists?)
34
- allow(subject).to receive(:require_env)
35
- Teaspoon.configured = false
36
- @orig_teaspoon_env = ENV['TEASPOON_ENV']
37
- ENV['TEASPOON_ENV'] = nil
38
- end
39
-
40
- after do
41
- Teaspoon.configured = true
42
- ENV['TEASPOON_ENV'] = @orig_teaspoon_env
43
- end
44
-
45
- describe "when loading with an override" do
46
-
47
- before do
48
- expect(subject).to receive(:require_env).and_call_original
49
- end
50
-
51
- it "allows passing an override" do
52
- expanded = File.expand_path("_override_", Dir.pwd)
53
- expect(::Kernel).to receive(:load).with(expanded)
54
- subject.require_environment("_override_")
55
- end
56
-
57
- it "sets the TEASPOON_ENV" do
58
- expanded = File.expand_path("../../_override_file_", Dir.pwd)
59
- expect(::Kernel).to receive(:load).with(expanded)
60
- subject.require_environment("../../_override_file_")
61
- expect(ENV["TEASPOON_ENV"]).to eq(expanded)
62
- end
63
-
64
- end
65
-
66
- describe "when loading from defaults" do
67
-
68
- it "looks for the standard files" do
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
- subject.require_environment
72
-
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
- subject.require_environment
77
-
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
- subject.require_environment
83
- end
84
-
85
- it "raises if no env file was found" do
86
- expect{ subject.require_environment }.to raise_error(Teaspoon::EnvironmentNotFound)
87
- end
88
-
89
- end
90
-
91
- end
92
-
93
- describe ".standard_environments" do
94
-
95
- it "returns an array" do
96
- expect(subject.standard_environments).to eql(["spec/teaspoon_env.rb", "test/teaspoon_env.rb", "teaspoon_env.rb"])
97
- end
98
-
99
- end
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
-
109
- end
@@ -1,57 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Teaspoon::ExceptionHandling do
4
-
5
- subject { Teaspoon::ExceptionHandling }
6
-
7
- before do
8
- @orig_debug = Rails.application.config.assets.debug
9
- @orig_show_exceptions = Rails.application.config.action_dispatch.show_exceptions
10
- end
11
-
12
- after do
13
- Rails.application.config.assets.debug = @orig_debug
14
- Rails.application.config.action_dispatch.show_exceptions = @orig_show_exceptions
15
- end
16
-
17
- describe ".add_rails_handling" do
18
-
19
- before do
20
- allow(subject).to receive(:render_exceptions_with_javascript)
21
- end
22
-
23
- it "sets config.assets.debug to false" do
24
- subject.add_rails_handling
25
- expect(Rails.application.config.assets.debug).to be_falsey
26
- end
27
-
28
- it "sets config.action_dispatch.show_exceptions to true" do
29
- subject.add_rails_handling
30
- expect(Rails.application.config.action_dispatch.show_exceptions).to be_truthy
31
- end
32
-
33
- it "calls #render_exceptions_with_javascript" do
34
- expect(subject).to receive(:render_exceptions_with_javascript)
35
- subject.add_rails_handling
36
- end
37
-
38
- end
39
-
40
- describe "ActionDispatch::DebugExceptions#render_exception mixin" do
41
-
42
- before do
43
- subject.add_rails_handling
44
- end
45
-
46
- let(:middleware) { ActionDispatch::DebugExceptions.new(app, nil) }
47
- let(:app) { double(:app) }
48
- let(:env) { double(:env, "[]" => []) }
49
-
50
- it "responds with a javascript tag that raises the error" do
51
- response = middleware.send(:render_exception, env, Exception.new("_message_"))
52
- expect(response).to eq([200, {"Content-Type"=>"text/html;", "Content-Length"=>"54"}, ["<script>throw Error(\"Exception: _message_\\n\")</script>"]])
53
- end
54
-
55
- end
56
-
57
- end
@@ -1,96 +0,0 @@
1
- require "spec_helper"
2
- require "teaspoon/exporter"
3
-
4
- describe Teaspoon::Exporter do
5
-
6
- subject { Teaspoon::Exporter.new(:suite_name, "http://666.420.42.0:31337/url/to/teaspoon", "_output_path_") }
7
-
8
- describe "#initialize" do
9
-
10
- it "assigns @suite and @url" do
11
- expect(subject.instance_variable_get(:@suite)).to eq(:suite_name)
12
- expect(subject.instance_variable_get(:@url)).to eq("http://666.420.42.0:31337/url/to/teaspoon")
13
- end
14
-
15
- it "expands the @output_path" do
16
- expected = File.join(File.expand_path("_output_path_"), "suite_name")
17
- expect(subject.instance_variable_get(:@output_path)).to eq(expected)
18
- end
19
-
20
- end
21
-
22
- describe "#export" do
23
-
24
- before do
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
- end
29
-
30
- it "makes a temp directory and cds to it" do
31
- expect(Dir).to receive(:chdir).with("_temp_path_")
32
- subject.export
33
- end
34
-
35
- it "executes the wget call and creates the export" do
36
- `(exit 0)`
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
- subject.export
41
- end
42
-
43
- it "raises a Teaspoon::ExporterException if the command failed for some reason" do
44
- `(exit 1)`
45
- expect(Dir).to receive(:chdir).with("_temp_path_").and_yield
46
- expect { subject.export }.to raise_error Teaspoon::ExporterException, "Unable to export suite_name suite."
47
- end
48
-
49
- it "raises a Teaspoon::MissingDependency if wget wasn't found" do
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
- expect { subject.export }.to raise_error Teaspoon::MissingDependency, "Could not find wget for exporting."
54
- end
55
-
56
- describe "creating the export" do
57
-
58
- before do
59
- `(exit 0)`
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
- end
69
-
70
- it "updates the relative paths" do
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
- subject.export
74
- end
75
-
76
- it "cleans up the old files" do
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
- subject.export
81
- end
82
-
83
- it "moves the files into the output path" do
84
- allow(subject).to receive(:cleanup_output)
85
- output_path = subject.instance_variable_get(:@output_path)
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
- subject.export
90
- end
91
-
92
- end
93
-
94
- end
95
-
96
- end
@@ -1,259 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Teaspoon::Formatters::Base do
4
-
5
- let(:passing_spec) { double(passing?: true) }
6
- let(:pending_spec) { double(passing?: false, pending?: true) }
7
- let(:failing_spec) { double(passing?: false, pending?: false) }
8
- let(:result) { double }
9
-
10
- before do
11
- @log = ""
12
- allow(STDOUT).to receive(:print) { |s| @log << s }
13
- end
14
-
15
- describe "#initialize" do
16
-
17
- subject { Teaspoon::Formatters::Base.new(:foo, "_output_file_") }
18
-
19
- before do
20
- allow(File).to receive(:open)
21
- end
22
-
23
- it "assigns various instance vars" do
24
- expect(subject.instance_variable_get(:@suite_name)).to eq("foo")
25
- expect(subject.instance_variable_get(:@output_file)).to eq("_output_file_")
26
- expect(subject.instance_variable_get(:@stdout)).to eq("")
27
- expect(subject.instance_variable_get(:@suite)).to eq(nil)
28
- expect(subject.instance_variable_get(:@last_suite)).to eq(nil)
29
- end
30
-
31
- it "assigns @total_count, @run_count, and arrays for tracking results" do
32
- expect(subject.total_count).to eq(0)
33
- expect(subject.run_count).to eq(0)
34
- expect(subject.passes).to eq([])
35
- expect(subject.pendings).to eq([])
36
- expect(subject.failures).to eq([])
37
- expect(subject.errors).to eq([])
38
- end
39
-
40
- it "writes a new output file if one is specified" do
41
- expect(File).to receive(:open).with("_output_file_", "w")
42
- subject
43
- end
44
-
45
- end
46
-
47
- describe "#runner" do
48
-
49
- let(:result) { double(total: 666) }
50
-
51
- it "sets @total_count" do
52
- subject.runner(result)
53
- expect(subject.total_count).to eq(666)
54
- end
55
-
56
- it "calls #log_runner when appropriate" do
57
- expect(subject).to receive(:log_runner).with(result)
58
- subject.runner(result)
59
-
60
- expect(subject).to_not receive(:log_runner)
61
- subject.runner(result, false)
62
- end
63
-
64
- end
65
-
66
- describe "#suite" do
67
-
68
- it "sets @suite, and @last_suite to the result" do
69
- subject.suite(result)
70
- expect(subject.instance_variable_get(:@suite)).to eq(result)
71
- expect(subject.instance_variable_get(:@last_suite)).to eq(result)
72
- end
73
-
74
- it "calls #log_suite when appropriate" do
75
- expect(subject).to receive(:log_suite).with(result)
76
- subject.suite(result)
77
-
78
- expect(subject).to_not receive(:log_suite)
79
- subject.suite(result, false)
80
- end
81
-
82
- end
83
-
84
- describe "#spec" do
85
-
86
- it "increments the run count" do
87
- subject.spec(failing_spec)
88
- expect(subject.run_count).to eq(1)
89
- subject.spec(failing_spec)
90
- expect(subject.run_count).to eq(2)
91
- end
92
-
93
- it "adds to the correct array on passing results" do
94
- subject.spec(passing_spec)
95
- expect(subject.run_count).to eq(1)
96
- expect(subject.passes).to eq([passing_spec])
97
- end
98
-
99
- it "adds to the correct array on pending results" do
100
- subject.spec(pending_spec)
101
- expect(subject.run_count).to eq(1)
102
- expect(subject.pendings).to eq([pending_spec])
103
- end
104
-
105
- it "adds to the correct array on failing results" do
106
- subject.spec(failing_spec)
107
- expect(subject.run_count).to eq(1)
108
- expect(subject.failures).to eq([failing_spec])
109
- end
110
-
111
- it "calls #log_spec when appropriate" do
112
- expect(subject).to receive(:log_spec).with(failing_spec)
113
- subject.spec(failing_spec)
114
-
115
- expect(subject).to_not receive(:log_spec)
116
- subject.spec(failing_spec, false)
117
- end
118
-
119
- it "clears @stdout" do
120
- subject.instance_variable_set(:@stdout, "----")
121
- subject.spec(failing_spec)
122
- expect(subject.instance_variable_get(:@stdout)).to eq("")
123
- end
124
-
125
- end
126
-
127
- describe "#error" do
128
-
129
- it "tracks the error" do
130
- subject.error(result)
131
- expect(subject.errors).to eq([result])
132
- end
133
-
134
- it "calls #log_error when appropriate" do
135
- expect(subject).to receive(:log_error).with(result)
136
- subject.error(result)
137
-
138
- expect(subject).to_not receive(:log_error)
139
- subject.error(result, false)
140
- end
141
-
142
- end
143
-
144
- describe "#exception" do
145
-
146
- it "calls #log_exception when appropriate" do
147
- expect(subject).to receive(:log_exception).with(result)
148
- subject.exception(result)
149
-
150
- expect(subject).to_not receive(:log_exception)
151
- subject.exception(result, false)
152
- end
153
-
154
- end
155
-
156
- describe "#console" do
157
-
158
- it "adds the string to @stdout" do
159
- subject.console("_message1_")
160
- subject.console("_message2_")
161
- expect(subject.instance_variable_get(:@stdout)).to eq("_message1__message2_")
162
- end
163
-
164
- it "calls #log_console when appropriate" do
165
- expect(subject).to receive(:log_console).with("_message_")
166
- subject.console("_message_")
167
-
168
- expect(subject).to_not receive(:log_console)
169
- subject.console("_message_", false)
170
- end
171
-
172
- end
173
-
174
- describe "#result" do
175
-
176
- let(:result) { double(coverage: nil) }
177
-
178
- it "calls #log_result when appropriate" do
179
- expect(subject).to receive(:log_result).with(result)
180
- subject.result(result)
181
-
182
- expect(subject).to_not receive(:log_result)
183
- subject.result(result, false)
184
- end
185
-
186
- end
187
-
188
- describe "#coverage" do
189
-
190
- it "calls #log_coverage when appropriate" do
191
- expect(subject).to receive(:log_coverage).with("_message_")
192
- subject.coverage("_message_")
193
-
194
- expect(subject).to receive(:log_coverage).with("_message_")
195
- subject.coverage("_message_")
196
- end
197
-
198
- end
199
-
200
- describe "#threshold_failure" do
201
-
202
- it "calls #log_threshold_failure when appropriate" do
203
- expect(subject).to receive(:log_threshold_failure).with("_message_")
204
- subject.threshold_failure("_message_")
205
-
206
- expect(subject).to receive(:log_threshold_failure).with("_message_")
207
- subject.threshold_failure("_message_")
208
- end
209
-
210
- end
211
-
212
- describe "#complete" do
213
-
214
- it "calls #log_complete when appropriate" do
215
- expect(subject).to receive(:log_complete).with(42)
216
- subject.complete(42)
217
-
218
- expect(subject).to receive(:log_complete).with(0)
219
- subject.complete(0)
220
- end
221
-
222
- end
223
-
224
- describe "#log_spec" do
225
-
226
- it "calls #log_passing_spec on passing results" do
227
- expect(subject).to receive(:log_passing_spec).with(passing_spec)
228
- subject.send(:log_spec, passing_spec)
229
- end
230
-
231
- it "calls #log_pending_spec on pending results" do
232
- expect(subject).to receive(:log_pending_spec).with(pending_spec)
233
- subject.send(:log_spec, pending_spec)
234
- end
235
-
236
- it "calls #log_failing_spec on failing results" do
237
- expect(subject).to receive(:log_failing_spec).with(failing_spec)
238
- subject.send(:log_spec, failing_spec)
239
- end
240
-
241
- end
242
-
243
- describe "logging to file" do
244
-
245
- it "logs to a file" do
246
- handle = double(write: nil)
247
- expect(File).to receive(:open).with("_output_file_", "a").and_yield(handle)
248
- expect(handle).to receive(:write).with("_str_")
249
- subject.send(:log_to_file, "_str_", "_output_file_")
250
- end
251
-
252
- it "raises a Teaspoon::FileNotWritable exception if the file can't be written to" do
253
- expect(File).to receive(:open).and_raise(IOError, "_io_error_message_")
254
- expect { subject.send(:log_to_file, "_str_", "_output_file_") }.to raise_error(Teaspoon::FileNotWritable, "_io_error_message_")
255
- end
256
-
257
- end
258
-
259
- end