|
19 | 19 |
|
20 | 20 | context 'with no errors or warnings' do
|
21 | 21 | before do
|
22 |
| - result.stub(:stdout).and_return([ |
23 |
| - 'Processed 1 file(s)', |
24 |
| - 'Found 0 errors', |
25 |
| - 'Found 0 warnings', |
26 |
| - 'Finished in 490 ms' |
27 |
| - ].join("\n")) |
| 22 | + result.stub(stderr: '', stdout: normalize_indent(<<-OUT)) |
| 23 | + Processed 1 file(s) |
| 24 | + Found 0 errors |
| 25 | + Found 0 warnings |
| 26 | + Finished in 490 ms |
| 27 | + OUT |
28 | 28 | end
|
29 | 29 |
|
30 | 30 | it { should pass }
|
31 | 31 | end
|
32 | 32 |
|
33 | 33 | context 'and it reports a warning' do
|
34 | 34 | before do
|
35 |
| - result.stub(:stdout).and_return([ |
36 |
| - 'warning file=file1.scala message=Use : Unit = for procedures line=1 column=15', |
37 |
| - 'Processed 1 file(s)', |
38 |
| - 'Found 0 errors', |
39 |
| - 'Found 1 warnings', |
40 |
| - 'Finished in 490 ms' |
41 |
| - ].join("\n")) |
| 35 | + result.stub(stderr: '', stdout: normalize_indent(<<-OUT)) |
| 36 | + warning file=file1.scala message=Use : Unit = for procedures line=1 column=15 |
| 37 | + Processed 1 file(s) |
| 38 | + Found 0 errors |
| 39 | + Found 1 warnings |
| 40 | + Finished in 490 ms |
| 41 | + OUT |
42 | 42 | end
|
43 | 43 |
|
44 | 44 | it { should warn }
|
45 | 45 | end
|
46 | 46 | end
|
47 | 47 |
|
48 |
| - context 'when scalastyle exits unsucessfully' do |
| 48 | + context 'when scalastyle exits unsuccessfully' do |
49 | 49 | let(:result) { double('result') }
|
50 | 50 |
|
51 | 51 | before do
|
|
55 | 55 |
|
56 | 56 | context 'and it reports an error' do
|
57 | 57 | before do
|
58 |
| - result.stub(:stdout).and_return([ |
59 |
| - 'error file=file1.scala message=Use : Unit = for procedures line=1 column=15', |
60 |
| - 'Processed 1 file(s)', |
61 |
| - 'Found 1 errors', |
62 |
| - 'Found 0 warnings', |
63 |
| - 'Finished in 490 ms' |
64 |
| - ].join("\n")) |
| 58 | + result.stub(stderr: '', stdout: normalize_indent(<<-OUT)) |
| 59 | + error file=file1.scala message=Use : Unit = for procedures line=1 column=15 |
| 60 | + Processed 1 file(s) |
| 61 | + Found 1 errors |
| 62 | + Found 0 warnings |
| 63 | + Finished in 490 ms |
| 64 | + OUT |
| 65 | + end |
| 66 | + |
| 67 | + it { should fail_hook } |
| 68 | + end |
| 69 | + |
| 70 | + context 'with a usage message' do |
| 71 | + before do |
| 72 | + result.stub(stderr: '', stdout: normalize_indent(<<-OUT)) |
| 73 | + scalastyle 0.7.0 |
| 74 | + Usage: scalastyle [options] <source directory> |
| 75 | + -c, --config FILE configuration file (required) |
| 76 | + -v, --verbose true|false verbose output |
| 77 | + -q, --quiet true|false be quiet |
| 78 | + --xmlOutput FILE write checkstyle format output to this file |
| 79 | + --xmlEncoding STRING encoding to use for the xml file |
| 80 | + --inputEncoding STRING encoding for the source files |
| 81 | + -w, --warnings true|false fail if there are warnings |
| 82 | + -e, --externalJar FILE jar containing custom rules |
| 83 | + OUT |
| 84 | + end |
| 85 | + |
| 86 | + it { should fail_hook } |
| 87 | + end |
| 88 | + |
| 89 | + context 'with a runtime error' do |
| 90 | + before do |
| 91 | + # rubocop:disable Metrics/LineLength |
| 92 | + result.stub(stdout: '', stderr: normalize_indent(<<-ERR)) |
| 93 | + Exception in thread "main" java.io.FileNotFoundException: scalastyle-config.xml (No such file or directory) |
| 94 | + at java.io.FileInputStream.open0(Native Method) |
| 95 | + at java.io.FileInputStream.open(FileInputStream.java:195) |
| 96 | + at java.io.FileInputStream.<init>(FileInputStream.java:138) |
| 97 | + at java.io.FileInputStream.<init>(FileInputStream.java:93) |
| 98 | + at scala.xml.Source$.fromFile(XML.scala:22) |
| 99 | + at scala.xml.factory.XMLLoader$class.loadFile(XMLLoader.scala:50) |
| 100 | + at scala.xml.XML$.loadFile(XML.scala:60) |
| 101 | + at org.scalastyle.ScalastyleConfiguration$.readFromXml(ScalastyleConfiguration.scala:87) |
| 102 | + at org.scalastyle.Main$.execute(Main.scala:106) |
| 103 | + at org.scalastyle.Main$.main(Main.scala:95) |
| 104 | + at org.scalastyle.Main.main(Main.scala) |
| 105 | + ERR |
| 106 | + # rubocop:enable Metrics/LineLength |
65 | 107 | end
|
66 | 108 |
|
67 | 109 | it { should fail_hook }
|
|
0 commit comments