teaspoon 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -19,11 +19,11 @@ describe Teaspoon do
19
19
  it "sets configured to true" do
20
20
  subject.configured = false
21
21
  subject.configure { }
22
- expect(subject.configured).to be_true
22
+ expect(subject.configured).to be_truthy
23
23
  end
24
24
 
25
25
  it "overrides configuration from ENV" do
26
- subject.configuration.should_receive(:override_from_env).with(ENV)
26
+ expect(subject.configuration).to receive(:override_from_env).with(ENV)
27
27
  subject.configure { }
28
28
  end
29
29
 
@@ -32,7 +32,8 @@ describe Teaspoon do
32
32
  describe ".setup" do
33
33
 
34
34
  it "calls configure" do
35
- subject.should_receive(:configure).with(&block = proc{})
35
+ block = proc{}
36
+ expect(subject).to receive(:configure).with(no_args) { |&arg| expect(arg).to eq(block) }
36
37
  subject.setup(&block)
37
38
  end
38
39
 
@@ -75,9 +76,9 @@ describe Teaspoon::Configuration do
75
76
  expect(subject.server_timeout).to eq(20)
76
77
  expect(subject.formatters).to eq(['dot'])
77
78
  expect(subject.use_coverage).to be_nil
78
- expect(subject.fail_fast).to be_true
79
- expect(subject.suppress_log).to be_false
80
- expect(subject.color).to be_true
79
+ expect(subject.fail_fast).to be_truthy
80
+ expect(subject.suppress_log).to be_falsey
81
+ expect(subject.color).to be_truthy
81
82
 
82
83
  expect(subject.suite_configs).to be_a(Hash)
83
84
  expect(subject.coverage_configs).to be_a(Hash)
@@ -127,9 +128,9 @@ describe Teaspoon::Configuration do
127
128
  describe ".override_from_options" do
128
129
 
129
130
  it "allows overriding from options" do
130
- subject.should_receive(:fail_fast=).with(true)
131
- subject.should_receive(:driver_timeout=).with(123)
132
- subject.should_receive(:driver=).with("driver")
131
+ expect(subject).to receive(:fail_fast=).with(true)
132
+ expect(subject).to receive(:driver_timeout=).with(123)
133
+ expect(subject).to receive(:driver=).with("driver")
133
134
 
134
135
  subject.send(:override_from_options, fail_fast: true, driver_timeout: 123, driver: "driver")
135
136
  end
@@ -139,9 +140,9 @@ describe Teaspoon::Configuration do
139
140
  describe ".override_from_env" do
140
141
 
141
142
  it "allows overriding from the env" do
142
- subject.should_receive(:fail_fast=).with(true)
143
- subject.should_receive(:driver_timeout=).with(123)
144
- subject.should_receive(:driver=).with("driver")
143
+ expect(subject).to receive(:fail_fast=).with(true)
144
+ expect(subject).to receive(:driver_timeout=).with(123)
145
+ expect(subject).to receive(:driver=).with("driver")
145
146
 
146
147
  subject.send(:override_from_env, "FAIL_FAST" => "true", "DRIVER_TIMEOUT" => "123", "DRIVER" => "driver")
147
148
  end
@@ -161,6 +162,7 @@ describe Teaspoon::Configuration::Suite do
161
162
  expect(subject.javascripts).to eq(["jasmine/1.3.1", "teaspoon/jasmine"])
162
163
  expect(subject.stylesheets).to eq(["teaspoon"])
163
164
  expect(subject.no_coverage).to eq([%r{/lib/ruby/gems/}, %r{/vendor/assets/}, %r{/support/}, %r{/(.+)_helper.}])
165
+ expect(subject.expand_assets).to eq(true)
164
166
  end
165
167
 
166
168
  it "accepts a block that can override defaults" do
@@ -192,12 +194,18 @@ describe Teaspoon::Configuration::Suite do
192
194
 
193
195
  it "shows an error for unknown frameworks" do
194
196
  @suite = proc{ |s| s.use_framework :foo }
195
- expect{ subject }.to raise_error Teaspoon::UnknownFramework, "Unknown framework \"foo\""
197
+ expect{ subject }.to raise_error(
198
+ Teaspoon::UnknownFramework,
199
+ "Unknown framework \"foo\""
200
+ )
196
201
  end
197
202
 
198
203
  it "shows an error for unknown versions" do
199
204
  @suite = proc{ |s| s.use_framework :qunit, "666" }
