teaspoon 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/MIT.LICENSE +1 -1
  3. data/README.md +46 -377
  4. data/app/assets/javascripts/teaspoon-jasmine.js +200 -194
  5. data/app/assets/javascripts/teaspoon-mocha.js +183 -185
  6. data/app/assets/javascripts/teaspoon-qunit.js +201 -193
  7. data/app/assets/javascripts/teaspoon-teaspoon.js +10 -10
  8. data/app/assets/javascripts/teaspoon/base/fixture.coffee +0 -1
  9. data/app/assets/javascripts/teaspoon/base/hook.coffee +7 -6
  10. data/app/assets/javascripts/teaspoon/qunit.coffee +10 -0
  11. data/app/controllers/teaspoon/suite_controller.rb +3 -4
  12. data/app/views/teaspoon/suite/_boot.html.erb +1 -1
  13. data/app/views/teaspoon/suite/_boot_require_js.html.erb +1 -0
  14. data/bin/teaspoon +1 -1
  15. data/config/routes.rb +4 -14
  16. data/lib/generators/teaspoon/install/install_generator.rb +22 -11
  17. data/lib/generators/teaspoon/install/templates/jasmine/{env_comments.rb → env_comments.rb.tt} +10 -5
  18. data/lib/generators/teaspoon/install/templates/jasmine/spec_helper.coffee +5 -5
  19. data/lib/generators/teaspoon/install/templates/jasmine/spec_helper.js +5 -5
  20. data/lib/generators/teaspoon/install/templates/mocha/{env_comments.rb → env_comments.rb.tt} +10 -5
  21. data/lib/generators/teaspoon/install/templates/mocha/spec_helper.coffee +6 -5
  22. data/lib/generators/teaspoon/install/templates/mocha/spec_helper.js +6 -5
  23. data/lib/generators/teaspoon/install/templates/qunit/{env_comments.rb → env_comments.rb.tt} +10 -5
  24. data/lib/generators/teaspoon/install/templates/qunit/test_helper.coffee +5 -5
  25. data/lib/generators/teaspoon/install/templates/qunit/test_helper.js +5 -5
  26. data/lib/tasks/teaspoon.rake +1 -1
  27. data/lib/teaspoon/command_line.rb +37 -40
  28. data/lib/teaspoon/configuration.rb +27 -30
  29. data/lib/teaspoon/configuration.rb.orig +187 -0
  30. data/lib/teaspoon/console.rb +31 -17
  31. data/lib/teaspoon/coverage.rb +2 -3
  32. data/lib/teaspoon/deprecated.rb +13 -8
  33. data/lib/teaspoon/drivers/base.rb +2 -2
  34. data/lib/teaspoon/drivers/capybara_webkit_driver.rb +33 -0
  35. data/lib/teaspoon/drivers/phantomjs/runner.js +2 -2
  36. data/lib/teaspoon/drivers/phantomjs_driver.rb +13 -4
  37. data/lib/teaspoon/drivers/selenium_driver.rb +3 -5
  38. data/lib/teaspoon/engine.rb +33 -5
  39. data/lib/teaspoon/environment.rb +2 -4
  40. data/lib/teaspoon/exceptions.rb +8 -5
  41. data/lib/teaspoon/formatters/base.rb +39 -27
  42. data/lib/teaspoon/formatters/clean_formatter.rb +0 -1
  43. data/lib/teaspoon/formatters/description.rb +36 -0
  44. data/lib/teaspoon/formatters/documentation_formatter.rb +2 -2
  45. data/lib/teaspoon/formatters/json_formatter.rb +1 -2
  46. data/lib/teaspoon/formatters/junit_formatter.rb +20 -20
  47. data/lib/teaspoon/formatters/modules/report_module.rb +4 -4
  48. data/lib/teaspoon/formatters/pride_formatter.rb +0 -1
  49. data/lib/teaspoon/formatters/rspec_html_formatter.rb +463 -0
  50. data/lib/teaspoon/formatters/snowday_formatter.rb +0 -1
  51. data/lib/teaspoon/formatters/swayze_or_oprah_formatter.rb +5 -4
  52. data/lib/teaspoon/formatters/tap_formatter.rb +2 -3
  53. data/lib/teaspoon/formatters/tap_y_formatter.rb +20 -21
  54. data/lib/teaspoon/formatters/teamcity_formatter.rb +4 -5
  55. data/lib/teaspoon/instrumentation.rb +7 -7
  56. data/lib/teaspoon/result.rb +1 -3
  57. data/lib/teaspoon/runner.rb +1 -2
  58. data/lib/teaspoon/server.rb +2 -1
  59. data/lib/teaspoon/suite.rb +20 -17
  60. data/lib/teaspoon/utility.rb +1 -3
  61. data/lib/teaspoon/version.rb +1 -1
  62. data/spec/dummy/config/application.rb +14 -18
  63. data/spec/dummy/config/boot.rb +2 -6
  64. data/spec/dummy/config/environment.rb +3 -3
  65. data/spec/dummy/config/environments/development.rb +27 -13
  66. data/spec/dummy/config/environments/production.rb +79 -0
  67. data/spec/dummy/config/environments/test.rb +26 -13
  68. data/spec/dummy/config/routes.rb +1 -1
  69. data/spec/dummy/config/secrets.yml +22 -0
  70. data/spec/features/console_reporter_spec.rb +3 -8
  71. data/spec/features/hooks_spec.rb +17 -4
  72. data/spec/features/html_reporter_spec.rb +12 -1
  73. data/spec/features/install_generator_spec.rb +2 -3
  74. data/spec/features/instrumentation_spec.rb +11 -11
  75. data/spec/javascripts/teaspoon/base/teaspoon_spec.coffee +14 -1
  76. data/spec/spec_helper.rb +7 -4
  77. data/spec/teaspoon/command_line_spec.rb +19 -28
  78. data/spec/teaspoon/configuration_spec.rb +22 -14
  79. data/spec/teaspoon/console_spec.rb +79 -63
  80. data/spec/teaspoon/coverage_spec.rb +23 -23
  81. data/spec/teaspoon/drivers/capybara_webkit_driver_spec.rb +39 -0
  82. data/spec/teaspoon/drivers/phantomjs_driver_spec.rb +10 -5
  83. data/spec/teaspoon/drivers/selenium_driver_spec.rb +10 -10
  84. data/spec/teaspoon/environment_spec.rb +28 -20
  85. data/spec/teaspoon/exceptions_spec.rb +4 -4
  86. data/spec/teaspoon/exporter_spec.rb +28 -28
  87. data/spec/teaspoon/formatters/base_spec.rb +29 -29
  88. data/spec/teaspoon/formatters/clean_formatter_spec.rb +1 -1
  89. data/spec/teaspoon/formatters/documentation_formatter_spec.rb +1 -1
  90. data/spec/teaspoon/formatters/dot_formatter_spec.rb +1 -1
  91. data/spec/teaspoon/formatters/json_formatter_spec.rb +7 -7
  92. data/spec/teaspoon/formatters/junit_formatter_spec.rb +10 -10
  93. data/spec/teaspoon/formatters/pride_formatter_spec.rb +1 -1
  94. data/spec/teaspoon/formatters/rspec_html_formatter_spec.rb +107 -0
  95. data/spec/teaspoon/formatters/snowday_formatter_spec.rb +1 -1
  96. data/spec/teaspoon/formatters/tap_formatter_spec.rb +1 -1
  97. data/spec/teaspoon/formatters/tap_y_formatter_spec.rb +1 -1
  98. data/spec/teaspoon/formatters/teamcity_formatter_spec.rb +27 -27
  99. data/spec/teaspoon/instrumentation_spec.rb +35 -29
  100. data/spec/teaspoon/result_spec.rb +40 -36
  101. data/spec/teaspoon/runner_spec.rb +23 -20
  102. data/spec/teaspoon/server_spec.rb +19 -16
  103. data/spec/teaspoon/suite_spec.rb +23 -9
  104. data/spec/teaspoon_env.rb +7 -12
  105. data/test/javascripts/teaspoon/qunit/models_test.coffee +6 -2
  106. data/vendor/assets/javascripts/support/chai-1.10.0.js +4800 -0
  107. data/vendor/assets/javascripts/support/chai-jq-0.0.7.js +524 -0
  108. data/vendor/assets/javascripts/support/chai.js +4435 -4349
  109. metadata +57 -54
  110. data/app/assets/javascripts/teaspoon-angular.js +0 -1299
  111. data/app/assets/javascripts/teaspoon/angular.coffee +0 -55
  112. data/app/assets/javascripts/teaspoon/angular/reporters/console.coffee +0 -11
  113. data/app/assets/javascripts/teaspoon/angular/reporters/html.coffee +0 -21
  114. data/spec/javascripts/angular_helper.coffee +0 -5
  115. data/spec/javascripts/teaspoon/angular/models_aspec.coffee +0 -95
  116. data/spec/javascripts/teaspoon/angular/reporters/html_aspec.coffee +0 -9
  117. data/vendor/assets/javascripts/angular/1.0.5.js +0 -26195
  118. data/vendor/assets/javascripts/angular/MIT-LICENSE +0 -22
