teaspoon 0.7.9 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +382 -260
  3. data/app/assets/javascripts/teaspoon-angular.js +108 -26241
  4. data/app/assets/javascripts/teaspoon-jasmine.js +103 -2642
  5. data/app/assets/javascripts/teaspoon-mocha.js +109 -5416
  6. data/app/assets/javascripts/teaspoon-qunit.js +107 -2255
  7. data/app/assets/javascripts/teaspoon-teaspoon.js +0 -1
  8. data/app/assets/javascripts/teaspoon/angular.coffee +3 -1
  9. data/app/assets/javascripts/teaspoon/base/hook.coffee +21 -0
  10. data/app/assets/javascripts/teaspoon/base/reporters/html.coffee +26 -14
  11. data/app/assets/javascripts/teaspoon/base/reporters/html/progress_view.coffee +1 -1
  12. data/app/assets/javascripts/teaspoon/base/reporters/html/template.coffee +3 -3
  13. data/app/assets/javascripts/teaspoon/base/teaspoon.coffee +10 -1
  14. data/app/assets/javascripts/teaspoon/jasmine.coffee +3 -1
  15. data/app/assets/javascripts/teaspoon/mocha.coffee +3 -1
  16. data/app/assets/javascripts/teaspoon/mocha/reporters/html.coffee +1 -1
  17. data/app/assets/javascripts/teaspoon/qunit.coffee +3 -1
  18. data/app/assets/javascripts/teaspoon/qunit/reporters/html.coffee +1 -1
  19. data/app/assets/javascripts/teaspoon/teaspoon.coffee +0 -1
  20. data/app/assets/stylesheets/teaspoon.css +12 -8
  21. data/app/controllers/teaspoon/suite_controller.rb +32 -0
  22. data/app/views/teaspoon/suite/_body.html.erb +0 -0
  23. data/app/views/teaspoon/suite/_boot.html.erb +4 -0
  24. data/app/views/teaspoon/suite/_boot_require_js.html.erb +19 -0
  25. data/app/views/teaspoon/{spec/suites.html.erb → suite/index.html.erb} +6 -7
  26. data/app/views/teaspoon/suite/show.html.erb +19 -0
  27. data/bin/teaspoon +1 -1
  28. data/config/routes.rb +14 -4
  29. data/lib/generators/teaspoon/install/POST_INSTALL +2 -2
  30. data/lib/generators/teaspoon/install/install_generator.rb +22 -11
  31. data/lib/generators/teaspoon/install/templates/_body.html.erb +0 -0
  32. data/lib/generators/teaspoon/install/templates/_boot.html.erb +4 -0
  33. data/lib/generators/teaspoon/install/templates/jasmine/env.rb +11 -0
  34. data/lib/generators/teaspoon/install/templates/jasmine/env_comments.rb +182 -0
  35. data/lib/generators/teaspoon/install/templates/jasmine/spec_helper.coffee +8 -6
  36. data/lib/generators/teaspoon/install/templates/jasmine/spec_helper.js +8 -7
  37. data/lib/generators/teaspoon/install/templates/mocha/env.rb +11 -0
  38. data/lib/generators/teaspoon/install/templates/mocha/env_comments.rb +182 -0
  39. data/lib/generators/teaspoon/install/templates/mocha/spec_helper.coffee +13 -13
  40. data/lib/generators/teaspoon/install/templates/mocha/spec_helper.js +13 -13
  41. data/lib/generators/teaspoon/install/templates/qunit/env.rb +11 -0
  42. data/lib/generators/teaspoon/install/templates/qunit/env_comments.rb +182 -0
  43. data/lib/generators/teaspoon/install/templates/qunit/test_helper.coffee +6 -5
  44. data/lib/generators/teaspoon/install/templates/qunit/test_helper.js +6 -5
  45. data/lib/tasks/teaspoon.rake +9 -2
  46. data/lib/teaspoon.rb +4 -6
  47. data/lib/teaspoon/command_line.rb +116 -134
  48. data/lib/teaspoon/configuration.rb +144 -66
  49. data/lib/teaspoon/console.rb +70 -37
  50. data/lib/teaspoon/coverage.rb +42 -15
  51. data/lib/teaspoon/deprecated.rb +65 -0
  52. data/lib/teaspoon/drivers/base.rb +10 -0
  53. data/lib/teaspoon/drivers/phantomjs/runner.js +9 -11
  54. data/lib/teaspoon/drivers/phantomjs_driver.rb +21 -21
  55. data/lib/teaspoon/drivers/selenium_driver.rb +32 -13
  56. data/lib/teaspoon/engine.rb +32 -12
  57. data/lib/teaspoon/environment.rb +16 -12
  58. data/lib/teaspoon/exceptions.rb +41 -5
  59. data/lib/teaspoon/exporter.rb +52 -0
  60. data/lib/teaspoon/formatters/base.rb +171 -0
  61. data/lib/teaspoon/formatters/clean_formatter.rb +2 -4
  62. data/lib/teaspoon/formatters/documentation_formatter.rb +60 -0
  63. data/lib/teaspoon/formatters/dot_formatter.rb +12 -90
  64. data/lib/teaspoon/formatters/json_formatter.rb +36 -0
  65. data/lib/teaspoon/formatters/junit_formatter.rb +51 -32
  66. data/lib/teaspoon/formatters/modules/report_module.rb +76 -0
  67. data/lib/teaspoon/formatters/pride_formatter.rb +23 -27
  68. data/lib/teaspoon/formatters/snowday_formatter.rb +7 -11
  69. data/lib/teaspoon/formatters/swayze_or_oprah_formatter.rb +88 -64
  70. data/lib/teaspoon/formatters/tap_formatter.rb +18 -27
  71. data/lib/teaspoon/formatters/tap_y_formatter.rb +35 -45
  72. data/lib/teaspoon/formatters/teamcity_formatter.rb +69 -31
  73. data/lib/teaspoon/instrumentation.rb +33 -33
  74. data/lib/teaspoon/result.rb +2 -1
  75. data/lib/teaspoon/runner.rb +40 -28
  76. data/lib/teaspoon/server.rb +23 -25
  77. data/lib/teaspoon/suite.rb +52 -72
  78. data/lib/teaspoon/utility.rb +3 -14
  79. data/lib/teaspoon/version.rb +1 -1
  80. data/spec/dummy/app/assets/javascripts/integration/integration_spec.coffee +3 -0
  81. data/spec/dummy/app/assets/javascripts/integration/spec_helper.coffee +2 -0
  82. data/spec/dummy/config/application.rb +3 -0
  83. data/spec/features/console_reporter_spec.rb +48 -18
  84. data/spec/features/hooks_spec.rb +23 -41
  85. data/spec/features/html_reporter_spec.rb +38 -21
  86. data/spec/features/install_generator_spec.rb +34 -20
  87. data/spec/features/instrumentation_spec.rb +3 -2
  88. data/spec/fixtures/coverage.json +243 -0
  89. data/spec/javascripts/fixtures/_body.html.erb +1 -0
  90. data/spec/javascripts/jasmine_helper.coffee +1 -1
  91. data/spec/javascripts/teaspoon/base/fixture_spec.coffee +4 -4
  92. data/spec/javascripts/teaspoon/base/reporters/html_spec.coffee +9 -10
  93. data/spec/javascripts/teaspoon/mocha/reporters/html_mspec.coffee +0 -6
  94. data/spec/javascripts/teaspoon/phantomjs/runner_spec.coffee +5 -6
  95. data/spec/javascripts/turbolinks_helper.coffee +1 -1
  96. data/spec/spec_helper.rb +3 -4
  97. data/spec/teaspoon/command_line_spec.rb +139 -23
  98. data/spec/teaspoon/configuration_spec.rb +164 -46
  99. data/spec/teaspoon/console_spec.rb +142 -47
  100. data/spec/teaspoon/coverage_spec.rb +98 -28
  101. data/spec/teaspoon/drivers/base_spec.rb +5 -0
  102. data/spec/teaspoon/drivers/phantomjs_driver_spec.rb +32 -14
  103. data/spec/teaspoon/drivers/selenium_driver_spec.rb +32 -24
  104. data/spec/teaspoon/engine_spec.rb +8 -5
  105. data/spec/teaspoon/environment_spec.rb +56 -33
  106. data/spec/teaspoon/exceptions_spec.rb +57 -0
  107. data/spec/teaspoon/exporter_spec.rb +96 -0
  108. data/spec/teaspoon/formatters/base_spec.rb +259 -0
  109. data/spec/teaspoon/formatters/clean_formatter_spec.rb +37 -0
  110. data/spec/teaspoon/formatters/documentation_formatter_spec.rb +127 -0
  111. data/spec/teaspoon/formatters/dot_formatter_spec.rb +52 -56
  112. data/spec/teaspoon/formatters/json_formatter_spec.rb +77 -0
  113. data/spec/teaspoon/formatters/junit_formatter_spec.rb +72 -35
  114. data/spec/teaspoon/formatters/pride_formatter_spec.rb +37 -0
  115. data/spec/teaspoon/formatters/snowday_formatter_spec.rb +35 -0
  116. data/spec/teaspoon/formatters/tap_formatter_spec.rb +29 -81
  117. data/spec/teaspoon/formatters/tap_y_formatter_spec.rb +31 -141
  118. data/spec/teaspoon/formatters/teamcity_formatter_spec.rb +99 -42
  119. data/spec/teaspoon/instrumentation_spec.rb +44 -44
  120. data/spec/teaspoon/result_spec.rb +37 -0
  121. data/spec/teaspoon/runner_spec.rb +70 -59
  122. data/spec/teaspoon/server_spec.rb +34 -52
  123. data/spec/teaspoon/suite_spec.rb +42 -188
  124. data/spec/teaspoon_env.rb +39 -28
  125. data/vendor/assets/javascripts/{angular-scenario-1.0.5.js → angular/1.0.5.js} +0 -0
  126. data/vendor/assets/javascripts/{angular-scenario-1.0.5.MIT-LICENSE → angular/MIT-LICENSE} +0 -0
  127. data/vendor/assets/javascripts/{jasmine-1.3.1.js → jasmine/1.3.1.js} +0 -0
  128. data/vendor/assets/javascripts/jasmine/2.0.0.js +2412 -0
  129. data/vendor/assets/javascripts/{jasmine-1.3.1.MIT.LICENSE → jasmine/MIT.LICENSE} +0 -0
  130. data/vendor/assets/javascripts/{mocha-1.10.0.js → mocha/1.10.0.js} +1 -0
  131. data/vendor/assets/javascripts/mocha/1.17.1.js +5813 -0
  132. data/vendor/assets/javascripts/{mocha-1.10.1.MIT.LICENSE → mocha/MIT.LICENSE} +0 -0
  133. data/vendor/assets/javascripts/{qunit-1.12.0.js → qunit/1.12.0.js} +1 -1
  134. data/vendor/assets/javascripts/qunit/1.14.0.js +2288 -0
  135. data/vendor/assets/javascripts/{qunit-1.12.0.MIT.LICENSE → qunit/MIT.LICENSE} +0 -0
  136. data/vendor/assets/javascripts/support/chai.js +827 -385
  137. data/vendor/assets/javascripts/support/jasmine-jquery-1.7.0.js +720 -0
  138. data/vendor/assets/javascripts/support/jasmine-jquery-2.0.0.js +812 -0
  139. data/vendor/assets/javascripts/support/sinon-chai.js +17 -0
  140. data/vendor/assets/javascripts/support/sinon.js +1138 -643
  141. metadata +57 -36
  142. data/app/controllers/teaspoon/spec_controller.rb +0 -38
  143. data/app/helpers/teaspoon/spec_helper.rb +0 -36
  144. data/app/views/teaspoon/spec/_require_js.html.erb +0 -21
  145. data/app/views/teaspoon/spec/_standard.html.erb +0 -4
  146. data/app/views/teaspoon/spec/runner.html.erb +0 -19
  147. data/lib/generators/teaspoon/install/templates/env.rb +0 -38
  148. data/lib/generators/teaspoon/install/templates/jasmine/initializer.rb +0 -64
  149. data/lib/generators/teaspoon/install/templates/mocha/initializer.rb +0 -64
  150. data/lib/generators/teaspoon/install/templates/qunit/initializer.rb +0 -64
  151. data/lib/teaspoon/check_coverage.rb +0 -33
  152. data/lib/teaspoon/drivers/base_driver.rb +0 -10
  153. data/lib/teaspoon/exception_handling.rb +0 -18
  154. data/lib/teaspoon/formatters/base_formatter.rb +0 -63
  155. data/spec/dummy/config/initializers/teaspoon.rb +0 -41
  156. data/spec/teaspoon/check_coverage_spec.rb +0 -50
  157. data/spec/teaspoon/formatters/base_formatter_spec.rb +0 -45
  158. data/vendor/assets/javascripts/support/chai.MIT.LICENSE +0 -22
  159. data/vendor/assets/javascripts/support/expect.MIT.LICENSE +0 -22
  160. data/vendor/assets/javascripts/support/jasmine-jquery.MIT.LICENSE +0 -20
  161. data/vendor/assets/javascripts/support/jasmine-jquery.js +0 -659
  162. data/vendor/assets/javascripts/support/sinon-chai.MIT-ISH.LICENSE +0 -13
  163. data/vendor/assets/javascripts/support/sinon.BSD.LICENSE +0 -27