200
- expect{ subject }.to raise_error Teaspoon::UnknownFramework, "Unknown framework \"qunit\" with version 666 -- available versions 1.12.0, 1.14.0"
205
+ expect{ subject }.to raise_error(
206
+ Teaspoon::UnknownFramework,
207
+ "Unknown framework \"qunit\" with version 666 -- available versions 1.12.0, 1.14.0"
208
+ )
201
209
  end
202
210
 
203
211
  end
@@ -7,44 +7,51 @@ require "teaspoon/exporter"
7
7
  describe Teaspoon::Console do
8
8
 
9
9
  let(:driver) { double(run_specs: 0) }
10
- let(:server) { double(start: nil, url: "http://url.com") }
10
+ let(:server) { double(start: nil, url: "http://url.com", responsive?: false) }
11
11
  let(:runner) { double(failure_count: 2) }
12
12
 
13
13
  before do
14
- Teaspoon::Environment.stub(:load)
15
- Teaspoon::Server.stub(:new).and_return(server)
16
- Teaspoon::Runner.stub(:new).and_return(runner)
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
17
 
18
- Teaspoon::Console.any_instance.stub(:driver).and_return(driver)
19
- Teaspoon::Console.any_instance.stub(:log)
18
+ allow_any_instance_of(Teaspoon::Console).to receive(:driver).and_return(driver)
19
+ allow_any_instance_of(Teaspoon::Console).to receive(:log)
20
20
  end
21
21
 
22
22
  describe "#initialize" do
23
23
 
24
- it "assigns @options" do
24
+ it "assigns @default_options" do
25
25
  subject = Teaspoon::Console.new(foo: "bar")
26
- expect(subject.instance_variable_get(:@options)).to eql(foo: "bar")
26
+ expect(subject.instance_variable_get(:@default_options)).to eql(foo: "bar")
27
27
  end
28
28
 
29
29
  it "loads the environment" do
30
- Teaspoon::Environment.should_receive(:load)
30
+ expect(Teaspoon::Environment).to receive(:load)
31
31
  Teaspoon::Console.new
32
32
  end
33
33
 
34
34
  it "starts the server" do
35
- Teaspoon::Console.any_instance.should_receive(:log).with("Starting the Teaspoon server...")
36
- Teaspoon::Console.any_instance.should_receive(:start_server).and_call_original
37
- Teaspoon::Server.should_receive(:new).and_return(server)
38
- server.should_receive(:start)
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
39
  Teaspoon::Console.new
40
40
  end
41
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
+
42
49
  it "aborts (displaying a message) on Teaspoon::ServerException" do
43
- STDOUT.should_receive(:print).with("_message_\n")
44
- Teaspoon::Console.any_instance.should_receive(:log).and_call_original
45
- Teaspoon::Console.any_instance.should_receive(:start_server).and_raise(Teaspoon::ServerException, "_message_")
46
- Teaspoon::Console.any_instance.should_receive(:abort).with("_message_").and_call_original
47
- expect{ Teaspoon::Console.new }.to raise_error SystemExit
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)
48
55
  end
49
56
 
50
57
  end
@@ -52,11 +59,11 @@ describe Teaspoon::Console do
52
59
  describe "#failures?" do
53
60
 
54
61
  it "calls #execute and returns the inverse of #executes return value" do
55
- subject.should_receive(:execute).and_return(false)
56
- expect(subject.failures?).to be_true
62
+ expect(subject).to receive(:execute).and_return(false)
63
+ expect(subject.failures?).to be_truthy
57
64
 
58
- subject.should_receive(:execute).and_return(true)
59
- expect(subject.failures?).to be_false
65
+ expect(subject).to receive(:execute).and_return(true)
66
+ expect(subject.failures?).to be_falsey
60
67
  end
61
68
 
62
69
  end
@@ -64,19 +71,25 @@ describe Teaspoon::Console do
64
71
  describe "#execute" do
65
72
 
66
73
  it "calls #execute_without_handling and returns its value" do
67
- subject.should_receive(:execute_without_handling).with(foo: "bar").and_return(true)
68
- expect(subject.execute(foo: "bar")).to be_true
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
69
82
  end
70
83
 
71
84
  it "handles Teaspoon::Error exceptions" do
72
- subject.should_receive(:abort).with("_unknown_error_")
73
- subject.should_receive(:execute_without_handling).and_raise(Teaspoon::Error, "_unknown_error_")
85
+ expect(subject).to receive(:abort).with("_unknown_error_")
86
+ expect(subject).to receive(:execute_without_handling).and_raise(Teaspoon::Error, "_unknown_error_")
74
87
  subject.execute
