horn_of_plenty 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/LICENSE.txt +19 -0
  5. data/README.md +36 -0
  6. data/lib/horn_of_plenty.rb +22 -0
  7. data/lib/horn_of_plenty/adapters/github/client.rb +82 -0
  8. data/lib/horn_of_plenty/adapters/github/collections/card.rb +46 -0
  9. data/lib/horn_of_plenty/adapters/github/configuration.rb +38 -0
  10. data/lib/horn_of_plenty/adapters/github/error.rb +44 -0
  11. data/lib/horn_of_plenty/adapters/github/parsers/board.rb +52 -0
  12. data/lib/horn_of_plenty/adapters/github/parsers/card.rb +91 -0
  13. data/lib/horn_of_plenty/adapters/github/parsers/issue.rb +95 -0
  14. data/lib/horn_of_plenty/adapters/github/parsers/lane.rb +50 -0
  15. data/lib/horn_of_plenty/adapters/github/parsers/pull_request.rb +38 -0
  16. data/lib/horn_of_plenty/adapters/github/queries/list_boards.rb +18 -0
  17. data/lib/horn_of_plenty/adapters/github/queries/list_cards.rb +19 -0
  18. data/lib/horn_of_plenty/adapters/github/queries/list_issues.rb +22 -0
  19. data/lib/horn_of_plenty/adapters/github/queries/list_lanes.rb +19 -0
  20. data/lib/horn_of_plenty/adapters/github/queries/list_pull_requests.rb +22 -0
  21. data/lib/horn_of_plenty/adapters/github/repositories/board.rb +24 -0
  22. data/lib/horn_of_plenty/adapters/github/repositories/card.rb +24 -0
  23. data/lib/horn_of_plenty/adapters/github/repositories/issue.rb +24 -0
  24. data/lib/horn_of_plenty/adapters/github/repositories/lane.rb +24 -0
  25. data/lib/horn_of_plenty/adapters/github/repositories/pull_request.rb +24 -0
  26. data/lib/horn_of_plenty/adapters/github/requests/list_boards.rb +50 -0
  27. data/lib/horn_of_plenty/adapters/github/requests/list_cards.rb +52 -0
  28. data/lib/horn_of_plenty/adapters/github/requests/list_issues.rb +50 -0
  29. data/lib/horn_of_plenty/adapters/github/requests/list_lanes.rb +52 -0
  30. data/lib/horn_of_plenty/adapters/github/requests/list_pull_requests.rb +50 -0
  31. data/lib/horn_of_plenty/adapters/github/response.rb +16 -0
  32. data/lib/horn_of_plenty/adapters/github/responses/list_boards.rb +17 -0
  33. data/lib/horn_of_plenty/adapters/github/responses/list_cards.rb +23 -0
  34. data/lib/horn_of_plenty/adapters/github/responses/list_issues.rb +18 -0
  35. data/lib/horn_of_plenty/adapters/github/responses/list_lanes.rb +17 -0
  36. data/lib/horn_of_plenty/adapters/github/responses/list_pull_requests.rb +17 -0
  37. data/lib/horn_of_plenty/collection.rb +60 -0
  38. data/lib/horn_of_plenty/core_ext/string.rb +95 -0
  39. data/lib/horn_of_plenty/models/board.rb +32 -0
  40. data/lib/horn_of_plenty/models/card.rb +51 -0
  41. data/lib/horn_of_plenty/models/issue.rb +46 -0
  42. data/lib/horn_of_plenty/models/lane.rb +30 -0
  43. data/lib/horn_of_plenty/models/parsable.rb +44 -0
  44. data/lib/horn_of_plenty/models/pull_request.rb +12 -0
  45. data/lib/horn_of_plenty/null_objects/board.rb +10 -0
  46. data/lib/horn_of_plenty/null_objects/card.rb +10 -0
  47. data/lib/horn_of_plenty/null_objects/issue.rb +10 -0
  48. data/lib/horn_of_plenty/null_objects/lane.rb +10 -0
  49. data/lib/horn_of_plenty/null_objects/pull_request.rb +10 -0
  50. data/lib/horn_of_plenty/paginator.rb +109 -0
  51. data/lib/horn_of_plenty/parsers/hash.rb +95 -0
  52. data/lib/horn_of_plenty/queries/fetch.rb +36 -0
  53. data/lib/horn_of_plenty/repositories/board.rb +26 -0
  54. data/lib/horn_of_plenty/repositories/card.rb +26 -0
  55. data/lib/horn_of_plenty/repositories/issue.rb +26 -0
  56. data/lib/horn_of_plenty/repositories/lane.rb +26 -0
  57. data/lib/horn_of_plenty/repositories/pull_request.rb +26 -0
  58. data/lib/horn_of_plenty/repository.rb +29 -0
  59. data/lib/horn_of_plenty/request.rb +32 -0
  60. data/lib/horn_of_plenty/response.rb +44 -0
  61. data/lib/horn_of_plenty/version.rb +4 -0
  62. data/spec/fixtures/responses/board_github.json +29 -0
  63. data/spec/fixtures/responses/card_github.json +7 -0
  64. data/spec/fixtures/responses/issue_github.json +163 -0
  65. data/spec/fixtures/responses/lane_github.json +7 -0
  66. data/spec/fixtures/responses/pull_request_github.json +361 -0
  67. data/spec/lib/horn_of_plenty/adapters/github/client_spec.rb +12 -0
  68. data/spec/lib/horn_of_plenty/adapters/github/collections/card_spec.rb +14 -0
  69. data/spec/lib/horn_of_plenty/adapters/github/configuration_spec.rb +12 -0
  70. data/spec/lib/horn_of_plenty/adapters/github/error_spec.rb +35 -0
  71. data/spec/lib/horn_of_plenty/adapters/github/parsers/board_spec.rb +39 -0
  72. data/spec/lib/horn_of_plenty/adapters/github/parsers/card_spec.rb +64 -0
  73. data/spec/lib/horn_of_plenty/adapters/github/parsers/issue_spec.rb +47 -0
  74. data/spec/lib/horn_of_plenty/adapters/github/parsers/lane_spec.rb +38 -0
  75. data/spec/lib/horn_of_plenty/adapters/github/parsers/pull_request_spec.rb +50 -0
  76. data/spec/lib/horn_of_plenty/adapters/github/queries/list_boards_spec.rb +19 -0
  77. data/spec/lib/horn_of_plenty/adapters/github/queries/list_cards_spec.rb +19 -0
  78. data/spec/lib/horn_of_plenty/adapters/github/queries/list_issues_spec.rb +19 -0
  79. data/spec/lib/horn_of_plenty/adapters/github/queries/list_lanes_spec.rb +19 -0
  80. data/spec/lib/horn_of_plenty/adapters/github/queries/list_pull_requests_spec.rb +19 -0
  81. data/spec/lib/horn_of_plenty/adapters/github/repositories/board_spec.rb +22 -0
  82. data/spec/lib/horn_of_plenty/adapters/github/repositories/card_spec.rb +67 -0
  83. data/spec/lib/horn_of_plenty/adapters/github/repositories/issue_spec.rb +22 -0
  84. data/spec/lib/horn_of_plenty/adapters/github/repositories/lane_spec.rb +25 -0
  85. data/spec/lib/horn_of_plenty/adapters/github/repositories/pull_request_spec.rb +24 -0
  86. data/spec/lib/horn_of_plenty/adapters/github/requests/list_boards_spec.rb +42 -0
  87. data/spec/lib/horn_of_plenty/adapters/github/requests/list_cards_spec.rb +51 -0
  88. data/spec/lib/horn_of_plenty/adapters/github/requests/list_issues_spec.rb +42 -0
  89. data/spec/lib/horn_of_plenty/adapters/github/requests/list_lanes_spec.rb +51 -0
  90. data/spec/lib/horn_of_plenty/adapters/github/requests/list_pull_requests_spec.rb +42 -0
  91. data/spec/lib/horn_of_plenty/adapters/github/responses/list_boards_spec.rb +78 -0
  92. data/spec/lib/horn_of_plenty/adapters/github/responses/list_cards_spec.rb +86 -0
  93. data/spec/lib/horn_of_plenty/adapters/github/responses/list_issues_spec.rb +104 -0
  94. data/spec/lib/horn_of_plenty/adapters/github/responses/list_lanes_spec.rb +86 -0
  95. data/spec/lib/horn_of_plenty/adapters/github/responses/list_pull_requests_spec.rb +109 -0
  96. data/spec/lib/horn_of_plenty/models/board_spec.rb +10 -0
  97. data/spec/lib/horn_of_plenty/models/card_spec.rb +10 -0
  98. data/spec/lib/horn_of_plenty/models/issue_spec.rb +10 -0
  99. data/spec/lib/horn_of_plenty/models/lane_spec.rb +10 -0
  100. data/spec/lib/horn_of_plenty/models/pull_request_spec.rb +10 -0
  101. data/spec/lib/horn_of_plenty/null_objects/board_spec.rb +10 -0
  102. data/spec/lib/horn_of_plenty/null_objects/card_spec.rb +10 -0
  103. data/spec/lib/horn_of_plenty/null_objects/issue_spec.rb +10 -0
  104. data/spec/lib/horn_of_plenty/null_objects/lane_spec.rb +10 -0
  105. data/spec/lib/horn_of_plenty/null_objects/pull_request_spec.rb +10 -0
  106. data/spec/lib/horn_of_plenty/queries/fetch_spec.rb +15 -0
  107. data/spec/lib/horn_of_plenty/repositories/board_spec.rb +48 -0
  108. data/spec/lib/horn_of_plenty/repositories/card_spec.rb +51 -0
  109. data/spec/lib/horn_of_plenty/repositories/issue_spec.rb +48 -0
  110. data/spec/lib/horn_of_plenty/repositories/lane_spec.rb +51 -0
  111. data/spec/lib/horn_of_plenty/repositories/pull_request_spec.rb +50 -0
  112. data/spec/support/patterns.rb +1 -0
  113. metadata +396 -0
  114. metadata.gz.sig +0 -0
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+ require 'chamber'
3
+ require 'horn_of_plenty/adapters/github/repositories/pull_request'
4
+ require 'rspeckled/spec_helpers/rspeckled'
5
+
6
+ module HornOfPlenty
7
+ module Adapters
8
+ module Github
9
+ module Repositories
10
+ describe PullRequest do
11
+ before(:each) { Adapters::Github.config.token = Chamber.env.adapters.github.token }
12
+
13
+ it 'can retrieve pull_requests from an adapter' do
14
+ pull_requests = PullRequest.fetch(
15
+ repository: 'thekompanee/hustle-and-flow-issue-dump',
16
+ )
17
+
18
+ expect(pull_requests.length).to eql 1
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+ require 'rspeckled/spec_helpers/rspeckled'
3
+ require 'horn_of_plenty/adapters/github/requests/list_boards'
4
+
5
+ module HornOfPlenty
6
+ module Adapters
7
+ module Github
8
+ module Requests
9
+ describe ListBoards do
10
+ it 'has the correct method' do
11
+ request = ListBoards.new(query: 'what', repository: 'yeah')
12
+
13
+ expect(request.method).to eql 'get'
14
+ end
15
+
16
+ it 'has the correct path based on the repository name' do
17
+ request = ListBoards.new(query: {}, repository: 'yeah')
18
+
19
+ expect(request.path).to eql 'repos/yeah/projects'
20
+ end
21
+
22
+ it 'has the correct path based on the ID' do
23
+ request = ListBoards.new(repository: 'yeah', query: { id: '1' })
24
+
25
+ expect(request.path).to eql 'repos/yeah/projects/1'
26
+ end
27
+
28
+ it 'properly combines the query and pagination hashes' do
29
+ query_hash = { 'some_var' => 'some_val', 'other_var' => 'other_val' }
30
+ pagination_hash = { 'some_var' => 'boom' }
31
+
32
+ request = ListBoards.new(query: query_hash,
33
+ pagination: pagination_hash,
34
+ repository: 'yeah')
35
+
36
+ expect(request.to_h).to eql('some_var' => 'boom', 'other_var' => 'other_val')
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+ require 'rspeckled/spec_helpers/rspeckled'
3
+ require 'horn_of_plenty/adapters/github/requests/list_cards'
4
+
5
+ module HornOfPlenty
6
+ module Adapters
7
+ module Github
8
+ module Requests
9
+ describe ListCards do
10
+ it 'has the correct method' do
11
+ request = ListCards.new(query: 'what', repository: 'yeah')
12
+
13
+ expect(request.method).to eql 'get'
14
+ end
15
+
16
+ it 'has the correct path based on the repository name' do
17
+ request = ListCards.new(repository: 'yeah',
18
+ query: { lane_id: '1' })
19
+
20
+ expect(request.path).to eql 'repos/yeah/projects/columns/1/cards'
21
+ end
22
+
23
+ it 'has the correct path based on the column ID' do
24
+ request = ListCards.new(repository: 'yeah',
25
+ query: { lane_id: '1' })
26
+
27
+ expect(request.path).to eql 'repos/yeah/projects/columns/1/cards'
28
+ end
29
+
30
+ it 'has the correct path based on the project ID and column ID' do
31
+ request = ListCards.new(repository: 'yeah',
32
+ query: { id: '2', lane_id: '1' })
33
+
34
+ expect(request.path).to eql 'repos/yeah/projects/columns/cards/2'
35
+ end
36
+
37
+ it 'properly combines the query and pagination hashes' do
38
+ query_hash = { 'some_var' => 'some_val', 'other_var' => 'other_val' }
39
+ pagination_hash = { 'some_var' => 'boom' }
40
+
41
+ request = ListCards.new(query: query_hash,
42
+ pagination: pagination_hash,
43
+ repository: 'yeah')
44
+
45
+ expect(request.to_h).to eql('some_var' => 'boom', 'other_var' => 'other_val')
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+ require 'rspeckled/spec_helpers/rspeckled'
3
+ require 'horn_of_plenty/adapters/github/requests/list_issues'
4
+
5
+ module HornOfPlenty
6
+ module Adapters
7
+ module Github
8
+ module Requests
9
+ describe ListIssues do
10
+ it 'has the correct method' do
11
+ request = ListIssues.new(query: 'what', repository: 'yeah')
12
+
13
+ expect(request.method).to eql 'get'
14
+ end
15
+
16
+ it 'has the correct path based on the repository name' do
17
+ request = ListIssues.new(query: {}, repository: 'yeah')
18
+
19
+ expect(request.path).to eql 'repos/yeah/issues'
20
+ end
21
+
22
+ it 'has the correct path based on the ID' do
23
+ request = ListIssues.new(repository: 'yeah', query: { id: '1' })
24
+
25
+ expect(request.path).to eql 'repos/yeah/issues/1'
26
+ end
27
+
28
+ it 'properly combines the query and pagination hashes' do
29
+ query_hash = { 'some_var' => 'some_val', 'other_var' => 'other_val' }
30
+ pagination_hash = { 'some_var' => 'boom' }
31
+
32
+ request = ListIssues.new(query: query_hash,
33
+ pagination: pagination_hash,
34
+ repository: 'yeah')
35
+
36
+ expect(request.to_h).to eql('some_var' => 'boom', 'other_var' => 'other_val')
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+ require 'rspeckled/spec_helpers/rspeckled'
3
+ require 'horn_of_plenty/adapters/github/requests/list_lanes'
4
+
5
+ module HornOfPlenty
6
+ module Adapters
7
+ module Github
8
+ module Requests
9
+ describe ListLanes do
10
+ it 'has the correct method' do
11
+ request = ListLanes.new(query: 'what', repository: 'yeah')
12
+
13
+ expect(request.method).to eql 'get'
14
+ end
15
+
16
+ it 'has the correct path based on the repository name' do
17
+ request = ListLanes.new(repository: 'yeah',
18
+ query: { board_id: '1' })
19
+
20
+ expect(request.path).to eql 'repos/yeah/projects/1/columns'
21
+ end
22
+
23
+ it 'has the correct path based on the project ID' do
24
+ request = ListLanes.new(repository: 'yeah',
25
+ query: { board_id: '1' })
26
+
27
+ expect(request.path).to eql 'repos/yeah/projects/1/columns'
28
+ end
29
+
30
+ it 'has the correct path based on the project ID and column ID' do
31
+ request = ListLanes.new(repository: 'yeah',
32
+ query: { id: '2', board_id: '1' })
33
+
34
+ expect(request.path).to eql 'repos/yeah/projects/columns/2'
35
+ end
36
+
37
+ it 'properly combines the query and pagination hashes' do
38
+ query_hash = { 'some_var' => 'some_val', 'other_var' => 'other_val' }
39
+ pagination_hash = { 'some_var' => 'boom' }
40
+
41
+ request = ListLanes.new(query: query_hash,
42
+ pagination: pagination_hash,
43
+ repository: 'yeah')
44
+
45
+ expect(request.to_h).to eql('some_var' => 'boom', 'other_var' => 'other_val')
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+ require 'rspeckled/spec_helpers/rspeckled'
3
+ require 'horn_of_plenty/adapters/github/requests/list_pull_requests'
4
+
5
+ module HornOfPlenty
6
+ module Adapters
7
+ module Github
8
+ module Requests
9
+ describe ListPullRequests do
10
+ it 'has the correct method' do
11
+ request = ListPullRequests.new(query: 'what', repository: 'yeah')
12
+
13
+ expect(request.method).to eql 'get'
14
+ end
15
+
16
+ it 'has the correct path based on the repository name' do
17
+ request = ListPullRequests.new(query: {}, repository: 'yeah')
18
+
19
+ expect(request.path).to eql 'repos/yeah/pulls'
20
+ end
21
+
22
+ it 'has the correct path based on the ID' do
23
+ request = ListPullRequests.new(repository: 'yeah', query: { id: '1' })
24
+
25
+ expect(request.path).to eql 'repos/yeah/pulls/1'
26
+ end
27
+
28
+ it 'properly combines the query and pagination hashes' do
29
+ query_hash = { 'some_var' => 'some_val', 'other_var' => 'other_val' }
30
+ pagination_hash = { 'some_var' => 'boom' }
31
+
32
+ request = ListPullRequests.new(query: query_hash,
33
+ pagination: pagination_hash,
34
+ repository: 'yeah')
35
+
36
+ expect(request.to_h).to eql('some_var' => 'boom', 'other_var' => 'other_val')
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+ require 'horn_of_plenty/models/board'
3
+ require 'horn_of_plenty/adapters/github/client'
4
+ require 'horn_of_plenty/adapters/github/responses/list_boards'
5
+ require 'horn_of_plenty/adapters/github/requests/list_boards'
6
+ require 'chamber'
7
+ require 'rspeckled/spec_helpers/rspeckled'
8
+
9
+ module HornOfPlenty
10
+ module Adapters
11
+ module Github
12
+ module Responses
13
+ describe ListBoards do
14
+ it 'can retrieve boards' do
15
+ client = Client.new(url: 'https://api.github.com',
16
+ version: 'inertia-preview',
17
+ token: Chamber.env.adapters.github.token,
18
+ logger: $stdout)
19
+ board_request = Requests::ListBoards.new(
20
+ repository: 'thekompanee/hustle-and-flow-issue-dump',
21
+ )
22
+
23
+ board_response = client.request(board_request)
24
+
25
+ expect(board_response.status_code).to eql 200
26
+ expect(board_response.body.length).to eql 2
27
+ expect(board_response).to be_successful
28
+ expect(board_response.body).to include(
29
+ a_hash_including(
30
+ 'name' => 'Main',
31
+ ),
32
+ )
33
+ end
34
+
35
+ it 'can handle if a board does not exist' do
36
+ client = Client.new(url: 'https://api.github.com',
37
+ version: 'inertia-preview',
38
+ token: Chamber.env.adapters.github.token,
39
+ logger: $stdout)
40
+ board_request = Requests::ListBoards.new(repository: 'thekompanee/hustle_and_flow')
41
+
42
+ board_response = client.request(board_request)
43
+
44
+ expect(board_response.status_code).to eql 200
45
+ expect(board_response.body).to be_empty
46
+ expect(board_response).to be_successful
47
+ end
48
+
49
+ it 'can handle if there is an error' do
50
+ client = Client.new(url: 'https://api.github.com',
51
+ version: 'inertia-preview',
52
+ token: Chamber.env.adapters.github.token,
53
+ logger: $stdout)
54
+ board_request = Requests::ListBoards.new(repository: 'thekompanee/no-repo-here')
55
+
56
+ expect { client.request(board_request) }.to raise_error Github::Errors::NotFound
57
+ end
58
+
59
+ it 'can parse the boards that are returned' do
60
+ client = Client.new(url: 'https://api.github.com',
61
+ version: 'inertia-preview',
62
+ token: Chamber.env.adapters.github.token,
63
+ logger: $stdout)
64
+ board_request = Requests::ListBoards.new(
65
+ repository: 'thekompanee/hustle-and-flow-issue-dump',
66
+ )
67
+
68
+ board_response = client.request(board_request)
69
+ board = board_response.result.first
70
+
71
+ expect(board).to be_a HornOfPlenty::Models::Board
72
+ expect(board.title).to eql 'Main'
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,86 @@
1
+ # frozen_string_literal: true
2
+ require 'horn_of_plenty/models/card'
3
+ require 'horn_of_plenty/adapters/github/client'
4
+ require 'horn_of_plenty/adapters/github/responses/list_cards'
5
+ require 'horn_of_plenty/adapters/github/requests/list_cards'
6
+ require 'chamber'
7
+ require 'rspeckled/spec_helpers/rspeckled'
8
+
9
+ module HornOfPlenty
10
+ module Adapters
11
+ module Github
12
+ module Responses
13
+ describe ListCards do
14
+ it 'can retrieve cards' do
15
+ client = Client.new(url: 'https://api.github.com',
16
+ version: 'inertia-preview',
17
+ token: Chamber.env.adapters.github.token,
18
+ logger: $stdout)
19
+ card_request = Requests::ListCards.new(
20
+ repository: 'thekompanee/hustle-and-flow-issue-dump',
21
+ query: { lane_id: 215_863 },
22
+ )
23
+
24
+ card_response = client.request(card_request)
25
+
26
+ expect(card_response.status_code).to eql 200
27
+ expect(card_response.body.length).to eql 4
28
+ expect(card_response).to be_successful
29
+ expect(card_response.body).to include(
30
+ a_hash_including(
31
+ 'note' => 'First Card',
32
+ ),
33
+ )
34
+ end
35
+
36
+ it 'can handle if a lane does not have any cards' do
37
+ client = Client.new(url: 'https://api.github.com',
38
+ version: 'inertia-preview',
39
+ token: Chamber.env.adapters.github.token,
40
+ logger: $stdout)
41
+ card_request = Requests::ListCards.new(
42
+ repository: 'thekompanee/hustle-and-flow-issue-dump',
43
+ query: { lane_id: 215_866 },
44
+ )
45
+
46
+ card_response = client.request(card_request)
47
+
48
+ expect(card_response.status_code).to eql 200
49
+ expect(card_response.body).to be_empty
50
+ expect(card_response).to be_successful
51
+ end
52
+
53
+ it 'can handle if there is an error' do
54
+ client = Client.new(url: 'https://api.github.com',
55
+ version: 'inertia-preview',
56
+ token: Chamber.env.adapters.github.token,
57
+ logger: $stdout)
58
+ card_request = Requests::ListCards.new(
59
+ repository: 'thekompanee/no-repo-here',
60
+ query: { lane_id: 3 },
61
+ )
62
+
63
+ expect { client.request(card_request) }.to raise_error Github::Errors::NotFound
64
+ end
65
+
66
+ it 'can parse notes that are returned' do
67
+ client = Client.new(url: 'https://api.github.com',
68
+ version: 'inertia-preview',
69
+ token: Chamber.env.adapters.github.token,
70
+ logger: $stdout)
71
+ card_request = Requests::ListCards.new(
72
+ repository: 'thekompanee/hustle-and-flow-issue-dump',
73
+ query: { lane_id: 215_863 },
74
+ )
75
+
76
+ card_response = client.request(card_request)
77
+ card = card_response.result.first
78
+
79
+ expect(card).to be_a HornOfPlenty::Models::Card
80
+ expect(card.title).to eql 'First Card'
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,104 @@
1
+ # frozen_string_literal: true
2
+ require 'horn_of_plenty/models/issue'
3
+ require 'horn_of_plenty/adapters/github/client'
4
+ require 'horn_of_plenty/adapters/github/responses/list_issues'
5
+ require 'horn_of_plenty/adapters/github/requests/list_issues'
6
+ require 'chamber'
7
+ require 'rspeckled/spec_helpers/rspeckled'
8
+
9
+ module HornOfPlenty
10
+ module Adapters
11
+ module Github
12
+ module Responses
13
+ describe ListIssues do
14
+ it 'can retrieve issues' do
15
+ client = Client.new(url: 'https://api.github.com',
16
+ version: 'inertia-preview',
17
+ token: Chamber.env.adapters.github.token,
18
+ logger: $stdout)
19
+ issue_request = Requests::ListIssues.new(
20
+ repository: 'thekompanee/hustle-and-flow-issue-dump',
21
+ )
22
+
23
+ issue_response = client.request(issue_request)
24
+
25
+ expect(issue_response.status_code).to eql 200
26
+ expect(issue_response.body.length).to eql 3
27
+ expect(issue_response).to be_successful
28
+ expect(issue_response.body).to include(
29
+ a_hash_including(
30
+ 'title' => 'My Bar Pull Request',
31
+ ),
32
+ )
33
+ end
34
+
35
+ it 'can filter issues' do
36
+ client = Client.new(url: 'https://api.github.com',
37
+ version: 'inertia-preview',
38
+ token: Chamber.env.adapters.github.token,
39
+ logger: $stdout)
40
+ issue_request = Requests::ListIssues.new(
41
+ repository: 'thekompanee/hustle-and-flow-issue-dump',
42
+ query: {
43
+ author_id: 'jfelchner',
44
+ status: 'open',
45
+ labels: 'dont-touch-this-label',
46
+ },
47
+ )
48
+
49
+ issue_response = client.request(issue_request)
50
+
51
+ expect(issue_response.status_code).to eql 200
52
+ expect(issue_response.body.length).to eql 1
53
+ expect(issue_response).to be_successful
54
+ expect(issue_response.body).to include(
55
+ a_hash_including(
56
+ 'title' => 'Menu item specifications not working',
57
+ ),
58
+ )
59
+ end
60
+
61
+ it 'can handle if a issue does not exist' do
62
+ client = Client.new(url: 'https://api.github.com',
63
+ version: 'inertia-preview',
64
+ token: Chamber.env.adapters.github.token,
65
+ logger: $stdout)
66
+ issue_request = Requests::ListIssues.new(repository: 'thekompanee/hustle_and_flow')
67
+
68
+ issue_response = client.request(issue_request)
69
+
70
+ expect(issue_response.status_code).to eql 200
71
+ expect(issue_response.body).to be_empty
72
+ expect(issue_response).to be_successful
73
+ end
74
+
75
+ it 'can handle if there is an error' do
76
+ client = Client.new(url: 'https://api.github.com',
77
+ version: 'inertia-preview',
78
+ token: Chamber.env.adapters.github.token,
79
+ logger: $stdout)
80
+ issue_request = Requests::ListIssues.new(repository: 'thekompanee/no-repo-here')
81
+
82
+ expect { client.request(issue_request) }.to raise_error Github::Errors::NotFound
83
+ end
84
+
85
+ it 'can parse the issues that are returned' do
86
+ client = Client.new(url: 'https://api.github.com',
87
+ version: 'inertia-preview',
88
+ token: Chamber.env.adapters.github.token,
89
+ logger: $stdout)
90
+ issue_request = Requests::ListIssues.new(
91
+ repository: 'thekompanee/hustle-and-flow-issue-dump',
92
+ )
93
+
94
+ issue_response = client.request(issue_request)
95
+ issue = issue_response.result.first
96
+
97
+ expect(issue).to be_a HornOfPlenty::Models::Issue
98
+ expect(issue.title).to eql 'My Bar Pull Request'
99
+ end
100
+ end
101
+ end
102
+ end
103
+ end
104
+ end