@@ -0,0 +1,37 @@
1
+ require "spec_helper"
2
+
3
+ describe Teaspoon::Formatters::CleanFormatter do
4
+
5
+ let(:passing_spec) { double(passing?: true) }
6
+ let(:pending_spec) { double(passing?: false, pending?: true, description: "_description_") }
7
+ let(:failing_spec) { double(passing?: false, pending?: false, description: "_description_", message: "_message_", link: "_link_") }
8
+
9
+ before do
10
+ @log = ""
11
+ STDOUT.stub(:print) { |s| @log << s }
12
+ end
13
+
14
+ describe "#result" do
15
+
16
+ let(:result) { double(elapsed: 3.1337, coverage: nil) }
17
+
18
+ before do
19
+ subject.run_count = 666
20
+ end
21
+
22
+ describe "with failures" do
23
+
24
+ before do
25
+ subject.failures << failing_spec
26
+ end
27
+
28
+ it "logs the failures but not the failure commands" do
29
+ subject.result(result)
30
+ expect(@log).to eq("\n\nFailures:\n\n 1) _description_\n\e[31m Failure/Error: _message_\n\e[0m\nFinished in 3.1337 seconds\n\e[31m666 examples, 1 failure\e[0m\n")
31
+ end
32
+
33
+ end
34
+
35
+ end
36
+
37
+ end
@@ -0,0 +1,127 @@
1
+ require "spec_helper"
2
+
3
+ describe Teaspoon::Formatters::DocumentationFormatter do
4
+
5
+ let(:suite) { double(label: "_suite_", level: @level || 0)}
6
+ let(:passing_spec) { double(passing?: true, label: "_passing_") }
7
+ let(:pending_spec) { double(passing?: false, pending?: true, label: "_pending_", description: "_description_") }
8
+ let(:failing_spec) { double(passing?: false, pending?: false, label: "_failing_", description: "_description_", message: "_message_", link: "_link_") }
9
+
10
+ before do
11
+ @log = ""
12
+ STDOUT.stub(:print) { |s| @log << s }
13
+ end
14
+
15
+ describe "#suite" do
16
+
17
+ it "logs a properly indented suite message" do
18
+ @level = 2
19
+ subject.suite(suite)
20
+ expect(@log).to eq(" _suite_\n")
21
+ expect(subject.instance_variable_get(:@level)).to eq(2)
22
+ end
23
+
24
+ end
25
+
26
+ describe "#spec" do
27
+
28
+ before do
29
+ subject.instance_variable_set(:@level, 1)
30
+ subject.instance_variable_set(:@last_suite, {})
31
+ subject.instance_variable_set(:@stdout, "line1\nline2\n")
32
+ end
33
+
34
+ it "logs an indented green label on passing results" do
35
+ subject.spec(passing_spec)
36
+ expect(@log).to eq("\e[32m _passing_\e[0m\n\e[36m # line1\n # line2\e[0m\n")
37
+ end
38
+
39
+ it "logs an indented yellow label on pending results" do
40
+ subject.instance_variable_set(:@level, 1)
41
+ subject.instance_variable_set(:@last_suite, {})
42
+ subject.spec(pending_spec)
43
+ expect(@log).to eq("\e[33m _pending_ (PENDING)\e[0m\n\e[36m # line1\n # line2\e[0m\n")
44
+ end
45
+
46
+ it "logs an indented red label (with stdout) on failing results" do
47
+ subject.spec(failing_spec)
48
+ expect(@log).to eq("\e[31m _failing_ (FAILED - 1)\e[0m\n\e[36m # line1\n # line2\e[0m\n")
49
+ end
50
+
51
+ end
52
+
53
+ describe "#error" do
54
+
55
+ let(:result) { double(message: "_message_", trace: [{"file" => "http://127.0.0.1:31337/assets/path/file.js?foo=true&body=1", "line" => 42, "function" => "notAnAnonFunc"}]) }
56
+
57
+ it "logs the error" do
58
+ subject.error(result)
59
+ expect(@log).to eq("\e[31m_message_\e[0m\n\e[36m # path/file.js?foo=true:42 -- notAnAnonFunc\e[0m\n\n")
60
+ end
61
+
62
+ end
63
+
64
+ describe "#result" do
65
+
66
+ let(:result) { double(elapsed: 3.1337, coverage: nil) }
67
+
68
+ before do
69
+ subject.run_count = 666
70
+ end
71
+
72
+ describe "with no failures" do
73
+
74
+ it "logs the stats" do
75
+ subject.result(result)
76
+ expect(@log).to eq("\nFinished in 3.1337 seconds\n\e[32m666 examples, 0 failures\e[0m\n")
77
+ end
78
+
79
+ end
80
+
81
+ describe "with failures" do
82
+
83
+ before do
84
+ subject.failures << failing_spec
85
+ end
86
+
87
+ it "logs the failures" do
88
+ subject.result(result)
89
+ expect(@log).to eq("\nFailures:\n\n 1) _description_\n\e[31m Failure/Error: _message_\n\e[0m\nFinished in 3.1337 seconds\n\e[31m666 examples, 1 failure\e[0m\n\nFailed examples:\n\n\e[31mteaspoon -s default --filter=\"_link_\"\e[0m\n")
90
+ end
91
+
92
+ end
93
+
94
+ describe "with pending" do
95
+
96
+ before do
97
+ subject.pendings << pending_spec
98
+ end
99
+
100
+ it "logs the pending specs" do
101
+ subject.result(result)
102
+ expect(@log).to eq("\nPending:\n\e[33m _description_\e[0m\n\e[36m # Not yet implemented\n\e[0m\nFinished in 3.1337 seconds\n\e[33m666 examples, 0 failures, 1 pending\e[0m\n")
103
+ end
104
+
105
+ end
106
+
107
+ end
108
+
109
+ describe "#coverage" do
110
+
111
+ it "logs the coverage" do
112
+ subject.coverage("_text_\n\n_text_summary_")
113
+ expect(@log).to eq("\n_text_\n\n_text_summary_\n")
114
+ end
115
+
116
+ end
117
+
118
+ describe "#threshold_failure" do
119
+
120
+ it "logs the threshold failures" do
121
+ subject.threshold_failure("_was_not_met_\n_was_not_met_")
122
+ expect(@log).to eq("\e[31m\n_was_not_met_\n_was_not_met_\n\e[0m\n")
123
+ end
124
+
125
+ end
126
+
127
+ end
@@ -1,9 +1,11 @@
1
1
  require "spec_helper"
