danger-swiftformat 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/swiftformat/gem_version.rb +1 -1
- data/lib/swiftformat/plugin.rb +3 -0
- data/spec/swiftformat/plugin_spec.rb +39 -20
- 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: 4c8c48bd8f7f861b6222d443bfa92df522b3808f
|
4
|
+
data.tar.gz: 0a8d82cb15fc5bc6e4fd9c7d663bdc246b160680
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95dc50ab3b0fdea5415783920e82c231619472bcf8c07e8d9b70a97496100a8f2147b218c0db082232f36c5ed05209a21d41dab9fde5f59504abfdc20b254b2e
|
7
|
+
data.tar.gz: a509022e22ab09438da6f9098c47857d1cbb7e846ed4e0b9037b6192ef3c0e31973a2fdd1a0104ed1aee910f4bdc7a6d961d72185aec3f2f2e7d8410d7bba02a
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
danger-swiftformat (0.0.
|
4
|
+
danger-swiftformat (0.0.3)
|
5
5
|
danger-plugin-api (~> 1.0)
|
6
6
|
|
7
7
|
GEM
|
@@ -69,7 +69,7 @@ GEM
|
|
69
69
|
notiffany (0.1.1)
|
70
70
|
nenv (~> 0.1)
|
71
71
|
shellany (~> 0.0)
|
72
|
-
octokit (4.
|
72
|
+
octokit (4.8.0)
|
73
73
|
sawyer (~> 0.8.0, >= 0.5.3)
|
74
74
|
open4 (1.3.4)
|
75
75
|
parallel (1.12.1)
|
data/lib/swiftformat/plugin.rb
CHANGED
@@ -35,16 +35,12 @@ module Danger
|
|
35
35
|
let(:success_output) { { errors: [], stats: { run_time: "0.08s" } } }
|
36
36
|
let(:error_output) { { errors: [{ file: "Modified.swift", rules: %w(firstRule secondRule) }], stats: { run_time: "0.16s" } } }
|
37
37
|
|
38
|
-
before do
|
39
|
-
allow_any_instance_of(SwiftFormat).to receive(:installed?).and_return(true)
|
40
|
-
allow(@sut.git).to receive(:added_files).and_return(["Added.swift"])
|
41
|
-
allow(@sut.git).to receive(:modified_files).and_return(["Modified.swift"])
|
42
|
-
allow(@sut.git).to receive(:deleted_files).and_return(["Deleted.swift"])
|
43
|
-
end
|
44
38
|
|
45
|
-
context "when
|
39
|
+
context "when there are no swift files to check" do
|
46
40
|
before do
|
47
|
-
|
41
|
+
allow(@sut.git).to receive(:added_files).and_return(["Added.m"])
|
42
|
+
allow(@sut.git).to receive(:modified_files).and_return(["Modified.m"])
|
43
|
+
allow(@sut.git).to receive(:deleted_files).and_return(["Deleted.m"])
|
48
44
|
end
|
49
45
|
|
50
46
|
it "should not do anything" do
|
@@ -56,25 +52,48 @@ module Danger
|
|
56
52
|
end
|
57
53
|
end
|
58
54
|
|
59
|
-
context "when
|
55
|
+
context "when there are swift files to check" do
|
60
56
|
before do
|
61
|
-
allow_any_instance_of(SwiftFormat).to receive(:
|
57
|
+
allow_any_instance_of(SwiftFormat).to receive(:installed?).and_return(true)
|
58
|
+
allow(@sut.git).to receive(:added_files).and_return(["Added.swift"])
|
59
|
+
allow(@sut.git).to receive(:modified_files).and_return(["Modified.swift"])
|
60
|
+
allow(@sut.git).to receive(:deleted_files).and_return(["Deleted.swift"])
|
62
61
|
end
|
63
62
|
|
64
|
-
|
65
|
-
|
63
|
+
context "when swiftformat does not find any errors" do
|
64
|
+
before do
|
65
|
+
allow_any_instance_of(SwiftFormat).to receive(:check_format).with(%w(Added.swift Modified.swift)).and_return(success_output)
|
66
|
+
end
|
66
67
|
|
67
|
-
|
68
|
-
|
69
|
-
|
68
|
+
it "should not do anything" do
|
69
|
+
@sut.check_format(fail_on_error: true)
|
70
|
+
|
71
|
+
status = @sut.status_report
|
72
|
+
expect(status[:errors]).to be_empty
|
73
|
+
expect(status[:markdowns]).to be_empty
|
74
|
+
end
|
70
75
|
end
|
71
76
|
|
72
|
-
|
73
|
-
|
77
|
+
context "when swiftformat finds errors" do
|
78
|
+
before do
|
79
|
+
allow_any_instance_of(SwiftFormat).to receive(:check_format).with(%w(Added.swift Modified.swift)).and_return(error_output)
|
80
|
+
end
|
74
81
|
|
75
|
-
|
76
|
-
|
77
|
-
|
82
|
+
it "should output some markdown and error if fail_on_error is true" do
|
83
|
+
@sut.check_format(fail_on_error: true)
|
84
|
+
|
85
|
+
status = @sut.status_report
|
86
|
+
expect(status[:errors]).to_not be_empty
|
87
|
+
expect(status[:markdowns]).to_not be_empty
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should output some markdown and not error if fail_on_error is false" do
|
91
|
+
@sut.check_format(fail_on_error: false)
|
92
|
+
|
93
|
+
status = @sut.status_report
|
94
|
+
expect(status[:errors]).to be_empty
|
95
|
+
expect(status[:markdowns]).to_not be_empty
|
96
|
+
end
|
78
97
|
end
|
79
98
|
end
|
80
99
|
end
|