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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a6ee9731972b91a28abe4fc4b8c560508db30f76
4
- data.tar.gz: 2f85cde2168bc1073d85e826a7b6645f43db271e
3
+ metadata.gz: 4c8c48bd8f7f861b6222d443bfa92df522b3808f
4
+ data.tar.gz: 0a8d82cb15fc5bc6e4fd9c7d663bdc246b160680
5
5
  SHA512:
6
- metadata.gz: 3b1d0ff41b673f6c0cf6d0b97d17a70fb9721f858ab9d97f29a68af42e9e2089f37ee5dff6fe11edc80becd1c2222747146045040fc53b1777f55c0aeab91244
7
- data.tar.gz: 5569c70f0570483713ee28a074cc07bf9027c04a29383651091a8fa8eab442c2bd42d466845411000e2af9021cc3137a80f6aee1fa2eb1efe28e4d3b9b58d6a1
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.2)
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.7.0)
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)
@@ -1,3 +1,3 @@
1
1
  module Swiftformat
2
- VERSION = "0.0.2".freeze
2
+ VERSION = "0.0.3".freeze
3
3
  end
@@ -27,6 +27,9 @@ module Danger
27
27
  # Find Swift files
28
28
  swift_files = find_swift_files
29
29
 
30
+ # Stop processing if there are no swift files
31
+ return if swift_files.empty?
32
+
30
33
  # Run swiftformat
31
34
  results = swiftformat.check_format(swift_files)
32
35
 
@@ -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 swiftformat does not find any errors" do
39
+ context "when there are no swift files to check" do
46
40
  before do
47
- allow_any_instance_of(SwiftFormat).to receive(:check_format).with(%w(Added.swift Modified.swift)).and_return(success_output)
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 swiftformat finds errors" do
55
+ context "when there are swift files to check" do
60
56
  before do
61
- allow_any_instance_of(SwiftFormat).to receive(:check_format).with(%w(Added.swift Modified.swift)).and_return(error_output)
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
- it "should output some markdown and error if fail_on_error is true" do
65
- @sut.check_format(fail_on_error: true)
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
- status = @sut.status_report
68
- expect(status[:errors]).to_not be_empty
69
- expect(status[:markdowns]).to_not be_empty
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
- it "should output some markdown and not error if fail_on_error is false" do
73
- @sut.check_format(fail_on_error: false)
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
- status = @sut.status_report
76
- expect(status[:errors]).to be_empty
77
- expect(status[:markdowns]).to_not be_empty
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-swiftformat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vincent Garrigues