2
- require "teaspoon/formatters/dot_formatter"
3
- require "teaspoon/result"
4
2
 
5
3
  describe Teaspoon::Formatters::DotFormatter do
6
4
 
5
+ let(:passing_spec) { double(passing?: true) }
6
+ let(:pending_spec) { double(passing?: false, pending?: true, description: "_description_") }
7
+ let(:failing_spec) { double(passing?: false, pending?: false, description: "_description_", message: "_message_", link: "_link_") }
8
+
7
9
  before do
8
10
  @log = ""
9
11
  STDOUT.stub(:print) { |s| @log << s }
@@ -11,110 +13,104 @@ describe Teaspoon::Formatters::DotFormatter do
11
13
 
12
14
  describe "#spec" do
13
15
 
14
- it "tracks totals" do
15
- subject.total = 41
16
- subject.should_receive(:log).with(".", 32)
17
- subject.spec(Teaspoon::Result.build_from_json("status" => "passed"))
18
- expect(subject.total).to be(42)
19
- end
20
-
21
- it "logs a green . on pass" do
22
- subject.should_receive(:log).with(".", 32)
23
- subject.spec(Teaspoon::Result.build_from_json("status" => "passed"))
16
+ it "logs a green . on passing results" do
17
+ subject.spec(passing_spec)
18
+ expect(@log).to eq("\e[32m.\e[0m")
24
19
  end