@@ -8,7 +8,7 @@ describe Teaspoon::Formatters::CleanFormatter do
8
8
 
9
9
  before do
10
10
  @log = ""
11
- STDOUT.stub(:print) { |s| @log << s }
11
+ allow(STDOUT).to receive(:print) { |s| @log << s }
12
12
  end
13
13
 
14
14
  describe "#result" do
@@ -9,7 +9,7 @@ describe Teaspoon::Formatters::DocumentationFormatter do
9
9
 
10
10
  before do
11
11
  @log = ""
12
- STDOUT.stub(:print) { |s| @log << s }
12
+ allow(STDOUT).to receive(:print) { |s| @log << s }
13
13
  end
14
14
 
15
15
  describe "#suite" do
@@ -8,7 +8,7 @@ describe Teaspoon::Formatters::DotFormatter do
8
8
 
9
9
  before do
10
10
  @log = ""
11
- STDOUT.stub(:print) { |s| @log << s }
11
+ allow(STDOUT).to receive(:print) { |s| @log << s }
12
12
  end
13
13
 
14
14
  describe "#spec" do
@@ -10,7 +10,7 @@ describe Teaspoon::Formatters::JsonFormatter do
10
10
  let(:result) { double(hash.merge(total: 42)) }
11
11
 
12
12
  it "logs the original json" do