75
88
  end
76
89
 
77
90
  it "returns false on Teaspoon::Failure" do
78
- subject.should_receive(:execute_without_handling).and_raise(Teaspoon::Failure)
79
- expect(subject.execute).to be_false
91
+ expect(subject).to receive(:execute_without_handling).and_raise(Teaspoon::Failure)
92
+ expect(subject.execute).to be_falsey
80
93
  end
81
94
 
82
95
  end
@@ -84,14 +97,14 @@ describe Teaspoon::Console do
84
97
  describe "#execute_without_handling" do
85
98
 
86
99
  before do
87
- subject.stub(:run_specs).and_return(0)
88
- subject.stub(:export)
100
+ allow(subject).to receive(:run_specs).and_return(0)
101
+ allow(subject).to receive(:export)
89
102
  end
90
103
 
91
- it "merges @options" do
92
- subject.instance_variable_set(:@options, foo: "bar")
104
+ it "merges options" do
105
+ subject.instance_variable_set(:@default_options, foo: "bar")
93
106
  subject.execute_without_handling(bar: "baz")
94
- expect(subject.instance_variable_get(:@options)).to eql(foo: "bar", bar: "baz")
107
+ expect(subject.options).to eql(foo: "bar", bar: "baz")
95
108
  end
96
109
 
97
110
  it "clears any @suites" do
@@ -101,7 +114,7 @@ describe Teaspoon::Console do
101
114
  end
102
115
 
103
116
  it "resolves the files" do
104
- Teaspoon::Suite.should_receive(:resolve_spec_for).with("file").and_return(suite: "foo", path: "file2")
117
+ expect(Teaspoon::Suite).to receive(:resolve_spec_for).with("file").and_return(suite: "foo", path: "file2")
105
118
  subject.execute_without_handling(files: ["file"])
106
119
 
107
120
  expect(subject.send(:suites)).to eq(["foo"])
@@ -110,35 +123,35 @@ describe Teaspoon::Console do
110
123
 
111
124
  it "resolves the files if a directory was given" do
112
125
  resolve_spec_for_output = ['test/javascripts/foo.coffee', 'test/javascripts/bar.coffee']
113
- Teaspoon::Suite.should_receive(:resolve_spec_for).with("full/path").and_return(suite: "foo", path: resolve_spec_for_output)
126
+ expect(Teaspoon::Suite).to receive(:resolve_spec_for).with("full/path").and_return(suite: "foo", path: resolve_spec_for_output)
114
127
  subject.execute_without_handling(files: ["full/path"])
115
128
  expect(subject.send(:suites)).to eq(["foo"])
116
129
  expect(subject.send(:filter, "foo")).to eq("file[]=#{resolve_spec_for_output.join('&file[]=')}")
117
130
  end
118
131
 
119
132
  it "runs the tests" do
120
- subject.should_receive(:suites).and_return([:default, :foo])
121
- subject.should_receive(:run_specs).twice.and_return(2)
122
- expect(subject.execute_without_handling).to be_false
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
123
136
  end
124
137
 
125
138
  it "returns true if no failure count" do
126
- subject.should_receive(:suites).and_return([:default, :foo])
127
- subject.should_receive(:run_specs).twice.and_return(0)
128
- expect(subject.execute_without_handling).to be_true
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
129
142
  end
130
143
 
131
144
  it "returns true if there were failures" do
132
- subject.should_receive(:suites).and_return([:default])
133
- subject.should_receive(:run_specs).once.and_return(1)
134
- expect(subject.execute_without_handling).to be_false
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
135
148
  end
136
149
 
137
150
  it "calls export if the options include :export" do
138
- subject.should_receive(:suites).and_return([:default, :foo])
139
- subject.instance_variable_set(:@options, export: true)
140
- subject.should_receive(:export).with(:default)
141
- subject.should_receive(:export).with(:foo)
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)
142
155
  subject.execute
143
156
  end
144
157
 
@@ -147,33 +160,36 @@ describe Teaspoon::Console do
147
160
  describe "#run_specs" do
148
161
 
149
162
  before do
150
- Teaspoon.configuration.stub(:fail_fast).and_return(false)
151
- Teaspoon.configuration.should_receive(:suite_configs).and_return("_suite_" => proc{}, "suite_name" => proc{})
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{})
152
165
  end
153
166
 
154
167
  it "raises a Teaspoon::UnknownSuite exception when the suite isn't known" do