25
20
 
26
- it "logs a yellow * on pending" do
27
- subject.should_receive(:log).with("*", 33)
28
- subject.spec(Teaspoon::Result.build_from_json("status" => "pending"))
21
+ it "logs a yellow * on pending results" do
22
+ subject.spec(pending_spec)
23
+ expect(@log).to eq("\e[33m*\e[0m")
29
24
  end
30
25
 
31
- it "logs a red F on anything else" do
32
- subject.should_receive(:log).with("F", 31)
33
- subject.spec(Teaspoon::Result.build_from_json("status" => "foo"))
26
+ it "logs a red F on failing results" do
27
+ subject.spec(failing_spec)
28
+ expect(@log).to eq("\e[31mF\e[0m")
34
29
  end
35
30
 
36
31
  end
37
32
 
38
33
  describe "#error" do
39
34
 
35
+ let(:result) { double(message: "_message_", trace: [{"file" => "http://127.0.0.1:31337/assets/path/file.js?foo=true&body=1", "line" => 42, "function" => "notAnAnonFunc"}]) }
36
+
40
37
  it "logs the error" do
41
- trace = {"file" => "http://127.0.0.1:31337/assets/path/file.js?foo=true&body=1", "line" => 42, "function" => "notAnAnonFunc"}
42
- subject.error("message" => "_message_", "trace" => [trace])
43
- expect(@log).to eq("\e[31m_message_\n\e[0m\e[36m # path/file.js?foo=true:42 -- notAnAnonFunc\n\e[0m\n")
38
+ subject.error(result)
39
+ expect(@log).to eq("\e[31m_message_\e[0m\n\e[36m # path/file.js?foo=true:42 -- notAnAnonFunc\e[0m\n\n")
40
+ end
41
+
42
+ end
43
+
44
+ describe "#console" do
45
+
46
+ it "logs the message" do
47
+ subject.console("_message_\n")
48
+ expect(@log).to eq("_message_\n")
44
49
  end
