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