155
- expect { subject.run_specs("_unknown_") }.to raise_error Teaspoon::UnknownSuite
168
+ expect { subject.run_specs("_unknown_") }.to raise_error(
169
+ Teaspoon::UnknownSuite,
170
+ %{Unknown suite: "_unknown_"}
171
+ )
156
172
  end
157
173
 
158
174
  it "logs that the suite is being run" do
159
- subject.should_receive(:log).with("Teaspoon running _suite_ suite at http://url.com/teaspoon/_suite_")
175
+ expect(subject).to receive(:log).with("Teaspoon running _suite_ suite at http://url.com/teaspoon/_suite_")
160
176
  subject.run_specs("_suite_")
161
177
  end
162
178
 
163
179
  it "calls #run_specs on the driver" do
164
- subject.should_receive(:driver).and_return(driver)
165
- driver.should_receive(:run_specs).with(runner, "http://url.com/teaspoon/suite_name?reporter=Console")
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")
166
182
  expect(subject.run_specs(:suite_name)).to eq(2)
167
183
  end
168
184
 
169
185
  it "raises a Teaspoon::Failure exception on failures when set to fail_fast" do
170
- Teaspoon.configuration.stub(:fail_fast).and_return(true)
186
+ allow(Teaspoon.configuration).to receive(:fail_fast).and_return(true)
171
187
  expect { subject.run_specs(:suite_name) }.to raise_error Teaspoon::Failure
172
188
  end
173
189
 
174
190
  it "raises a Teaspoon:UnknownDriver when an unknown driver is being used" do
175
- Teaspoon.configuration.should_receive(:driver).twice.and_return(:foo)
176
- subject.should_receive(:driver).and_call_original
191
+ expect(Teaspoon.configuration).to receive(:driver).twice.and_return(:foo)
192
+ expect(subject).to receive(:driver).and_call_original
177
193
  expect { subject.run_specs(:suite_name) }.to raise_error Teaspoon::UnknownDriver
178
194
  end
179
195
 
@@ -182,8 +198,8 @@ describe Teaspoon::Console do
182
198
  describe "#export" do
183
199
 
184
200
  before do
185
- Teaspoon.configuration.should_receive(:suite_configs).and_return("_suite_" => proc{}, "suite_name" => proc{})
186
- Teaspoon::Exporter.stub(:new).and_return(double(export: nil))
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))
187
203
  end
188
204
 
189
205
  it "raises a Teaspoon::UnknownSuite exception when the suite isn't known" do
@@ -191,15 +207,15 @@ describe Teaspoon::Console do
191
207
  end
192
208
 
193
209
  it "logs that the suite is being exported" do
194
- subject.should_receive(:log).with("Teaspoon exporting _suite_ suite at http://url.com/teaspoon/_suite_")
210
+ expect(subject).to receive(:log).with("Teaspoon exporting _suite_ suite at http://url.com/teaspoon/_suite_")
195
211
  subject.export("_suite_")
196
212
  end
197
213
 
198
214
  it "calls #export on the exporter" do
199
- subject.instance_variable_set(:@options, export: "_output_path_")
215
+ subject.instance_variable_set(:@default_options, export: "_output_path_")
200
216
  exporter = double(export: nil)
201
- Teaspoon::Exporter.should_receive(:new).with("_suite_", "http://url.com/teaspoon/_suite_", "_output_path_").and_return(exporter)
202
- exporter.should_receive(:export)
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)
203
219
  subject.export("_suite_")
204
220
  end
205
221
 
@@ -8,9 +8,9 @@ describe Teaspoon::Coverage do
8
8
  let(:config) { double }
9
9
 
10
10
  before do
11
- Teaspoon::Instrumentation.stub(:executable).and_return("/path/to/executable")
12
- subject.stub(:`).and_return("")
13
- subject.stub(:input_path).and_yield("/temp_path/coverage.json")
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
14
  subject.instance_variable_set(:@config, config)
15
15
  end
16
16
 
@@ -25,8 +25,8 @@ describe Teaspoon::Coverage do
25
25
  end
26
26
 
27
27
  it "gets the coverage configuration" do
28
- Teaspoon::Coverage.any_instance.should_receive(:coverage_configuration).with("default")
29
- subject = Teaspoon::Coverage.new("_suite_", :default, data)
28
+ expect_any_instance_of(Teaspoon::Coverage).to receive(:coverage_configuration).with("default")
29
+ Teaspoon::Coverage.new("_suite_", :default, data)
30
30
  end
31
31
 
32
32
  end
@@ -37,12 +37,12 @@ describe Teaspoon::Coverage do
37
37
 
38
38
  it "generates reports using istanbul and passes them to the block provided" do
39
39
  `(exit 0)`
40
- html_report = "/path/to/executable report html /temp_path/coverage.json --dir output/path/_suite_ 2>&1"
41
- text1_report = "/path/to/executable report text /temp_path/coverage.json --dir output/path/_suite_ 2>&1"
42
- text2_report = "/path/to/executable report text-summary /temp_path/coverage.json --dir output/path/_suite_ 2>&1"
43
- subject.should_receive(:`).with(html_report).and_return("_html_report_")
44
- subject.should_receive(:`).with(text1_report).and_return("_text1_report_")
45
- subject.should_receive(:`).with(text2_report).and_return("_text2_report_")
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
46
  subject.generate_reports { |r| @result = r }