45
50
 
46
51
  end
47
52
 
48
53
  describe "#result" do
49
54
 
55
+ let(:result) { double(elapsed: 3.1337, coverage: nil) }
56
+
50
57
  before do
51
- subject.total = 666
58
+ subject.run_count = 666
52
59
  end
53
60
 
54
61
  describe "with no failures" do
55
62
 
56
- it "logs the details" do
57
- subject.result("elapsed" => 0.31337)
58
- expect(@log).to eq("\n\nFinished in 0.31337 seconds\n\e[32m666 examples, 0 failures\n\e[0m")
63
+ it "logs the stats" do
64
+ subject.result(result)
65
+ expect(@log).to eq("\n\nFinished in 3.1337 seconds\n\e[32m666 examples, 0 failures\e[0m\n")
59
66
  end
60
67
 
61
68
  end
62
69
 
63
70
  describe "with failures" do
64
71
 
65
- it "logs the details and raises an exception" do
66
- subject.failures << Teaspoon::Result.build_from_json("label" => "some spec", "suite" => "full description", "message" => "some message", "link" => "full description")
67
- expect{
68
- subject.result("elapsed" => 0.31337)
69
- }.to raise_error(Teaspoon::Failure)
70
- expect(@log).to eq("\n\nFailures:\n\n 1) full description some spec\n\e[31m Failure/Error: some message\n\n\e[0mFinished in 0.31337 seconds\n\e[31m666 examples, 1 failure\n\e[0m\nFailed examples:\n\n\e[31mteaspoon -s default --filter=\"full description\"\n\e[0m\n")
71
- expect(subject.failures.length).to be(1)
72
+ before do
73
+ subject.failures << failing_spec
72
74
  end