13
- subject.should_receive(:log_result).with(result)
13
+ expect(subject).to receive(:log_result).with(result)
14
14
  subject.runner(result)
15
15
  end
16
16
 
@@ -19,7 +19,7 @@ describe Teaspoon::Formatters::JsonFormatter do
19
19
  describe "#suite" do
20
20
 
21
21
  it "logs the original json" do
22
- subject.should_receive(:log_result).with(result)
22
+ expect(subject).to receive(:log_result).with(result)
23
23
  subject.suite(result)
24
24
  end
25
25
 
@@ -30,7 +30,7 @@ describe Teaspoon::Formatters::JsonFormatter do
30
30
  let(:result) { double(hash.merge(passing?: true)) }
31
31
 
32
32
  it "logs the original json" do
33
- subject.should_receive(:log_result).with(result)
33
+ expect(subject).to receive(:log_result).with(result)
34
34
  subject.spec(result)
35
35
  end
36
36
 
@@ -39,7 +39,7 @@ describe Teaspoon::Formatters::JsonFormatter do
39
39
  describe "#error" do
40
40
 
41
41
  it "logs the original json" do
42
- subject.should_receive(:log_result).with(result)
42
+ expect(subject).to receive(:log_result).with(result)
43
43
  subject.error(result)
44
44
  end
45
45
 
@@ -48,7 +48,7 @@ describe Teaspoon::Formatters::JsonFormatter do
48
48
  describe "#exception" do
49
49
 
50
50
  it "logs the original json" do
51
- subject.should_receive(:log_result).with(result)
51
+ expect(subject).to receive(:log_result).with(result)
52
52
  subject.exception(result)
53
53
  end
54
54
 
@@ -57,7 +57,7 @@ describe Teaspoon::Formatters::JsonFormatter do
57
57
  describe "#console" do
58
58
 
59
59
  it "logs the message as json" do
60
- subject.should_receive(:log_line).with(%Q{{"type":"console","log":"_message_"}})
60
+ expect(subject).to receive(:log_line).with(%Q{{"type":"console","log":"_message_"}})
61
61
  subject.console("_message_")
62
62
  end
63
63
 
@@ -68,7 +68,7 @@ describe Teaspoon::Formatters::JsonFormatter do
68
68
  let(:result) { double(hash.merge(coverage: nil)) }
69
69
 
70
70
  it "logs the original json" do
71
- subject.should_receive(:log_str).with("_original_json_")
71
+ expect(subject).to receive(:log_str).with("_original_json_")
72
72
  subject.result(result)
73
73
  end
74
74
 
@@ -4,11 +4,11 @@ describe Teaspoon::Formatters::JunitFormatter do
4
4
 
5
5
  let(:passing_spec) { double(passing?: true, suite: "_suite_name_", label: "_passing_label_") }
6
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_") }
7
+ let(:failing_spec) { double(passing?: false, pending?: false, suite: "_suite&name_", label: "_failing&label_", message: "_failure_message_") }
8
8
 
9
9
  before do
10
10
  @log = ""
11
- STDOUT.stub(:print) { |s| @log << s }
11
+ allow(STDOUT).to receive(:print) { |s| @log << s }
12
12
  end
13
13
 
14
14
  describe "#runner" do
@@ -16,28 +16,28 @@ describe Teaspoon::Formatters::JunitFormatter do
16
16
  let(:result) { double(start: "_start_", total: 42) }
17
17
 
18
18
  before do
19
- subject.instance_variable_set(:@suite_name, "not_default")
19
+ subject.instance_variable_set(:@suite_name, "not_default&")
20
20
  end
21
21
 
22
22
  it "starts the suite" do
23
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})
24
+ expect(@log).to eq(%Q{<?xml version="1.0" encoding="UTF-8"?>\n<testsuites name="Teaspoon">\n<testsuite name="not_default&amp;" tests="42" time="_start_">\n})
25
25
  end
26
26
 
27
27
  end
28
28
 
29
29
  describe "#suite" do
30
30
 
31
- let(:result) { double(label: "_label_") }
31
+ let(:result) { double(label: "_suite>label_") }
32
32
 
33
33
  it "calls #log_end_suite" do
34
- subject.should_receive(:log_end_suite)
34
+ expect(subject).to receive(:log_end_suite)
35
35
  subject.suite(result)
36
36
  end
37
37
 
38
38
  it "logs the start of the testsuite" do
39
39
  subject.suite(result)