47
47
  expect(@result).to eq("_text1_report_\n\n_text2_report_")
48
48
  end
@@ -59,24 +59,24 @@ describe Teaspoon::Coverage do
59
59
  let(:config) { double(statements: 42, functions: 66.6, branches: 0, lines: 100) }
60
60
 
61
61
  it "does nothing if there are no threshold checks to make" do
62
- subject.should_receive(:threshold_args).and_return(nil)
63
- subject.should_not_receive(:input_path)
62
+ expect(subject).to receive(:threshold_args).and_return(nil)
63
+ expect(subject).to_not receive(:input_path)
64
64
  subject.check_thresholds {}
65
65
  end
66
66
 
67
67
  it "checks the coverage using istanbul and passes them to the block provided" do
68
68
  `(exit 1)`
69
69
  check_coverage = "/path/to/executable check-coverage --statements=42 --functions=66.6 --branches=0 --lines=100 /temp_path/coverage.json 2>&1"
70
- subject.should_receive(:`).with(check_coverage).and_return("some mumbo jumbo\nERROR: _failure1_\nmore garbage\nERROR: _failure2_")
70
+ expect(subject).to receive(:`).with(check_coverage).and_return("some mumbo jumbo\nERROR: _failure1_\nmore garbage\nERROR: _failure2_")
71
71
  subject.check_thresholds { |r| @result = r }
72
72
  expect(@result).to eq("_failure1_\n_failure2_")
73
73
  end
74
74
 
75
75
  it "doesn't call the callback if the exit status is 0" do
76
76
  `(exit 0)`
77
- subject.should_receive(:`).and_return("ERROR: _failure1_")
77
+ expect(subject).to receive(:`).and_return("ERROR: _failure1_")
78
78
  subject.check_thresholds { |r| @called = true }
79
- expect(@called).to be_false
79
+ expect(@called).to be_falsey
80
80
  end
81
81
 
82
82
  end
@@ -88,9 +88,9 @@ describe Teaspoon::Coverage do
88
88
  before do
89
89
  Teaspoon::Instrumentation.instance_variable_set(:@executable, nil)
90
90
  Teaspoon::Instrumentation.instance_variable_set(:@executable_checked, nil)
91
- Teaspoon::Instrumentation.should_receive(:executable).and_call_original
92
- subject.should_receive(:input_path).and_call_original
93
- subject.should_receive(:`).and_call_original
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
94
 
95
95
  executable = Teaspoon::Instrumentation.executable
96
96
  pending('needs istanbul to be installed') unless executable
@@ -101,15 +101,15 @@ describe Teaspoon::Coverage do
101
101
  it "generates coverage reports" do
102
102
  subject.generate_reports { |r| @report = r }
103
103
  expect(@report).to eq <<-RESULT.strip_heredoc + "\n"
104
- -------------------------+-----------+-----------+-----------+-----------+
104
+ -------------------------|-----------|-----------|-----------|-----------|
105
105
  File | % Stmts |% Branches | % Funcs | % Lines |
106
- -------------------------+-----------+-----------+-----------+-----------+
106
+ -------------------------|-----------|-----------|-----------|-----------|
107
107
  integration/ | 90.91 | 100 | 75 | 90.91 |
108
108
  integration.coffee | 75 | 100 | 50 | 75 |
109
109
  spec_helper.coffee | 100 | 100 | 100 | 100 |
110
- -------------------------+-----------+-----------+-----------+-----------+
110
+ -------------------------|-----------|-----------|-----------|-----------|
111
111
  All files | 90.91 | 100 | 75 | 90.91 |
112
- -------------------------+-----------+-----------+-----------+-----------+
112
+ -------------------------|-----------|-----------|-----------|-----------|
113
113
  RESULT
114
114
  end
115
115