73
75
 
74
- describe "when fail_fast is false" do
75
-
76
- it "doesn't raise the exception" do
77
- Teaspoon.configuration.should_receive(:fail_fast).and_return(false)
78
- subject.failures << Teaspoon::Result.build_from_json("message" => "some message")
79
- subject.result("elapsed" => 0.31337)
80
- expect(subject.failures.length).to be(1)
81
- end
82
-
76
+ it "logs the failures" do
77
+ subject.result(result)
78
+ expect(@log).to eq("\n\nFailures:\n\n 1) _description_\n\e[31m Failure/Error: _message_\n\e[0m\nFinished in 3.1337 seconds\n\e[31m666 examples, 1 failure\e[0m\n\nFailed examples:\n\n\e[31mteaspoon -s default --filter=\"_link_\"\e[0m\n")
83
79
  end
84
80
 
85
81
  end
86
82
 
87
83
  describe "with pending" do
88
84
 
89
- it "logs the details" do
90
- subject.pendings << Teaspoon::Result.build_from_json("label" => "some spec", "suite" => "full description")
91
- subject.result("elapsed" => 0.31337)
92
- expect(@log).to eq("\n\nPending:\n\e[33m full description some spec\n\e[0m\e[36m # Not yet implemented\n\n\e[0mFinished in 0.31337 seconds\n\e[33m666 examples, 0 failures, 1 pending\n\e[0m")
85
+ before do
86
+ subject.pendings << pending_spec
87
+ end
88
+
89
+ it "logs the pending specs" do
90
+ subject.result(result)
91
+ expect(@log).to eq("\n\nPending:\n\e[33m _description_\e[0m\n\e[36m # Not yet implemented\n\e[0m\nFinished in 3.1337 seconds\n\e[33m666 examples, 0 failures, 1 pending\e[0m\n")
93
92
  end
94
93
 
95
94
  end
96
95
 
97
96
  end
98
97
 
99
- describe "#exception" do
98
+ describe "#coverage" do
100
99
 
101
- it "raises" do
102
- expect{ subject.exception }.to raise_error(Teaspoon::RunnerException)
100
+ it "logs the coverage" do
101
+ subject.coverage("_text_\n\n_text_summary_")
102
+ expect(@log).to eq("\n_text_\n\n_text_summary_\n")
103
103
  end
104
104
 
105
105
  end
106
106
 
107
- describe "#log" do
107
+ describe "#threshold_failure" do
108
108
 
109
- it "calls STDOUT.write" do
110
- STDOUT.should_receive(:print).with("foo")
111
- subject.send(:log, "foo")
109
+ it "logs the threshold failures" do
110
+ subject.threshold_failure("_was_not_met_\n_was_not_met_")
111
+ expect(@log).to eq("\e[31m\n_was_not_met_\n_was_not_met_\n\e[0m\n")
112
112
  end
