gergich 0.2.2 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/LICENSE +2 -2
- data/README.md +0 -1
- data/bin/check_coverage +2 -1
- data/bin/gergich +1 -0
- data/bin/master_bouncer +1 -1
- data/bin/run_tests.sh +8 -43
- data/lib/gergich.rb +20 -24
- data/lib/gergich/capture.rb +8 -4
- data/lib/gergich/capture/androidlint_capture.rb +5 -1
- data/lib/gergich/capture/brakeman_capture.rb +4 -2
- data/lib/gergich/capture/eslint_capture.rb +2 -0
- data/lib/gergich/capture/flake8_capture.rb +2 -0
- data/lib/gergich/capture/i18nliner_capture.rb +2 -0
- data/lib/gergich/capture/rubocop_capture.rb +2 -0
- data/lib/gergich/capture/shellcheck_capture.rb +2 -0
- data/lib/gergich/capture/stylelint_capture.rb +8 -5
- data/lib/gergich/capture/swiftlint_capture.rb +5 -1
- data/lib/gergich/cli.rb +4 -2
- data/lib/gergich/cli/gergich.rb +119 -118
- data/lib/gergich/cli/master_bouncer.rb +16 -14
- data/spec/gergich/capture/androidlint_capture_spec.rb +15 -10
- data/spec/gergich/capture/brakeman_capture_spec.rb +43 -41
- data/spec/gergich/capture/custom_capture_spec.rb +4 -2
- data/spec/gergich/capture/eslint_capture_spec.rb +6 -4
- data/spec/gergich/capture/flake8_capture_spec.rb +4 -2
- data/spec/gergich/capture/i18nliner_capture_spec.rb +6 -4
- data/spec/gergich/capture/rubocop_capture_spec.rb +24 -22
- data/spec/gergich/capture/shellcheck_capture_spec.rb +45 -43
- data/spec/gergich/capture/stylelint_capture_spec.rb +16 -7
- data/spec/gergich/capture/swiftlint_capture_spec.rb +8 -5
- data/spec/gergich/capture_spec.rb +6 -4
- data/spec/gergich_spec.rb +58 -4
- data/spec/spec_helper.rb +2 -0
- data/spec/support/capture_shared_examples.rb +2 -0
- metadata +39 -40
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative "../../support/capture_shared_examples"
|
2
4
|
|
3
5
|
RSpec.describe Gergich::Capture::BrakemanCapture do
|
@@ -10,75 +12,75 @@ RSpec.describe Gergich::Capture::BrakemanCapture do
|
|
10
12
|
let(:comments) do
|
11
13
|
[
|
12
14
|
{
|
13
|
-
path:
|
15
|
+
path: "app/models/custom_data.rb",
|
14
16
|
position: 36,
|
15
|
-
message:
|
16
|
-
[brakeman] Attribute Restriction: attr_accessible is recommended over attr_protected
|
17
|
-
|
18
|
-
|
17
|
+
message: <<~MESSAGE.strip,
|
18
|
+
[brakeman] Attribute Restriction: attr_accessible is recommended over attr_protected
|
19
|
+
See: http://brakemanscanner.org/docs/warning_types/attribute_restriction/
|
20
|
+
MESSAGE
|
19
21
|
severity: "warn"
|
20
22
|
},
|
21
23
|
{
|
22
|
-
path:
|
24
|
+
path: "app/models/submission_comment.rb",
|
23
25
|
position: 0,
|
24
|
-
message:
|
25
|
-
[brakeman] Mass Assignment: Potentially dangerous attribute available for mass assignment
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
message: <<~MESSAGE.strip,
|
27
|
+
[brakeman] Mass Assignment: Potentially dangerous attribute available for mass assignment
|
28
|
+
Code: :context_id
|
29
|
+
See: http://brakemanscanner.org/docs/warning_types/mass_assignment/
|
30
|
+
MESSAGE
|
29
31
|
severity: "warn"
|
30
32
|
},
|
31
33
|
{
|
32
|
-
path:
|
34
|
+
path: "app/controllers/context_controller.rb",
|
33
35
|
position: 60,
|
34
|
-
message:
|
35
|
-
[brakeman] Redirect: Possible unprotected redirect
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
message: <<~MESSAGE.strip,
|
37
|
+
[brakeman] Redirect: Possible unprotected redirect
|
38
|
+
Code: redirect_to(CanvasKaltura::ClientV3.new.assetSwfUrl(params[:id]))
|
39
|
+
User Input: params[:id]
|
40
|
+
See: http://brakemanscanner.org/docs/warning_types/redirect/
|
41
|
+
MESSAGE
|
40
42
|
severity: "warn"
|
41
43
|
},
|
42
44
|
{
|
43
|
-
path:
|
45
|
+
path: "app/views/context/object_snippet.html.erb",
|
44
46
|
position: 6,
|
45
|
-
message:
|
46
|
-
[brakeman] Cross Site Scripting: Unescaped parameter value
|
47
|
-
|
48
|
-
|
49
|
-
|
47
|
+
message: <<~MESSAGE.strip,
|
48
|
+
[brakeman] Cross Site Scripting: Unescaped parameter value
|
49
|
+
Code: Base64.decode64((params[:object_data] or ""))
|
50
|
+
User Input: params[:object_data]
|
51
|
+
See: http://brakemanscanner.org/docs/warning_types/cross_site_scripting
|
50
52
|
MESSAGE
|
51
53
|
severity: "warn"
|
52
54
|
},
|
53
55
|
{
|
54
|
-
path:
|
56
|
+
path: "app/models/account.rb",
|
55
57
|
position: 795,
|
56
|
-
message:
|
57
|
-
[brakeman] SQL Injection: Possible SQL injection
|
58
|
-
|
59
|
-
|
60
|
-
|
58
|
+
message: <<~MESSAGE.strip,
|
59
|
+
[brakeman] SQL Injection: Possible SQL injection
|
60
|
+
Code: Account.find_by_sql(Account.sub_account_ids_recursive_sql(parent_account_id))
|
61
|
+
User Input: Account.sub_account_ids_recursive_sql(parent_account_id)
|
62
|
+
See: http://brakemanscanner.org/docs/warning_types/sql_injection/
|
61
63
|
MESSAGE
|
62
64
|
severity: "error"
|
63
65
|
},
|
64
66
|
{
|
65
|
-
path:
|
67
|
+
path: "lib/cc/importer/blti_converter.rb",
|
66
68
|
position: 145,
|
67
|
-
message:
|
68
|
-
[brakeman] SSL Verification Bypass: SSL certificate verification was bypassed
|
69
|
-
|
70
|
-
|
69
|
+
message: <<~MESSAGE.strip,
|
70
|
+
[brakeman] SSL Verification Bypass: SSL certificate verification was bypassed
|
71
|
+
Code: Net::HTTP.new(URI.parse(url).host, URI.parse(url).port).verify_mode = OpenSSL::SSL::VERIFY_NONE
|
72
|
+
See: http://brakemanscanner.org/docs/warning_types/ssl_verification_bypass/
|
71
73
|
MESSAGE
|
72
74
|
severity: "error"
|
73
75
|
},
|
74
76
|
{
|
75
|
-
path:
|
77
|
+
path: "lib/cc/importer/canvas/quiz_converter.rb",
|
76
78
|
position: 44,
|
77
|
-
message:
|
78
|
-
[brakeman] Command Injection: Possible command injection
|
79
|
-
|
80
|
-
|
81
|
-
|
79
|
+
message: <<~MESSAGE.strip,
|
80
|
+
[brakeman] Command Injection: Possible command injection
|
81
|
+
Code: `\#{Qti.get_conversion_command(File.join(qti_folder, "qti_2_1"), qti_folder)}`
|
82
|
+
User Input: Qti.get_conversion_command(File.join(qti_folder, "qti_2_1"), qti_folder)
|
83
|
+
See: http://brakemanscanner.org/docs/warning_types/command_injection/
|
82
84
|
MESSAGE
|
83
85
|
severity: "warn"
|
84
86
|
}
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative "../../../lib/gergich/capture"
|
2
4
|
|
3
5
|
RSpec.describe "CustomCaptor" do
|
@@ -12,8 +14,8 @@ RSpec.describe "CustomCaptor" do
|
|
12
14
|
let(:described_class) { CustomCaptor }
|
13
15
|
let(:capture_format) { "custom:sqlite3:CustomCaptor" }
|
14
16
|
let(:output) do
|
15
|
-
|
16
|
-
foo.rb:1: you done screwed up
|
17
|
+
<<~OUTPUT
|
18
|
+
foo.rb:1: you done screwed up
|
17
19
|
OUTPUT
|
18
20
|
end
|
19
21
|
let(:comments) do
|
@@ -1,11 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative "../../support/capture_shared_examples"
|
2
4
|
|
3
5
|
RSpec.describe Gergich::Capture::EslintCapture do
|
4
6
|
let(:output) do
|
5
|
-
|
6
|
-
jsapp/models/user.js
|
7
|
-
|
8
|
-
|
7
|
+
<<~OUTPUT
|
8
|
+
jsapp/models/user.js
|
9
|
+
4:21 error Missing semicolon semi
|
10
|
+
5:1 warning Too much cowbell cowbell-overload
|
9
11
|
OUTPUT
|
10
12
|
end
|
11
13
|
let(:comments) do
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative "../../support/capture_shared_examples"
|
2
4
|
|
3
5
|
RSpec.describe Gergich::Capture::Flake8Capture do
|
4
6
|
let(:output) do
|
5
|
-
|
6
|
-
./djangogeneric/settings/base.py:73:80: E501 line too long (81 > 79 characters)
|
7
|
+
<<~OUTPUT
|
8
|
+
./djangogeneric/settings/base.py:73:80: E501 line too long (81 > 79 characters)
|
7
9
|
OUTPUT
|
8
10
|
end
|
9
11
|
let(:comments) do
|
@@ -1,11 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative "../../support/capture_shared_examples"
|
2
4
|
|
3
5
|
RSpec.describe Gergich::Capture::I18nlinerCapture do
|
4
6
|
let(:output) do
|
5
|
-
|
6
|
-
1)
|
7
|
-
invalid signature on line 4: <unsupported expression>
|
8
|
-
jsapp/models/user.js
|
7
|
+
<<~OUTPUT
|
8
|
+
1)
|
9
|
+
invalid signature on line 4: <unsupported expression>
|
10
|
+
jsapp/models/user.js
|
9
11
|
OUTPUT
|
10
12
|
end
|
11
13
|
let(:comments) do
|
@@ -1,22 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative "../../support/capture_shared_examples"
|
2
4
|
|
3
5
|
RSpec.describe Gergich::Capture::RubocopCapture do
|
4
6
|
let(:output) do
|
5
|
-
|
6
|
-
Offenses:
|
7
|
+
<<~OUTPUT
|
8
|
+
Offenses:
|
7
9
|
|
8
|
-
bin/gergich:47:8: C: Prefer double-quoted strings
|
9
|
-
if ENV['DEBUG']
|
10
|
-
|
11
|
-
foo/bar/baz.rb:1:2: W: no context for this one :shrug:
|
12
|
-
lib/gergich.rb:10:9: E: this is a terrible name
|
10
|
+
bin/gergich:47:8: C: Prefer double-quoted strings
|
11
|
+
if ENV['DEBUG']
|
12
|
+
^^^^^^^
|
13
|
+
foo/bar/baz.rb:1:2: W: no context for this one :shrug:
|
14
|
+
lib/gergich.rb:10:9: E: this is a terrible name
|
13
15
|
|
14
|
-
seriously, what were you thinking?
|
15
|
-
|
16
|
-
|
17
|
-
lib/gergich.rb:22:55: W: Line is too long. [55/54]
|
18
|
-
|
19
|
-
|
16
|
+
seriously, what were you thinking?
|
17
|
+
def foo
|
18
|
+
^^^
|
19
|
+
lib/gergich.rb:22:55: W: Line is too long. [55/54]
|
20
|
+
def initialize(ref = "HEAD", revision_number = nil)
|
21
|
+
^^
|
20
22
|
OUTPUT
|
21
23
|
end
|
22
24
|
let(:comments) do
|
@@ -36,24 +38,24 @@ lib/gergich.rb:22:55: W: Line is too long. [55/54]
|
|
36
38
|
{
|
37
39
|
path: "lib/gergich.rb",
|
38
40
|
position: 10,
|
39
|
-
message:
|
40
|
-
[rubocop] this is a terrible name
|
41
|
+
message: <<~OUTPUT,
|
42
|
+
[rubocop] this is a terrible name
|
41
43
|
|
42
|
-
seriously, what were you thinking?
|
44
|
+
seriously, what were you thinking?
|
43
45
|
|
44
|
-
|
45
|
-
|
46
|
+
def foo
|
47
|
+
^^^
|
46
48
|
OUTPUT
|
47
49
|
severity: "error"
|
48
50
|
},
|
49
51
|
{
|
50
52
|
path: "lib/gergich.rb",
|
51
53
|
position: 22,
|
52
|
-
message:
|
53
|
-
[rubocop] Line is too long. [55/54]
|
54
|
+
message: <<~OUTPUT,
|
55
|
+
[rubocop] Line is too long. [55/54]
|
54
56
|
|
55
|
-
|
56
|
-
|
57
|
+
def initialize(ref = "HEAD", revision_number = nil)
|
58
|
+
^^
|
57
59
|
OUTPUT
|
58
60
|
severity: "warn"
|
59
61
|
}
|
@@ -1,50 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative "../../support/capture_shared_examples"
|
2
4
|
|
3
5
|
RSpec.describe Gergich::Capture::ShellcheckCapture do
|
4
6
|
let(:output) do
|
5
|
-
|
6
|
-
[
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
]
|
7
|
+
<<~'OUTPUT'
|
8
|
+
[
|
9
|
+
{
|
10
|
+
"file": "bin/sync-translations.sh",
|
11
|
+
"line": 23,
|
12
|
+
"endLine": 23,
|
13
|
+
"column": 21,
|
14
|
+
"endColumn": 21,
|
15
|
+
"level": "style",
|
16
|
+
"code": 2006,
|
17
|
+
"message": "Use $(..) instead of legacy `..`."
|
18
|
+
},
|
19
|
+
{
|
20
|
+
"file": "bin/sync-translations.sh",
|
21
|
+
"line": 23,
|
22
|
+
"endLine": 23,
|
23
|
+
"column": 43,
|
24
|
+
"endColumn": 43,
|
25
|
+
"level": "warning",
|
26
|
+
"code": 2046,
|
27
|
+
"message": "Quote this to prevent word splitting."
|
28
|
+
},
|
29
|
+
{
|
30
|
+
"file": "bin/sync-translations.sh",
|
31
|
+
"line": 32,
|
32
|
+
"endLine": 32,
|
33
|
+
"column": 62,
|
34
|
+
"endColumn": 62,
|
35
|
+
"level": "info",
|
36
|
+
"code": 2086,
|
37
|
+
"message": "Double quote to prevent globbing and word splitting."
|
38
|
+
},
|
39
|
+
{
|
40
|
+
"file": "fail.sh",
|
41
|
+
"line": 3,
|
42
|
+
"endLine": 3,
|
43
|
+
"column": 12,
|
44
|
+
"endColumn": 12,
|
45
|
+
"level": "error",
|
46
|
+
"code": 1101,
|
47
|
+
"message": "Delete trailing spaces after \\ to break line (or use quotes for literal space)."
|
48
|
+
}
|
49
|
+
]
|
48
50
|
OUTPUT
|
49
51
|
end
|
50
52
|
|
@@ -1,15 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative "../../support/capture_shared_examples"
|
2
4
|
|
3
5
|
RSpec.describe Gergich::Capture::StylelintCapture do
|
4
6
|
let(:output) do
|
5
|
-
|
6
|
-
app/stylesheets/base/_print.scss
|
7
|
-
|
8
|
-
|
7
|
+
<<~OUTPUT
|
8
|
+
app/stylesheets/base/_print.scss
|
9
|
+
3:17 ✖ Unexpected invalid hex color "#owiehfi" color-no-invalid-hex
|
10
|
+
3:17 ⚠ Expected "#owiehfi" to be "#OWIEHFI" color-hex-case
|
9
11
|
|
10
|
-
app/stylesheets/base/_variables.scss
|
11
|
-
|
12
|
-
|
12
|
+
app/stylesheets/base/_variables.scss
|
13
|
+
2:15 ✖ Unexpected invalid hex color "#2D3B4" color-no-invalid-hex
|
14
|
+
30:15 ⚠ Expected "#2d3b4a" to be "#2D3B4A" color-hex-case
|
15
|
+
45:12 ℹ Expected "#2d3b4a" to be "#2D3B4A" color-hex-case
|
13
16
|
OUTPUT
|
14
17
|
end
|
15
18
|
let(:comments) do
|
@@ -37,6 +40,12 @@ app/stylesheets/base/_variables.scss
|
|
37
40
|
position: 30,
|
38
41
|
message: "[stylelint] Expected \"#2d3b4a\" to be \"#2D3B4A\"",
|
39
42
|
severity: "warn"
|
43
|
+
},
|
44
|
+
{
|
45
|
+
path: "app/stylesheets/base/_variables.scss",
|
46
|
+
position: 45,
|
47
|
+
message: "[stylelint] Expected \"#2d3b4a\" to be \"#2D3B4A\"",
|
48
|
+
severity: "info"
|
40
49
|
}
|
41
50
|
]
|
42
51
|
end
|
@@ -1,15 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative "../../support/capture_shared_examples"
|
2
4
|
|
3
5
|
RSpec.describe Gergich::Capture::SwiftlintCapture do
|
4
|
-
# rubocop:disable
|
6
|
+
# rubocop:disable Layout/LineLength
|
5
7
|
let(:colon_violation) { "Colon Violation: Colons should be next to the identifier when specifying a type. (colon)" }
|
6
8
|
let(:line_length_violation) { "Line Length Violation: Line should be 100 characters or less: currently 129 characters (line_length)" }
|
7
9
|
let(:force_cast_violation) { "Force Cast Violation: Force casts should be avoided. (force_cast)" }
|
10
|
+
# rubocop:enable Layout/LineLength
|
8
11
|
let(:output) do
|
9
|
-
|
10
|
-
/path/to/My.swift:13:22: warning: #{colon_violation}
|
11
|
-
/path/to/Fail.swift:76: warning: #{line_length_violation}
|
12
|
-
/path/to/Cast.swift:15:9: error: #{force_cast_violation}
|
12
|
+
<<~OUTPUT
|
13
|
+
/path/to/My.swift:13:22: warning: #{colon_violation}
|
14
|
+
/path/to/Fail.swift:76: warning: #{line_length_violation}
|
15
|
+
/path/to/Cast.swift:15:9: error: #{force_cast_violation}
|
13
16
|
OUTPUT
|
14
17
|
end
|
15
18
|
let(:comments) do
|
@@ -1,13 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative "../../lib/gergich/capture"
|
2
4
|
|
3
5
|
RSpec.describe Gergich::Capture do
|
4
6
|
let!(:draft) { double }
|
5
7
|
|
6
8
|
let :output do
|
7
|
-
|
8
|
-
#{path}
|
9
|
-
|
10
|
-
OUTPUT
|
9
|
+
<<~OUTPUT
|
10
|
+
#{path}
|
11
|
+
4:21 error Missing semicolon semi
|
12
|
+
OUTPUT
|
11
13
|
end
|
12
14
|
|
13
15
|
before do
|
data/spec/gergich_spec.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
RSpec.describe Gergich::API do
|
2
4
|
context "bad change-id" do
|
3
5
|
let(:result) { double(:result, body: "Not Found: 1234") }
|
@@ -88,6 +90,21 @@ RSpec.describe Gergich::Draft do
|
|
88
90
|
draft.reset!
|
89
91
|
end
|
90
92
|
|
93
|
+
context "#GERGICH_DB_PATH" do
|
94
|
+
it "uses the custom path" do
|
95
|
+
original_db_path = ENV["GERGICH_DB_PATH"]
|
96
|
+
ENV["GERGICH_DB_PATH"] = "/custom"
|
97
|
+
|
98
|
+
expect(draft.db_file).to eq("/custom/gergich-test.sqlite3")
|
99
|
+
|
100
|
+
ENV["GERGICH_DB_PATH"] = original_db_path
|
101
|
+
end
|
102
|
+
|
103
|
+
it "uses the default path" do
|
104
|
+
expect(draft.db_file).to eq("/tmp/gergich-test.sqlite3")
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
91
108
|
describe "#info" do
|
92
109
|
subject { draft.info }
|
93
110
|
|
@@ -99,6 +116,11 @@ RSpec.describe Gergich::Draft do
|
|
99
116
|
expect(subject).to eq("foo.rb" => [{ line: 1, message: "[INFO] fix foo" }])
|
100
117
|
end
|
101
118
|
|
119
|
+
it "strips whitespace from filename" do
|
120
|
+
draft.add_comment " foo.rb\n", 1, "fix foo", "info"
|
121
|
+
expect(subject).to eq("foo.rb" => [{ line: 1, message: "[INFO] fix foo" }])
|
122
|
+
end
|
123
|
+
|
102
124
|
it "includes COMMIT_MSG comments" do
|
103
125
|
draft.add_comment "/COMMIT_MSG", 1, "fix commit", "info"
|
104
126
|
expect(subject).to eq("/COMMIT_MSG" => [{ line: 1, message: "[INFO] fix commit" }])
|
@@ -210,16 +232,18 @@ RSpec.describe Gergich::Draft do
|
|
210
232
|
end
|
211
233
|
|
212
234
|
RSpec.describe Gergich::Review do
|
235
|
+
let(:change_id) { "test" }
|
213
236
|
let!(:commit) do
|
214
237
|
double(
|
215
238
|
:commit,
|
239
|
+
change_id: change_id,
|
216
240
|
files: [
|
217
241
|
"foo.rb",
|
218
242
|
"bar/baz.lol"
|
219
243
|
],
|
220
|
-
|
221
|
-
|
222
|
-
|
244
|
+
info: {},
|
245
|
+
revision_id: change_id,
|
246
|
+
revision_number: 1
|
223
247
|
)
|
224
248
|
end
|
225
249
|
let!(:draft) do
|
@@ -231,6 +255,37 @@ RSpec.describe Gergich::Review do
|
|
231
255
|
draft.reset!
|
232
256
|
end
|
233
257
|
|
258
|
+
describe "#status" do
|
259
|
+
subject { review.status }
|
260
|
+
|
261
|
+
context "nothing to publish" do
|
262
|
+
before :each do
|
263
|
+
allow(review).to receive(:anything_to_publish?).and_return(false)
|
264
|
+
end
|
265
|
+
it { expect { subject }.to output(include("Nothing to publish")).to_stdout }
|
266
|
+
end
|
267
|
+
|
268
|
+
context "something to publish" do
|
269
|
+
before :each do
|
270
|
+
allow(review).to receive(:anything_to_publish?).and_return(true)
|
271
|
+
allow(review).to receive(:already_commented?).and_return(false)
|
272
|
+
allow(review).to receive(:generate_payload).and_return({})
|
273
|
+
allow(review).to receive(:my_messages).and_return([])
|
274
|
+
end
|
275
|
+
it {
|
276
|
+
expected_outputs = [
|
277
|
+
"Project:",
|
278
|
+
"Branch:",
|
279
|
+
"Revision:",
|
280
|
+
"ChangeId: #{change_id}",
|
281
|
+
"Files:"
|
282
|
+
# There's more... but this is good
|
283
|
+
]
|
284
|
+
expect { subject }.to output(include(*expected_outputs)).to_stdout
|
285
|
+
}
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
234
289
|
describe "#publish!" do
|
235
290
|
context "nothing to publish" do
|
236
291
|
before :each do
|
@@ -253,7 +308,6 @@ RSpec.describe Gergich::Review do
|
|
253
308
|
|
254
309
|
it "publishes via the api" do
|
255
310
|
expect(Gergich::API).to receive(:post)
|
256
|
-
allow(review).to receive(:change_name?).and_return(false)
|
257
311
|
review.publish!
|
258
312
|
end
|
259
313
|
end
|