28
28
require 'minitest/autorun'
29
29
require 'webmock/minitest'
30
30
require 'judges/options'
31
+ require_relative '../test__helper'
31
32
32
33
# Test.
33
34
# Author:: Yegor Bugayenko (yegor256@gmail.com)
@@ -37,58 +38,48 @@ class TestQuantityOfDeliverables < Minitest::Test
37
38
def test_counts_commits
38
39
WebMock . disable_net_connect!
39
40
stub_github ( 'https://api.github.com/rate_limit' , body : { } )
40
- stub_request ( :get , 'https://api.github.com/user/42' ) . to_return (
41
- body : { id : 42 , login : 'torvalds' } . to_json , headers : {
42
- 'content-type' : 'application/json'
43
- }
41
+ stub_github (
42
+ 'https://api.github.com/user/42' ,
43
+ body : { id : 42 , login : 'torvalds' }
44
44
)
45
- stub_request ( :get , 'https://api.github.com/repos/foo/foo' ) . to_return (
46
- body : { id : 42 , full_name : 'foo/foo' , open_issues : 0 , size : 10 } . to_json , headers : {
47
- 'content-type' : 'application/json'
48
- }
45
+ stub_github (
46
+ 'https://api.github.com/repos/foo/foo' ,
47
+ body : { id : 42 , full_name : 'foo/foo' , open_issues : 0 , size : 10 }
49
48
)
50
- stub_request ( :get , 'https://api.github.com/repos/foo/foo/commits?per_page=100&since=2024-07-15T21:00:00%2B00:00' ) . to_return (
49
+ stub_github (
50
+ 'https://api.github.com/repos/foo/foo/commits?per_page=100&since=2024-07-15T21:00:00%2B00:00' ,
51
51
body : [
52
52
{
53
53
sha : 'bcb3cd5c2a6f3daebe1a2ab16a195a0bf2609943'
54
54
} ,
55
55
{
56
56
sha : '0d705c564abc9e5088f00310c42b82bc9f192a3d'
57
57
}
58
- ] . to_json ,
59
- headers : {
60
- 'content-type' : 'application/json'
61
- }
58
+ ]
62
59
)
63
- stub_request ( :get , 'https://api.github.com/repos/foo/foo/commits/bcb3cd5c2a6f3daebe1a2ab16a195a0bf2609943' ) . to_return (
60
+ stub_github (
61
+ 'https://api.github.com/repos/foo/foo/commits/bcb3cd5c2a6f3daebe1a2ab16a195a0bf2609943' ,
64
62
body : {
65
63
stats : {
66
64
total : 10
67
65
}
68
- } . to_json ,
69
- headers : {
70
- 'content-type' : 'application/json'
71
66
}
72
67
)
73
- stub_request ( :get , 'https://api.github.com/repos/foo/foo/commits/0d705c564abc9e5088f00310c42b82bc9f192a3d' ) . to_return (
68
+ stub_github (
69
+ 'https://api.github.com/repos/foo/foo/commits/0d705c564abc9e5088f00310c42b82bc9f192a3d' ,
74
70
body : {
75
71
stats : {
76
72
total : 10
77
73
}
78
- } . to_json ,
79
- headers : {
80
- 'content-type' : 'application/json'
81
74
}
82
75
)
83
- stub_request ( :get , 'https://api.github.com/repos/foo/foo/issues?per_page=100&since=%3E2024-07-15' ) . to_return (
76
+ stub_github (
77
+ 'https://api.github.com/repos/foo/foo/issues?per_page=100&since=%3E2024-07-15' ,
84
78
body : [
85
79
{
86
80
pull_request : { }
87
81
}
88
- ] . to_json ,
89
- headers : {
90
- 'content-type' : 'application/json'
91
- }
82
+ ]
92
83
)
93
84
stub_github (
94
85
'https://api.github.com/repos/foo/foo/releases?per_page=100' ,
@@ -113,32 +104,26 @@ def test_counts_commits
113
104
def test_processes_empty_repository
114
105
WebMock . disable_net_connect!
115
106
stub_github ( 'https://api.github.com/rate_limit' , body : { } )
116
- stub_request ( :get , 'https://api.github.com/user/42' ) . to_return (
117
- body : { id : 42 , login : 'torvalds' } . to_json , headers : {
118
- 'content-type' : 'application/json'
119
- }
107
+ stub_github (
108
+ 'https://api.github.com/user/42' ,
109
+ body : { id : 42 , login : 'torvalds' }
120
110
)
121
- stub_request ( :get , 'https://api.github.com/repos/foo/foo' ) . to_return (
122
- body : { id : 42 , full_name : 'foo/foo' , open_issues : 0 , size : 0 } . to_json , headers : {
123
- 'content-type' : 'application/json'
124
- }
111
+ stub_github (
112
+ 'https://api.github.com/repos/foo/foo' ,
113
+ body : { id : 42 , full_name : 'foo/foo' , open_issues : 0 , size : 0 }
125
114
)
126
- stub_request ( :get , 'https://api.github.com/repos/foo/foo/commits?per_page=100&since=2024-07-15T21:00:00%2B00:00' ) . to_return (
115
+ stub_github (
116
+ 'https://api.github.com/repos/foo/foo/commits?per_page=100&since=2024-07-15T21:00:00%2B00:00' ,
127
117
status : 409 ,
128
- body : [ ] . to_json ,
129
- headers : {
130
- 'content-type' : 'application/json'
131
- }
118
+ body : [ ]
132
119
)
133
- stub_request ( :get , 'https://api.github.com/repos/foo/foo/issues?per_page=100&since=%3E2024-07-15' ) . to_return (
120
+ stub_github (
121
+ 'https://api.github.com/repos/foo/foo/issues?per_page=100&since=%3E2024-07-15' ,
134
122
body : [
135
123
{
136
124
pull_request : { }
137
125
}
138
- ] . to_json ,
139
- headers : {
140
- 'content-type' : 'application/json'
141
- }
126
+ ]
142
127
)
143
128
stub_github (
144
129
'https://api.github.com/repos/foo/foo/releases?per_page=100' ,
0 commit comments