113
113
 
114
- it "colorizes" do
115
- STDOUT.should_receive(:print).with("\e[31mfoo\e[0m")
116
- subject.send(:log, "foo", 31)
117
- end
118
114
  end
119
115
 
120
116
  end
@@ -0,0 +1,77 @@
1
+ require "spec_helper"
2
+
3
+ describe Teaspoon::Formatters::JsonFormatter do
4
+
5
+ let(:hash) { {original_json: "_original_json_"} }
6
+ let(:result) { double(hash) }
7
+
8
+ describe "#runner" do
9
+
10
+ let(:result) { double(hash.merge(total: 42)) }
11
+
12
+ it "logs the original json" do
13
+ subject.should_receive(:log_result).with(result)
14
+ subject.runner(result)
15
+ end
16
+
17
+ end
18
+
19
+ describe "#suite" do
20
+
21
+ it "logs the original json" do
22
+ subject.should_receive(:log_result).with(result)
23
+ subject.suite(result)
24
+ end
25
+
26
+ end
27
+
28
+ describe "#spec" do
29
+
30
+ let(:result) { double(hash.merge(passing?: true)) }
31
+
32
+ it "logs the original json" do
33
+ subject.should_receive(:log_result).with(result)
34
+ subject.spec(result)
35
+ end
36
+
37
+ end
38
+
39
+ describe "#error" do
40
+
41
+ it "logs the original json" do
42
+ subject.should_receive(:log_result).with(result)
43
+ subject.error(result)
44
+ end
45
+
46
+ end
47
+
48
+ describe "#exception" do
49
+
50
+ it "logs the original json" do
51
+ subject.should_receive(:log_result).with(result)
52
+ subject.exception(result)
53
+ end
54
+
55
+ end
56
+
57
+ describe "#console" do
58
+
59
+ it "logs the message as json" do
60
+ subject.should_receive(:log_line).with(%Q{{"type":"console","log":"_message_"}})
61
+ subject.console("_message_")
62
+ end
63
+
64
+ end
65
+
66
+ describe "#result" do
67
+
68
+ let(:result) { double(hash.merge(coverage: nil)) }
69
+
70
+ it "logs the original json" do
71
+ subject.should_receive(:log_str).with("_original_json_")
72
+ subject.result(result)
73
+ end
74
+
75
+ end
76
+
77
+ end
@@ -1,9 +1,11 @@
1
1
  require "spec_helper"
2
- require "teaspoon/formatters/junit_formatter"
3
- require "teaspoon/result"
4
2
 
5
3
  describe Teaspoon::Formatters::JunitFormatter do
6
4
 
5
+ let(:passing_spec) { double(passing?: true, suite: "_suite_name_", label: "_passing_label_") }
6
+ let(:pending_spec) { double(passing?: false, pending?: true, suite: "_suite_name_", label: "_pending_label_") }
7
+ let(:failing_spec) { double(passing?: false, pending?: false, suite: "_suite_name_", label: "_failing&label_", message: "_failure_message_") }
8
+
7
9
  before do
8
10
  @log = ""
9
11
  STDOUT.stub(:print) { |s| @log << s }
@@ -11,65 +13,100 @@ describe Teaspoon::Formatters::JunitFormatter do
11
13
 
12
14
  describe "#runner" do
13
15
 
14
- let(:json) { {"start" => "_start_", "total" => 20} }
16
+ let(:result) { double(start: "_start_", total: 42) }
17
+
18
+ before do
19
+ subject.instance_variable_set(:@suite_name, "not_default")
20
+ end
15
21
 
16
- it "logs the information" do
17
- result = Teaspoon::Result.build_from_json(json)
18
- subject.should_receive(:log).with("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")
19
- subject.should_receive(:log).with("<testsuites name=\"jasmine\"><testsuite name=\"\" tests=\"20\">")
22
+ it "starts the suite" do
20
23
  subject.runner(result)
24
+ expect(@log).to eq(%Q{<?xml version="1.0" encoding="UTF-8"?>\n<testsuites name="Teaspoon">\n<testsuite name="not_default" tests="42" time="_start_">\n})
21
25
  end
22
26
 
23
27
  end
24
28
 
25
- describe "#spec" do
29
+ describe "#suite" do
30
+
31
+ let(:result) { double(label: "_label_") }
26
32
 
27
- describe "passing spec" do
33
+ it "calls #log_end_suite" do
34
+ subject.should_receive(:log_end_suite)
35
+ subject.suite(result)
36
+ end
28
37
 
29
- let(:json) { {"status" => "passed", "suite" => "My Suite", "label" => "My Label"} }
38
+ it "logs the start of the testsuite" do
39
+ subject.suite(result)
40
+ expect(@log).to eq(%Q{<testsuite name="_label_">\n})
41
+ end
30
42
 