40
- expect(@log).to eq(%Q{<testsuite name="_label_">\n})
40
+ expect(@log).to eq(%Q{<testsuite name="_suite&gt;label_">\n})
41
41
  end
42
42
 
43
43
  end
@@ -56,7 +56,7 @@ describe Teaspoon::Formatters::JunitFormatter do
56
56
 
57
57
  it "logs a failing testcase with the message on failing results" do
58
58
  subject.spec(failing_spec)
59
- expect(@log).to include(%Q{<testcase classname="_suite_name_" name="_failing&amp;label_">\n})
59
+ expect(@log).to include(%Q{<testcase classname="_suite&amp;name_" name="_failing&amp;label_">\n})
60
60
  expect(@log).to include(%Q{ <failure type="AssertionFailed">\n<![CDATA[\n_failure_message_\n]]>\n</failure>\n})
61
61
  expect(@log).to include(%Q{</testcase>\n})
62
62
  end
@@ -74,7 +74,7 @@ describe Teaspoon::Formatters::JunitFormatter do
74
74
  let(:result) { double(coverage: nil) }
75
75
 
76
76
  it "closes the last suite" do
77
- subject.should_receive(:log_end_suite)
77
+ expect(subject).to receive(:log_end_suite)
78
78
  subject.result(result)
79
79
  end
80
80
 
@@ -84,7 +84,7 @@ describe Teaspoon::Formatters::JunitFormatter do
84
84
 
85
85
  it "logs the coverage" do
86
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})
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
88
  end
89
89
 
90
90
  end
@@ -8,7 +8,7 @@ describe Teaspoon::Formatters::PrideFormatter do
8
8
 
9
9
  before do
10
10
  @log = ""
11
- STDOUT.stub(:print) { |s| @log << s }
11
+ allow(STDOUT).to receive(:print) { |s| @log << s }
12
12
  end
13
13
 
14
14
  describe "#spec" do
@@ -0,0 +1,107 @@
1
+ require "spec_helper"
2
+
3
+ describe Teaspoon::Formatters::RspecHtmlFormatter do
4
+
5
+ let(:suite) { double(label: "_suite&_", level: @level || 0)}
6
+ let(:passing_spec) { double(passing?: true, failing?: false, elapsed: nil, status: "passed", label: "_passing&_") }
7
+ let(:pending_spec) { double(passing?: false, pending?: true, failing?: false, elapsed: nil, status: "pending", label: "_pending&_", description: "_description&_") }
8
+ let(:failing_spec) { double(passing?: false, pending?: false, failing?: true, elapsed: nil, status: "failed", label: "_failing&_", description: "_description&_", message: "_message&_", link: "_link&_", trace: "_trace&_") }
9
+
10
+ before do
11
+ @log = ""
12
+ allow(STDOUT).to receive(:print) { |s| @log << s }
13
+ end
14
+
15
+ describe "#runner" do
16
+
17
+ let(:result) { double(start: "_start&_", total: 42) }
18
+
19
+ before do
20
+ subject.instance_variable_set(:@suite_name, "not_default&")
21
+ end
22
+
23
+ it "starts the HTML" do
24
+ subject.runner(result)
25
+ expect(@log).to eq(Teaspoon::Formatters::RspecHtmlFormatter::Templates::HEADER)
26
+ end
27
+
28
+ end
29
+
30
+ describe "#suite" do
31
+
32
+ it "logs a suite header" do
33
+ subject.suite(suite)
34
+ expect(@log).to eq(Teaspoon::Formatters::RspecHtmlFormatter::Templates::SUITE_START.gsub("<%= h @o.label %>", "_suite&amp;_"))
35
+ expect(subject.instance_variable_get(:@current_suite)).to eq(["_suite&_"])
36
+ end
37
+
38
+ it "finishes any ended suites" do
39
+ subject.instance_variable_get(:@current_suite) << "Suite 1" << "Suite 2" << "Suite 3" << "Suite 4"
40
+ @level = 2
41
+ subject.suite(suite)
42
+ expected_head = Teaspoon::Formatters::RspecHtmlFormatter::Templates::SUITE_END * 2
43
+ expected_tail = Teaspoon::Formatters::RspecHtmlFormatter::Templates::SUITE_START.gsub("<%= h @o.label %>", "_suite&amp;_")
44
+ expect(@log).to eq(expected_head + expected_tail)
45
+ end
46
+
47
+ end
48
+
49
+ describe "#spec" do
50
+
51
+ it "logs passing results" do
52
+ subject.spec(passing_spec)
53
+ expected_log = Teaspoon::Formatters::RspecHtmlFormatter::Templates::SPEC.gsub("<%= h @o.status %>", "passed")
54
+ expected_log.gsub!("<%= h @o.label %>", "_passing&amp;_")
55
+ expected_log.gsub!("<%= h \"\#{@o.elapsed}s\" if @o.elapsed %>", "")
56
+ expected_log.gsub!(/\<% if @o.failing\? %\>.*?\<% end %\>/m, "")
57
+ expect(@log).to eq(expected_log)
58
+ end
59
+
60
+ it "logs pending results" do
61
+ subject.spec(pending_spec)
62
+ expected_log = Teaspoon::Formatters::RspecHtmlFormatter::Templates::SPEC.gsub("<%= h @o.status %>", "pending")
63
+ expected_log.gsub!("<%= h @o.label %>", "_pending&amp;_")
64
+ expected_log.gsub!("<%= h \"\#{@o.elapsed}s\" if @o.elapsed %>", "")
65
+ expected_log.gsub!(/\<% if @o.failing\? %\>.*?\<% end %\>/m, "")
66
+ expect(@log).to eq(expected_log)
67
+ end
68
+
69
+ it "logs failing results" do
70
+ subject.spec(failing_spec)
71
+ expected_log = Teaspoon::Formatters::RspecHtmlFormatter::Templates::SPEC.gsub("<%= h @o.status %>", "failed")
72
+ expected_log.gsub!("<%= h @o.label %>", "_failing&amp;_")
73
+ expected_log.gsub!("<%= h \"\#{@o.elapsed}s\" if @o.elapsed %>", "")
74
+ expected_log.gsub!("<%= h @o.trace %>", "_trace&amp;_")
75
+ expected_log.gsub!("<% if @o.failing? %>", "")
76
+ expected_log.gsub!("<% end %>", "")
77
+ expect(@log).to eq(expected_log)
78
+ end
79
+
80
+ end
81
+
82
+ describe "#result" do
83
+
84
+ let(:result) { double(elapsed: 3.1337, coverage: nil) }
85
+
86
+ before do
87
+ subject.run_count = 666
88
+ subject.failures << failing_spec
89
+ subject.pendings << pending_spec
90
+ end
91
+
92
+ it "ends the HTML" do
93
+ subject.result(result)
94
+ expect(@log).to eq(Teaspoon::Formatters::RspecHtmlFormatter::Templates::FOOTER.gsub("<%= h @o.elapsed %>", "3.1337"))
95
+ end
96
+
97
+ it "finishes any remaining suites" do
98
+ subject.instance_variable_get(:@current_suite) << "Suite 1" << "Suite 2"
99
+ subject.result(result)
100
+ expected_head = Teaspoon::Formatters::RspecHtmlFormatter::Templates::SUITE_END * 2
101
+ expected_tail = Teaspoon::Formatters::RspecHtmlFormatter::Templates::FOOTER.gsub("<%= h @o.elapsed %>", "3.1337")
102
+ expect(@log).to eq(expected_head + expected_tail)
103
+ end
104
+
105
+ end
106
+
107
+ end
@@ -10,7 +10,7 @@ describe Teaspoon::Formatters::SnowdayFormatter do
10
10
 
