danger-slather 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/slather/gem_version.rb +1 -1
- data/lib/slather/plugin.rb +15 -8
- data/spec/slather_spec.rb +30 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba3f7cf814e5c7c34df8ba4dc7eaf2a2a4feb131
|
4
|
+
data.tar.gz: 022e6952680d03141cae1a2784fc4e8480f751a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94caa281818749952ac7dba39aca501650b39881cb0df8fcf3860e3d00b969b8f20e64c2cece449f79b31a2da6ee9fe80774cf1221039da9ed5ba028051ae9ed
|
7
|
+
data.tar.gz: e36e75e82569157ab01f3e385b88bdad1898658877635f84f4e93cd3864f34e4f8d3ad49ada13186e42e218bcab03b56ed2ef19e7166068e9f4e29270112b929
|
data/Gemfile.lock
CHANGED
data/lib/slather/gem_version.rb
CHANGED
data/lib/slather/plugin.rb
CHANGED
@@ -78,8 +78,8 @@ module Danger
|
|
78
78
|
minimum_coverage = options[:minimum_coverage]
|
79
79
|
notify_level = options[:notify_level] || :fail
|
80
80
|
|
81
|
-
if
|
82
|
-
files_to_notify =
|
81
|
+
if all_modified_files_coverage.count > 0
|
82
|
+
files_to_notify = all_modified_files_coverage.select do |file|
|
83
83
|
file.percentage_lines_tested < minimum_coverage
|
84
84
|
end
|
85
85
|
notify_messages = files_to_notify.map do |file|
|
@@ -117,10 +117,10 @@ module Danger
|
|
117
117
|
def modified_files_coverage_table
|
118
118
|
unless @project.nil?
|
119
119
|
line = ''
|
120
|
-
if
|
120
|
+
if all_modified_files_coverage.count > 0
|
121
121
|
line << "File | Coverage\n"
|
122
122
|
line << "-----|-----\n"
|
123
|
-
|
123
|
+
all_modified_files_coverage.each do |coverage_file|
|
124
124
|
file_name = coverage_file.source_file_pathname_relative_to_repo_root.to_s
|
125
125
|
percentage = @project.decimal_f([coverage_file.percentage_lines_tested])
|
126
126
|
line << "#{file_name} | **`#{percentage}%`**\n"
|
@@ -152,14 +152,21 @@ module Danger
|
|
152
152
|
|
153
153
|
# Array of files that we have coverage information and was modified
|
154
154
|
# @return [Array<File>]
|
155
|
-
def
|
155
|
+
def all_modified_files_coverage
|
156
156
|
unless @project.nil?
|
157
|
-
|
158
|
-
git.modified_files.
|
157
|
+
all_modified_files_coverage ||= begin
|
158
|
+
modified_files = git.modified_files.nil? ? [] : git.modified_files
|
159
|
+
added_files = git.added_files.nil? ? [] : git.added_files
|
160
|
+
all_changed_files = modified_files | added_files
|
161
|
+
@project.coverage_files.select do |file|
|
162
|
+
all_changed_files.include? file.source_file_pathname_relative_to_repo_root.to_s
|
163
|
+
end
|
159
164
|
end
|
165
|
+
|
166
|
+
all_modified_files_coverage
|
160
167
|
end
|
161
168
|
end
|
162
169
|
|
163
|
-
private :
|
170
|
+
private :all_modified_files_coverage, :total_coverage_markdown
|
164
171
|
end
|
165
172
|
end
|
data/spec/slather_spec.rb
CHANGED
@@ -32,6 +32,7 @@ module Danger
|
|
32
32
|
describe 'notify_if_modified_file_is_less_than' do
|
33
33
|
it 'Should only fails on modified files' do
|
34
34
|
@dangerfile.git.stubs(:modified_files).returns(['AppDelegate.swift'])
|
35
|
+
@dangerfile.git.stubs(:added_files).returns([])
|
35
36
|
|
36
37
|
@project_mock.stubs(:coverage_files).returns(
|
37
38
|
[
|
@@ -52,6 +53,7 @@ module Danger
|
|
52
53
|
|
53
54
|
it 'Should not fail if coverage is higher than parameter' do
|
54
55
|
@dangerfile.git.stubs(:modified_files).returns(['AppDelegate.swift'])
|
56
|
+
@dangerfile.git.stubs(:added_files).returns([])
|
55
57
|
|
56
58
|
@project_mock.stubs(:coverage_files).returns(
|
57
59
|
[
|
@@ -66,6 +68,7 @@ module Danger
|
|
66
68
|
|
67
69
|
it 'Should add warning if notify_level is warning' do
|
68
70
|
@dangerfile.git.stubs(:modified_files).returns(['AppDelegate.swift'])
|
71
|
+
@dangerfile.git.stubs(:added_files).returns([])
|
69
72
|
|
70
73
|
@project_mock.stubs(:coverage_files).returns(
|
71
74
|
[
|
@@ -82,6 +85,28 @@ module Danger
|
|
82
85
|
]
|
83
86
|
)
|
84
87
|
end
|
88
|
+
|
89
|
+
it 'Should count new files' do
|
90
|
+
@dangerfile.git.stubs(:modified_files).returns(['AppDelegate.swift'])
|
91
|
+
@dangerfile.git.stubs(:added_files).returns(['ViewController.swift'])
|
92
|
+
|
93
|
+
@project_mock.stubs(:coverage_files).returns(
|
94
|
+
[
|
95
|
+
mock_file('AppDelegate.swift', 10),
|
96
|
+
mock_file('ViewController.swift', 10)
|
97
|
+
]
|
98
|
+
)
|
99
|
+
|
100
|
+
@my_plugin.notify_if_modified_file_is_less_than(minimum_coverage: 50, notify_level: :warning)
|
101
|
+
|
102
|
+
expect(@dangerfile.status_report[:errors]).to eq([])
|
103
|
+
expect(@dangerfile.status_report[:warnings]).to eq(
|
104
|
+
[
|
105
|
+
'AppDelegate.swift has less than 50% code coverage',
|
106
|
+
'ViewController.swift has less than 50% code coverage'
|
107
|
+
]
|
108
|
+
)
|
109
|
+
end
|
85
110
|
end
|
86
111
|
|
87
112
|
describe 'notify_if_coverage_is_less_than' do
|
@@ -155,7 +180,11 @@ module Danger
|
|
155
180
|
[
|
156
181
|
'AppDelegate.swift',
|
157
182
|
'ViewController.swift',
|
158
|
-
'ViewController2.swift'
|
183
|
+
'ViewController2.swift'
|
184
|
+
]
|
185
|
+
)
|
186
|
+
@dangerfile.git.stubs(:added_files).returns(
|
187
|
+
[
|
159
188
|
'ViewController3.swift',
|
160
189
|
'ViewController4.swift'
|
161
190
|
]
|