31
- it "calls passing_spec" do
32
- result = Teaspoon::Result.build_from_json(json)
33
- subject.spec(result)
43
+ end
34
44
 
35
- @log.should include "<testcase classname=\"My Suite\" name=\"My Label\"></testcase>"
36
- end
45
+ describe "#spec" do
37
46
 
47
+ it "logs a passing testcase on passing results" do
48
+ subject.spec(passing_spec)
49
+ expect(@log).to eq(%Q{<testcase classname="_suite_name_" name="_passing_label_">\n</testcase>\n})
38
50
  end
39
51
 
40
- describe "pending spec" do
52
+ it "logs a skipped testcase on pending results" do
53
+ subject.spec(pending_spec)
54
+ expect(@log).to eq(%Q{<testcase classname="_suite_name_" name="_pending_label_">\n <skipped/>\n</testcase>\n})
55
+ end
41
56
 
42
- let(:json) { {"status" => "pending", "suite" => "My Suite", "label" => "My Label"} }
57
+ it "logs a failing testcase with the message on failing results" do
58
+ subject.spec(failing_spec)
59
+ expect(@log).to include(%Q{<testcase classname="_suite_name_" name="_failing&amp;label_">\n})
60
+ expect(@log).to include(%Q{ <failure type="AssertionFailed">\n<![CDATA[\n_failure_message_\n]]>\n</failure>\n})
61
+ expect(@log).to include(%Q{</testcase>\n})
62
+ end
43
63
 
44
- it "calls pending_spec" do
45
- result = Teaspoon::Result.build_from_json(json)
46
- subject.spec(result)
47
- @log.should include "<testcase classname=\"My Suite\" name=\"My Label\"><skipped /></testcase>"
48
- end
64
+ it "includes any stdout" do
65
+ subject.instance_variable_set(:@stdout, "_stdout_")
66
+ subject.spec(passing_spec)
67
+ expect(@log).to eq(%Q{<testcase classname="_suite_name_" name="_passing_label_">\n<system-out>\n<![CDATA[\n_stdout_\n]]>\n</system-out>\n</testcase>\n})
68
+ end
49
69
 
70
+ end
71
+
72
+ describe "#result" do
73
+
74
+ let(:result) { double(coverage: nil) }
75
+
76
+ it "closes the last suite" do
77
+ subject.should_receive(:log_end_suite)
78
+ subject.result(result)
50
79
  end
51
80
 
52
- describe "failing spec" do
81
+ end
53
82
 
54
- let(:json) { {"status" => "fail", "suite" => "My Suite", "label" => "My Label", "message" => "Error, oh no"} }
83
+ describe "#coverage" do
55
84
 
56
- it "calls failing_spec" do
57
- result = Teaspoon::Result.build_from_json(json)
58
- subject.spec(result)
59
- @log.should include "<testcase classname=\"My Suite\" name=\"My Label\">
60
- <failure type=\"AssertionFailed\">Error, oh no</failure>
61
- </testcase>"
62
- end
85
+ it "logs the coverage" do
86
+ subject.coverage("_text_\n\n_text_summary_")
87
+ expect(@log).to eq(%Q{<testsuite name="Coverage summary" tests="0">\n<properties>\n<![CDATA[\n_text_\n_text_summary_\n]]>\n<properties>\n</testsuite>\n})
88
+ end
89
+
90
+ end
63
91
 
92
+ describe "#threshold_failure" do
93
+
94
+ it "logs the threshold failures" do
95
+ subject.threshold_failure("_was_not_met_\n_was_not_met_")
96
+ expect(@log).to include(%Q{<testsuite name="Coverage thresholds" tests="1">\n})
97
+ expect(@log).to include(%Q{<testcase classname="Coverage thresholds" name="were not met">\n})
98
+ expect(@log).to include(%Q{ <failure type="AssertionFailed">\n<![CDATA[\n_was_not_met_\n_was_not_met_\n]]>\n</failure>\n})
99
+ expect(@log).to include(%Q{</testcase>\n})
100
+ expect(@log).to include(%Q{</testsuite>\n})
64
101
  end
65
102
 
66
103
  end
67
- describe "#result" do
68
104
 
69
- it "ends the suite" do
70
- subject.result('result')
105
+ describe "#complete" do
71
106
 
72
- @log.should include "</testsuite></testsuites>"
107
+ it "logs the closing suite tags" do
108
+ subject.complete(2)
109
+ expect(@log).to include(%Q{</testsuite>\n</testsuites>})
73
110
  end
74
111
 
75
112
  end