File tree 2 files changed +34
-6
lines changed
lib/overcommit/hook/pre_commit
spec/overcommit/hook/pre_commit
2 files changed +34
-6
lines changed Original file line number Diff line number Diff line change @@ -6,8 +6,8 @@ class Scalastyle < Base
6
6
MESSAGE_REGEX = /
7
7
^(?<type>error|warning)\s
8
8
file=(?<file>(?:\w :)?.+)\s
9
- message=.+\s
10
- line=(?<line>\d +)
9
+ message=.+\s *
10
+ ( line=(?<line>\d +))?
11
11
/x
12
12
13
13
def run
Original file line number Diff line number Diff line change 41
41
OUT
42
42
end
43
43
44
- it { should warn }
44
+ it { should warn ( /Use : Unit = for procedures/ ) }
45
+ end
46
+
47
+ context 'and it reports a warning with no line' do
48
+ before do
49
+ result . stub ( stderr : '' , stdout : normalize_indent ( <<-OUT ) )
50
+ warning file=file1.scala message=File must end with newline character
51
+ Processed 1 file(s)
52
+ Found 0 errors
53
+ Found 1 warnings
54
+ Finished in 490 ms
55
+ OUT
56
+ end
57
+
58
+ it { should warn ( /File must end with newline character/ ) }
45
59
end
46
60
end
47
61
64
78
OUT
65
79
end
66
80
67
- it { should fail_hook }
81
+ it { should fail_hook ( /Use : Unit = for procedures/ ) }
82
+ end
83
+
84
+ context 'and it reports an error with no line' do
85
+ before do
86
+ result . stub ( stderr : '' , stdout : normalize_indent ( <<-OUT ) )
87
+ error file=file1.scala message=File must end with newline character
88
+ Processed 1 file(s)
89
+ Found 1 errors
90
+ Found 0 warnings
91
+ Finished in 490 ms
92
+ OUT
93
+ end
94
+
95
+ it { should fail_hook ( /File must end with newline character/ ) }
68
96
end
69
97
70
98
context 'with a usage message' do
83
111
OUT
84
112
end
85
113
86
- it { should fail_hook }
114
+ it { should fail_hook ( /Usage/ ) }
87
115
end
88
116
89
117
context 'with a runtime error' do
104
132
ERR
105
133
end
106
134
107
- it { should fail_hook }
135
+ it { should fail_hook ( /Exception/ ) }
108
136
end
109
137
end
110
138
end
You can’t perform that action at this time.
0 commit comments