11
11
  before do
12
12
  @log = ""
13
- STDOUT.stub(:print) { |s| @log << s }
13
+ allow(STDOUT).to receive(:print) { |s| @log << s }
14
14
  end
15
15
 
16
16
  describe "#spec" do
@@ -8,7 +8,7 @@ describe Teaspoon::Formatters::TapFormatter do
8
8
 
9
9
  before do
10
10
  @log = ""
11
- STDOUT.stub(:print) { |s| @log << s }
11
+ allow(STDOUT).to receive(:print) { |s| @log << s }
12
12
  end
13
13
 
14
14
  describe "#runner" do
@@ -8,7 +8,7 @@ describe Teaspoon::Formatters::TapYFormatter do
8
8
 
9
9
  before do
10
10
  @log = ""
11
- STDOUT.stub(:print) { |s| @log << s }
11
+ allow(STDOUT).to receive(:print) { |s| @log << s }
12
12
  end
13
13
 
14
14
  describe "#runner" do
@@ -10,7 +10,7 @@ describe Teaspoon::Formatters::TeamcityFormatter do
10
10
 
11
11
  before do
12
12
  @log = ""
13
- STDOUT.stub(:print) { |s| @log << s }
13
+ allow(STDOUT).to receive(:print) { |s| @log << s }
14
14
  end
15
15
 
16
16
  describe "#runner" do
@@ -18,7 +18,7 @@ describe Teaspoon::Formatters::TeamcityFormatter do
18
18
  let(:result) { double(total: 42, start: "_start_") }
19
19
 
20
20
  it "starts the suite" do
21
- Time.should_receive(:now).and_return(double(to_json: "_json_time_"))
21
+ expect(Time).to receive(:now).and_return(double(to_json: "_json_time_"))
22
22
  subject.runner(result)
23
23
  expect(@log).to include("##teamcity[enteredTheMatrix timestamp='_json_time_']\n")
24
24
  expect(@log).to include("##teamcity[testCount count='42' timestamp='_start_']\n")
@@ -30,13 +30,13 @@ describe Teaspoon::Formatters::TeamcityFormatter do
30
30
 
31
31
  it "logs the suite" do
32
32
  subject.suite(suite)
