|
5 | 5 |
|
6 | 6 | require "fixtures" |
7 | 7 |
|
| 8 | +class Target |
| 9 | + def print(output) |
| 10 | + output.write("target") |
| 11 | + end |
| 12 | +end |
| 13 | + |
8 | 14 | describe Sus::Config do |
9 | 15 | include Fixtures |
10 | 16 |
|
|
14 | 20 | it "can load config from file" do |
15 | 21 | expect(config).not.to be(:nil?) |
16 | 22 | end |
| 23 | + |
| 24 | + with "summary output" do |
| 25 | + let(:io) {StringIO.new} |
| 26 | + let(:output) {Sus::Output::Text.new(io)} |
| 27 | + let(:assertions) {Sus::Assertions.new(output: Sus::Output.buffered)} |
| 28 | + |
| 29 | + with "errors and no assertions" do |
| 30 | + it "suppresses laudatory output but prints timing" do |
| 31 | + assertions.nested(Target.new, isolated: true) do |nested| |
| 32 | + nested.error!(RuntimeError.new("load error")) |
| 33 | + end |
| 34 | + |
| 35 | + config.before_tests(assertions, output: output) |
| 36 | + config.after_tests(assertions, output: output) |
| 37 | + |
| 38 | + expect(io.string).to be(:include?, "🏴 Finished in") |
| 39 | + expect(io.string).not.to be(:include?, "assertions per second") |
| 40 | + expect(io.string).not.to be(:include?, "No slow tests found") |
| 41 | + expect(io.string).to be(:include?, "Errored assertions") |
| 42 | + end |
| 43 | + end |
| 44 | + |
| 45 | + with "no assertions and no errors" do |
| 46 | + it "suppresses laudatory output but prints timing" do |
| 47 | + config.before_tests(assertions, output: output) |
| 48 | + config.after_tests(assertions, output: output) |
| 49 | + |
| 50 | + expect(io.string).to be(:include?, "🏴 Finished in") |
| 51 | + expect(io.string).not.to be(:include?, "assertions per second") |
| 52 | + expect(io.string).not.to be(:include?, "No slow tests found") |
| 53 | + end |
| 54 | + end |
| 55 | + |
| 56 | + with "passing assertions" do |
| 57 | + it "prints statistics and slow test output" do |
| 58 | + assertions.nested(Target.new, isolated: true, measure: true) do |nested| |
| 59 | + nested.assert(true) |
| 60 | + end |
| 61 | + |
| 62 | + config.before_tests(assertions, output: output) |
| 63 | + config.after_tests(assertions, output: output) |
| 64 | + |
| 65 | + expect(io.string).to be(:include?, "Finished in") |
| 66 | + expect(io.string).to be(:include?, "No slow tests found") |
| 67 | + end |
| 68 | + end |
| 69 | + end |
17 | 70 | end |
0 commit comments