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,86 @@
1
+ # frozen_string_literal: true
2
+ require 'horn_of_plenty/models/lane'
3
+ require 'horn_of_plenty/adapters/github/client'
4
+ require 'horn_of_plenty/adapters/github/responses/list_lanes'
5
+ require 'horn_of_plenty/adapters/github/requests/list_lanes'
6
+ require 'chamber'
7
+ require 'rspeckled/spec_helpers/rspeckled'
8
+
9
+ module HornOfPlenty
10
+ module Adapters
11
+ module Github
12
+ module Responses
13
+ describe ListLanes do
14
+ it 'can retrieve lanes' 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
+ lane_request = Requests::ListLanes.new(
20
+ repository: 'thekompanee/hustle-and-flow-issue-dump',
21
+ query: { board_id: 1 },
22
+ )
23
+
24
+ lane_response = client.request(lane_request)
25
+
26
+ expect(lane_response.status_code).to eql 200
27
+ expect(lane_response.body.length).to eql 9
28
+ expect(lane_response).to be_successful
29
+ expect(lane_response.body).to include(
30
+ a_hash_including(
31
+ 'name' => 'Backlog',
32
+ ),
33
+ )
34
+ end
35
+
36
+ it 'can handle if a lane does not exist' 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
+ lane_request = Requests::ListLanes.new(
42
+ repository: 'thekompanee/hustle-and-flow-issue-dump',
43
+ query: { board_id: 3 },
44
+ )
45
+
46
+ lane_response = client.request(lane_request)
47
+
48
+ expect(lane_response.status_code).to eql 200
49
+ expect(lane_response.body).to be_empty
50
+ expect(lane_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
+ lane_request = Requests::ListLanes.new(
59
+ repository: 'thekompanee/no-repo-here',
60
+ query: { board_id: 3 },
61
+ )
62
+
63
+ expect { client.request(lane_request) }.to raise_error Github::Errors::NotFound
64
+ end
65
+
66
+ it 'can parse the lanes 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
+ lane_request = Requests::ListLanes.new(
72
+ repository: 'thekompanee/hustle-and-flow-issue-dump',
73
+ query: { board_id: 1 },
74
+ )
75
+
76
+ lane_response = client.request(lane_request)
77
+ lane = lane_response.result.first
78
+
79
+ expect(lane).to be_a HornOfPlenty::Models::Lane
80
+ expect(lane.title).to eql 'Wishlist'
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,109 @@
1
+ # frozen_string_literal: true
2
+ require 'horn_of_plenty/models/pull_request'
3
+ require 'horn_of_plenty/adapters/github/client'
4
+ require 'horn_of_plenty/adapters/github/responses/list_pull_requests'
5
+ require 'horn_of_plenty/adapters/github/requests/list_pull_requests'
6
+ require 'chamber'
7
+ require 'rspeckled/spec_helpers/rspeckled'
8
+
9
+ module HornOfPlenty
10
+ module Adapters
11
+ module Github
12
+ module Responses
13
+ describe ListPullRequests do
14
+ it 'can retrieve pull requests' 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
+ pull_request_request = Requests::ListPullRequests.new(
20
+ repository: 'thekompanee/hustle-and-flow-issue-dump',
21
+ )
22
+
23
+ pull_request_response = client.request(pull_request_request)
24
+
25
+ expect(pull_request_response.status_code).to eql 200
26
+ expect(pull_request_response.body.length).to eql 1
27
+ expect(pull_request_response).to be_successful
28
+ expect(pull_request_response.body).to include(
29
+ a_hash_including(
30
+ 'title' => 'My Bar Pull Request',
31
+ ),
32
+ )
33
+ end
34
+
35
+ it 'can filter pull requests' 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
+ pull_request_request = Requests::ListPullRequests.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
+ pull_request_response = client.request(pull_request_request)
50
+
51
+ expect(pull_request_response.status_code).to eql 200
52
+ expect(pull_request_response.body.length).to eql 1
53
+ expect(pull_request_response).to be_successful
54
+ expect(pull_request_response.body).to include(
55
+ a_hash_including(
56
+ 'title' => 'My Bar Pull Request',
57
+ ),
58
+ )
59
+ end
60
+
61
+ it 'can handle if a pull request 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
+ pull_request_request = Requests::ListPullRequests.new(
67
+ repository: 'thekompanee/hustle_and_flow',
68
+ )
69
+
70
+ pull_request_response = client.request(pull_request_request)
71
+
72
+ expect(pull_request_response.status_code).to eql 200
73
+ expect(pull_request_response.body).to be_empty
74
+ expect(pull_request_response).to be_successful
75
+ end
76
+
77
+ it 'can handle if there is an error' do
78
+ client = Client.new(url: 'https://api.github.com',
79
+ version: 'inertia-preview',
80
+ token: Chamber.env.adapters.github.token,
81
+ logger: $stdout)
82
+ pull_request_request = Requests::ListPullRequests.new(
83
+ repository: 'thekompanee/no-repo-here',
84
+ )
85
+
86
+ expect { client.request(pull_request_request) }.to raise_error \
87
+ Github::Errors::NotFound
88
+ end
89
+
90
+ it 'can parse the pull requests that are returned' do
91
+ client = Client.new(url: 'https://api.github.com',
92
+ version: 'inertia-preview',
93
+ token: Chamber.env.adapters.github.token,
94
+ logger: $stdout)
95
+ pull_request_request = Requests::ListPullRequests.new(
96
+ repository: 'thekompanee/hustle-and-flow-issue-dump',
97
+ )
98
+
99
+ pull_request_response = client.request(pull_request_request)
100
+ pull_request = pull_request_response.result.first
101
+
102
+ expect(pull_request).to be_a HornOfPlenty::Models::PullRequest
103
+ expect(pull_request.title).to eql 'My Bar Pull Request'
104
+ end
105
+ end
106
+ end
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ require 'horn_of_plenty/models/board'
3
+ require 'rspeckled/spec_helpers/rspeckled'
4
+
5
+ module HornOfPlenty
6
+ module Models
7
+ describe Board do
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ require 'horn_of_plenty/models/card'
3
+ require 'rspeckled/spec_helpers/rspeckled'
4
+
5
+ module HornOfPlenty
6
+ module Models
7
+ describe Card do
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ require 'horn_of_plenty/models/issue'
3
+ require 'rspeckled/spec_helpers/rspeckled'
4
+
5
+ module HornOfPlenty
6
+ module Models
7
+ describe Issue do
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ require 'horn_of_plenty/models/lane'
3
+ require 'rspeckled/spec_helpers/rspeckled'
4
+
5
+ module HornOfPlenty
6
+ module Models
7
+ describe Lane do
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ require 'horn_of_plenty/models/pull_request'
3
+ require 'rspeckled/spec_helpers/rspeckled'
4
+
5
+ module HornOfPlenty
6
+ module Models
7
+ describe PullRequest do
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ require 'horn_of_plenty/null_objects/board'
3
+ require 'rspeckled/spec_helpers/rspeckled'
4
+
5
+ module HornOfPlenty
6
+ module NullObjects
7
+ describe Board do
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ require 'horn_of_plenty/null_objects/card'
3
+ require 'rspeckled/spec_helpers/rspeckled'
4
+
5
+ module HornOfPlenty
6
+ module NullObjects
7
+ describe Card do
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ require 'horn_of_plenty/null_objects/issue'
3
+ require 'rspeckled/spec_helpers/rspeckled'
4
+
5
+ module HornOfPlenty
6
+ module NullObjects
7
+ describe Issue do
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ require 'horn_of_plenty/null_objects/lane'
3
+ require 'rspeckled/spec_helpers/rspeckled'
4
+
5
+ module HornOfPlenty
6
+ module NullObjects
7
+ describe Lane do
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ require 'horn_of_plenty/null_objects/pull_request'
3
+ require 'rspeckled/spec_helpers/rspeckled'
4
+
5
+ module HornOfPlenty
6
+ module NullObjects
7
+ describe PullRequest do
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+ require 'rspeckled/spec_helpers/rspeckled'
3
+ require 'horn_of_plenty/queries/fetch'
4
+
5
+ module HornOfPlenty
6
+ module Queries
7
+ describe Fetch do
8
+ it 'returns the query unaltered by default' do
9
+ query = Fetch.new(some: 'query')
10
+
11
+ expect(query.to_h).to eql(some: 'query')
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+ require 'faraday'
3
+ require 'chamber'
4
+ require 'horn_of_plenty/adapters/github/configuration'
5
+ require 'horn_of_plenty/repositories/board'
6
+ require 'horn_of_plenty/models/board'
7
+ require 'rspeckled/spec_helpers/rspeckled'
8
+
9
+ module HornOfPlenty
10
+ module Repositories
11
+ describe Board do
12
+ before(:each) { Adapters::Github.config.token = Chamber.env.adapters.github.token }
13
+
14
+ it 'can retrieve boards from an adapter' do
15
+ boards = Board.fetch(adapter: 'github',
16
+ repository: 'thekompanee/hustle-and-flow-issue-dump')
17
+
18
+ expect(boards.length).to eql 2
19
+ end
20
+
21
+ it 'can retrieve a board by ID' do
22
+ boards = Board.fetch(
23
+ adapter: 'github',
24
+ repository: 'thekompanee/hustle-and-flow-issue-dump',
25
+ query: {
26
+ id: 1,
27
+ },
28
+ )
29
+
30
+ expect(boards.first).to be_a HornOfPlenty::Models::Board
31
+ expect(boards.first.title).to eql 'Main'
32
+ end
33
+
34
+ it 'can handle if the board with the ID cannot be found' do
35
+ boards = Board.fetch(
36
+ adapter: 'github',
37
+ repository: 'thekompanee/hustle-and-flow-issue-dump',
38
+ query: {
39
+ id: 2,
40
+ },
41
+ )
42
+
43
+ expect { boards.first }.to raise_error \
44
+ HornOfPlenty::Adapters::Github::Errors::NotFound
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+ require 'faraday'
3
+ require 'chamber'
4
+ require 'horn_of_plenty/adapters/github/configuration'
5
+ require 'horn_of_plenty/repositories/card'
6
+ require 'horn_of_plenty/models/card'
7
+ require 'rspeckled/spec_helpers/rspeckled'
8
+
9
+ module HornOfPlenty
10
+ module Repositories
11
+ describe Card do
12
+ before(:each) { Adapters::Github.config.token = Chamber.env.adapters.github.token }
13
+
14
+ it 'can retrieve cards from an adapter' do
15
+ cards = Card.fetch(adapter: 'github',
16
+ repository: 'thekompanee/hustle-and-flow-issue-dump',
17
+ query: {
18
+ lane_id: 215_863,
19
+ })
20
+
21
+ expect(cards.length).to eql 4
22
+ end
23
+
24
+ it 'can retrieve a card by ID' do
25
+ cards = Card.fetch(
26
+ adapter: 'github',
27
+ repository: 'thekompanee/hustle-and-flow-issue-dump',
28
+ query: {
29
+ id: 451_033,
30
+ },
31
+ )
32
+
33
+ expect(cards.first).to be_a HornOfPlenty::Models::Card
34
+ expect(cards.first.title).to eql 'First Card'
35
+ end
36
+
37
+ it 'can handle if the card with the ID cannot be found' do
38
+ cards = Card.fetch(
39
+ adapter: 'github',
40
+ repository: 'thekompanee/hustle-and-flow-issue-dump',
41
+ query: {
42
+ id: 2,
43
+ },
44
+ )
45
+
46
+ expect { cards.first }.to raise_error \
47
+ HornOfPlenty::Adapters::Github::Errors::NotFound
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+ require 'faraday'
3
+ require 'chamber'
4
+ require 'horn_of_plenty/adapters/github/configuration'
5
+ require 'horn_of_plenty/repositories/issue'
6
+ require 'horn_of_plenty/models/issue'
7
+ require 'rspeckled/spec_helpers/rspeckled'
8
+
9
+ module HornOfPlenty
10
+ module Repositories
11
+ describe Issue do
12
+ before(:each) { Adapters::Github.config.token = Chamber.env.adapters.github.token }
13
+
14
+ it 'can retrieve issues from an adapter' do
15
+ issues = Issue.fetch(adapter: 'github',
16
+ repository: 'thekompanee/hustle-and-flow-issue-dump')
17
+
18
+ expect(issues.length).to eql 3
19
+ end
20
+
21
+ it 'can retrieve a issue by ID' do
22
+ issues = Issue.fetch(
23
+ adapter: 'github',
24
+ repository: 'thekompanee/hustle-and-flow-issue-dump',
25
+ query: {
26
+ id: 1,
27
+ },
28
+ )
29
+
30
+ expect(issues.first).to be_a HornOfPlenty::Models::Issue
31
+ expect(issues.first.title).to eql 'Menu item specifications not working'
32
+ end
33
+
34
+ it 'can handle if the issue with the ID cannot be found' do
35
+ issues = Issue.fetch(
36
+ adapter: 'github',
37
+ repository: 'thekompanee/hustle-and-flow-issue-dump',
38
+ query: {
39
+ id: 100_000,
40
+ },
41
+ )
42
+
43
+ expect { issues.first }.to raise_error \
44
+ HornOfPlenty::Adapters::Github::Errors::NotFound
45
+ end
46
+ end
47
+ end
48
+ end