33
- expect(@log).to include(%Q{##teamcity[testSuiteStarted name='_suite_']})
33
+ expect(@log).to include(%{##teamcity[testSuiteStarted name='_suite_']})
34
34
  end
35
35
 
36
36
  it "closes the last suite if there was one" do
37
37
  subject.instance_variable_set(:@last_suite, suite)
38
38
  subject.suite(suite)
39
- expect(@log).to include(%Q{##teamcity[testSuiteFinished name='_suite_']})
39
+ expect(@log).to include(%{##teamcity[testSuiteFinished name='_suite_']})
40
40
  end
41
41
 
42
42
  end
@@ -45,29 +45,29 @@ describe Teaspoon::Formatters::TeamcityFormatter do
45
45
 
46
46
  it "logs a passing testcase on passing results" do
47
47
  subject.spec(passing_spec)
48
- expect(@log).to include(%Q{##teamcity[testStarted name='_passing_|[desc|]|rip|||'o|n_' captureStandardOutput='true']\n})
49
- expect(@log).to include(%Q{##teamcity[testFinished name='_passing_|[desc|]|rip|||'o|n_']\n})
48
+ expect(@log).to include(%{##teamcity[testStarted name='_passing_|[desc|]|rip|||'o|n_' captureStandardOutput='true']\n})
49
+ expect(@log).to include(%{##teamcity[testFinished name='_passing_|[desc|]|rip|||'o|n_']\n})
50
50
  end
51
51
 
52
52
  it "logs a skipped testcase on pending results" do
53
53
  subject.spec(pending_spec)
54
- expect(@log).to include(%Q{##teamcity[testIgnored name='_pending_|[desc|]_' captureStandardOutput='true']\n})
55
- expect(@log).to include(%Q{##teamcity[testFinished name='_pending_|[desc|]_']\n})
54
+ expect(@log).to include(%{##teamcity[testIgnored name='_pending_|[desc|]_' captureStandardOutput='true']\n})
55
+ expect(@log).to include(%{##teamcity[testFinished name='_pending_|[desc|]_']\n})
56
56
  end
57
57
 
58
58
  it "logs a failing testcase with the message on failing results" do
59
59
  subject.spec(failing_spec)
60
- expect(@log).to include(%Q{##teamcity[testStarted name='_failing_|[desc|]_' captureStandardOutput='true']\n})
61
- expect(@log).to include(%Q{##teamcity[testFailed name='_failing_|[desc|]_' message='_failure_|[mess|]age_']\n})
62
- expect(@log).to include(%Q{##teamcity[testFinished name='_failing_|[desc|]_']\n})
60
+ expect(@log).to include(%{##teamcity[testStarted name='_failing_|[desc|]_' captureStandardOutput='true']\n})
61
+ expect(@log).to include(%{##teamcity[testFailed name='_failing_|[desc|]_' message='_failure_|[mess|]age_']\n})
62
+ expect(@log).to include(%{##teamcity[testFinished name='_failing_|[desc|]_']\n})
63
63
  end
64
64
 
65
65
  it "captures stdout and puts it in the right place" do
66
66
  subject.instance_variable_set(:@stdout, "_stdout_\n")
67
67
  subject.spec(pending_spec)
68
- expect(@log).to include(%Q{##teamcity[testIgnored name='_pending_|[desc|]_' captureStandardOutput='true']\n})
69
- expect(@log).to include(%Q{_stdout_\n})
70
- expect(@log).to include(%Q{##teamcity[testFinished name='_pending_|[desc|]_']\n})
68
+ expect(@log).to include(%{##teamcity[testIgnored name='_pending_|[desc|]_' captureStandardOutput='true']\n})
69
+ expect(@log).to include(%{_stdout_\n})
70
+ expect(@log).to include(%{##teamcity[testFinished name='_pending_|[desc|]_']\n})
71
71
  end
72
72
 
73
73
  end
@@ -78,7 +78,7 @@ describe Teaspoon::Formatters::TeamcityFormatter do
78
78
 
79
79
  it "logs the error" do
80
80
  subject.error(result)
81
- expect(@log).to include(%Q{##teamcity[message text='_error_message_' errorDetails='myfile.js:420|nmyfile.js:666' status='ERROR']\n})
81
+ expect(@log).to include(%{##teamcity[message text='_error_message_' errorDetails='myfile.js:420|nmyfile.js:666' status='ERROR']\n})
82
82
  end
83
83
 
84
84
  end
@@ -88,7 +88,7 @@ describe Teaspoon::Formatters::TeamcityFormatter do
88
88
  it "closes any open suites" do
89
89
  subject.instance_variable_set(:@last_suite, double(label: "_last_suite_label_"))
90
90
  subject.result(result)
91
- expect(@log).to include(%Q{##teamcity[testSuiteFinished name='_last_suite_label_']})
91
+ expect(@log).to include(%{##teamcity[testSuiteFinished name='_last_suite_label_']})
92
92
  end
93
93
 
94
94
  it "assigns @result" do
@@ -102,9 +102,9 @@ describe Teaspoon::Formatters::TeamcityFormatter do
102
102
 
103
103
  it "logs the coverage" do
104
104
  subject.coverage("_text_\n\n_text_summary_")
105
- expect(@log).to include(%Q{##teamcity[testSuiteStarted name='Coverage summary']\n})
106
- expect(@log).to include(%Q{_text_\n\n_text_summary_\n})
107
- expect(@log).to include(%Q{##teamcity[testSuiteFinished name='Coverage summary']\n})
105
+ expect(@log).to include(%{##teamcity[testSuiteStarted name='Coverage summary']\n})
106
+ expect(@log).to include(%{_text_\n\n_text_summary_\n})
107
+ expect(@log).to include(%{##teamcity[testSuiteFinished name='Coverage summary']\n})
108
108
  end
109
109
 
110
110
  end
@@ -113,12 +113,12 @@ describe Teaspoon::Formatters::TeamcityFormatter do
113
113
 
114
114
  it "logs the threshold failures" do
115
115
  subject.threshold_failure("_was_not_met_\n_was_not_met_")
116
- expect(@log).to include(%Q{##teamcity[testSuiteStarted name='Coverage thresholds']\n})
117
- expect(@log).to include(%Q{##teamcity[testStarted name='Coverage thresholds' captureStandardOutput='true']\n})
118
- expect(@log).to include(%Q{##teamcity[testFailed name='Coverage thresholds' message='were not met']\n})
119
- expect(@log).to include(%Q{_was_not_met_\n_was_not_met_\n})
120
- expect(@log).to include(%Q{##teamcity[testFinished name='Coverage thresholds']\n})
121
- expect(@log).to include(%Q{##teamcity[testSuiteFinished name='Coverage thresholds']\n})
116
+ expect(@log).to include(%{##teamcity[testSuiteStarted name='Coverage thresholds']\n})
117
+ expect(@log).to include(%{##teamcity[testStarted name='Coverage thresholds' captureStandardOutput='true']\n})
118
+ expect(@log).to include(%{##teamcity[testFailed name='Coverage thresholds' message='were not met']\n})
119
+ expect(@log).to include(%{_was_not_met_\n_was_not_met_\n})
120
+ expect(@log).to include(%{##teamcity[testFinished name='Coverage thresholds']\n})
121
+ expect(@log).to include(%{##teamcity[testSuiteFinished name='Coverage thresholds']\n})
122
122
  end
123
123
 
124
124
  end
@@ -139,8 +139,8 @@ describe Teaspoon::Formatters::TeamcityFormatter do
139
139
 
140
140
  it "ends the suite" do
141
141
  subject.complete(1)
142
- expect(@log).to include(%Q{Finished in 3.1337 seconds\n})
143
- expect(@log).to include(%Q{6 examples, 1 failure, 2 pending\n\n})
142
+ expect(@log).to include(%{Finished in 3.1337 seconds\n})
143
+ expect(@log).to include(%{6 examples, 1 failure, 2 pending\n\n})
144
144
  end
145
145
 
146
146
  end
@@ -7,96 +7,102 @@ describe Teaspoon::Instrumentation do
7
7
 
8
8
  subject { Teaspoon::Instrumentation }
9
9
 
10
- let(:asset) { double(source: source, pathname: 'path/to/instrument.js') }
10
+ let(:asset) { double(source: source, pathname: "path/to/instrument.js") }
11
11
  let(:source) { "function add(a, b) { return a + b } // ☃ " }
12
- let(:response) { [200, {"Content-Type" => "application/javascript"}, asset] }
13
- let(:env) { {"QUERY_STRING" => "instrument=true"} }
12
+ let(:response) { [200, { "Content-Type" => "application/javascript" }, asset] }
13
+ let(:env) { { "QUERY_STRING" => "instrument=true" } }
14
14
 
15
15
  describe ".add_to" do
16
16
 
17
17
  before do
18
- Teaspoon::Instrumentation.stub(:executable).and_return("/path/to/istanbul")
18
+ allow(Teaspoon::Instrumentation).to receive(:executable).and_return("/path/to/istanbul")
19
19
  end
20
20
 
21
21
  before do
22
- Teaspoon::Instrumentation.stub(:add?).and_return(true)
23
- asset.should_receive(:clone).and_return(asset)
22
+ allow(Teaspoon::Instrumentation).to receive(:add?).and_return(true)
23
+ expect(asset).to receive(:clone).and_return(asset)
24
24
 
25
- File.stub(:open)
26
- subject.any_instance.stub(:instrument).and_return(source + " // instrumented")
25
+ allow(File).to receive(:open)
26
+ allow_any_instance_of(subject).to receive(:instrument).and_return(source + " // instrumented")
27
27
 
28
28
  path = nil
29
29
  Dir.mktmpdir { |p| path = p }
30
- Dir.stub(:mktmpdir).and_yield(path)
30
+ allow(Dir).to receive(:mktmpdir).and_yield(path)
31
31
  @output = File.join(path, "instrument.js")
32
32
  end
33
33
 
34
34
  it "writes the file to a tmp path" do
35
- file = double('file')
36
- File.should_receive(:open).with(@output, "w").and_yield(file)
37
- file.should_receive(:write).with("function add(a, b) { return a + b } // ☃ ")
35
+ file = double("file")
36
+ expect(File).to receive(:open).with(@output, "w").and_yield(file)
37
+ expect(file).to receive(:write).with("function add(a, b) { return a + b } // ☃ ")
38
38
  subject.add_to(response, env)
39
39
  end
40
40
 
41
41
  it "instruments the javascript file" do
42
- subject.any_instance.should_receive(:instrument).with(@output).and_return("_instrumented_")
42
+ expect_any_instance_of(subject).to receive(:instrument).with(@output).and_return("_instrumented_")
43
43
  subject.add_to(response, env)
44
44
  end
45
45
 
46
46
  it "replaces the response array with the appropriate information" do
47
- response = [666, {"Content-Type" => "application/javascript"}, asset]
48
- expected = [666, {"Content-Type" => "application/javascript", "Content-Length" => "59"}, asset]
47
+ response = [666, { "Content-Type" => "application/javascript" }, asset]
48
+ expected = [666, { "Content-Type" => "application/javascript", "Content-Length" => "59" }, asset]
49
49
 
50
50
  expect(subject.add_to(response, env)).to eq(expected)
51
51
  end
52
52
 
53
+ it "raises an exception if istanbul fails" do
54
+ `(exit 1)`
55
+ allow(subject).to receive(:`)
56
+ allow_any_instance_of(subject).to receive(:instrument).and_call_original
57
+ expect { subject.add_to(response, env) }.to raise_error(
58
+ Teaspoon::DependencyFailure, "Could not generate instrumentation for instrument.js."
59
+ )
60
+ end
61
+
53
62
  end
54
63
 
55
64
  describe ".add?" do
56
65
 
57
66
  before do
58
- Teaspoon::Instrumentation.stub(:executable).and_return("/path/to/istanbul")
67
+ allow(Teaspoon::Instrumentation).to receive(:executable).and_return("/path/to/istanbul")
59
68
  end
60
69
 
61
70
  it "returns true when everything is good" do
62
- expect(subject.add?(response, {"QUERY_STRING" => "instrument=true"})).to be(true)
63
- expect(subject.add?(response, {"QUERY_STRING" => "instrument=1"})).to be(true)
71
+ expect(subject.add?(response, "QUERY_STRING" => "instrument=true")).to be(true)
72
+ expect(subject.add?(response, "QUERY_STRING" => "instrument=1")).to be(true)
64
73
  end
65
74
 
66
75
  it "doesn't if the query param isn't set (or isn't something we care about)" do
67
76
  expect(subject.add?(response, {})).to_not be(true)
68
- expect(subject.add?(response, {"QUERY_STRING" => "instrument=foo"})).to_not be(true)
77
+ expect(subject.add?(response, "QUERY_STRING" => "instrument=foo")).to_not be(true)
69
78
  end
70
79
 
71
80
  it "doesn't if response isn't 200" do
72
- expect(subject.add?([404, {"Content-Type" => "application/javascript"}, asset], env)).to_not be(true)
81
+ expect(subject.add?([404, { "Content-Type" => "application/javascript" }, asset], env)).to_not be(true)
73
82
  end
74
83
 
75
84
  it "doesn't when the content type isn't application/javascript" do
76
- expect(subject.add?([200, {"Content-Type" => "foo/bar"}, asset], env)).to_not be(true)
85
+ expect(subject.add?([200, { "Content-Type" => "foo/bar" }, asset], env)).to_not be(true)
77
86
  end
78
87
 
79
88
  it "doesn't if there's no executable" do
80
- subject.should_receive(:executable).and_return(false)
89
+ expect(subject).to receive(:executable).and_return(false)
81
90
  expect(subject.add?(response, env)).to_not be(true)
82
91
  end
83
92
 
84
93
  it "doesn't if there's no asset" do
85
- expect(subject.add?([404, {"Content-Type" => "application/javascript"}, []], env)).to_not be(true)
94
+ expect(subject.add?([404, { "Content-Type" => "application/javascript" }, []], env)).to_not be(true)
86
95
  end
87
96
 
88
97
  end
89
98
 
90
99
  describe "integration" do
91
100
 
92
- let(:asset) { Rails.application.assets.find_asset('instrumented1.coffee') }
93
-
94
- before do
95
- pending("needs istanbul to be installed") unless Teaspoon::Instrumentation.executable
96
- end
101
+ let(:asset) { Rails.application.assets.find_asset("instrumented1.coffee") }
97
102
 
98
103
  it "instruments a file" do
99
- status, headers, asset = subject.add_to(response, {"QUERY_STRING" => "instrument=true"})
104
+ pending("needs istanbul to be installed") unless Teaspoon::Instrumentation.executable
105
+ status, headers, asset = subject.add_to(response, "QUERY_STRING" => "instrument=true")
100
106
  expect(status).to eq(200)
101
107
  expect(headers).to include("Content-Type" => "application/javascript")
102
108
  expect(asset.source).to match(/var __cov_.+ = \(Function\('return this'\)\)\(\);/)