github_api 0.4.11 → 0.5.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. data/README.md +76 -72
  2. data/features/cassettes/gists/starred.yml +48 -0
  3. data/features/cassettes/pagination/repos/commits/list.yml +193 -0
  4. data/features/cassettes/pagination/repos/commits/next.yml +183 -0
  5. data/features/cassettes/pagination/repos/diff/next.yml +45 -0
  6. data/features/cassettes/pagination/repos/list.yml +176 -0
  7. data/features/cassettes/pagination/repos/list/next.yml +222 -0
  8. data/features/cassettes/pagination/repos/per_page/each_page.yml +45 -0
  9. data/features/cassettes/repos/list.yml +92 -0
  10. data/features/error_codes.feature +1 -1
  11. data/features/gists.feature +12 -3
  12. data/features/gists/comments.feature +3 -3
  13. data/features/github_api.feature +13 -2
  14. data/features/pagination.feature +40 -39
  15. data/features/repos.feature +2 -2
  16. data/features/step_definitions/common_steps.rb +12 -0
  17. data/features/step_definitions/github_api_steps.rb +12 -1
  18. data/lib/github_api.rb +1 -1
  19. data/lib/github_api/api.rb +4 -2
  20. data/lib/github_api/api_factory.rb +11 -5
  21. data/lib/github_api/authorizations.rb +23 -32
  22. data/lib/github_api/client.rb +1 -0
  23. data/lib/github_api/events.rb +38 -38
  24. data/lib/github_api/filter.rb +1 -1
  25. data/lib/github_api/gists.rb +47 -42
  26. data/lib/github_api/gists/comments.rb +77 -84
  27. data/lib/github_api/git_data.rb +25 -6
  28. data/lib/github_api/git_data/blobs.rb +48 -45
  29. data/lib/github_api/git_data/commits.rb +76 -73
  30. data/lib/github_api/git_data/references.rb +137 -118
  31. data/lib/github_api/git_data/tags.rb +74 -70
  32. data/lib/github_api/git_data/trees.rb +88 -85
  33. data/lib/github_api/issues.rb +43 -31
  34. data/lib/github_api/issues/comments.rb +116 -119
  35. data/lib/github_api/issues/events.rb +20 -19
  36. data/lib/github_api/issues/labels.rb +200 -197
  37. data/lib/github_api/issues/milestones.rb +137 -134
  38. data/lib/github_api/orgs.rb +27 -23
  39. data/lib/github_api/orgs/members.rb +105 -108
  40. data/lib/github_api/orgs/teams.rb +236 -237
  41. data/lib/github_api/paged_request.rb +1 -1
  42. data/lib/github_api/pull_requests.rb +40 -42
  43. data/lib/github_api/pull_requests/comments.rb +140 -143
  44. data/lib/github_api/repos.rb +101 -67
  45. data/lib/github_api/repos/collaborators.rb +64 -68
  46. data/lib/github_api/repos/commits.rb +50 -39
  47. data/lib/github_api/repos/downloads.rb +107 -110
  48. data/lib/github_api/repos/forks.rb +38 -39
  49. data/lib/github_api/repos/hooks.rb +161 -167
  50. data/lib/github_api/repos/keys.rb +86 -86
  51. data/lib/github_api/repos/pub_sub_hubbub.rb +99 -87
  52. data/lib/github_api/repos/watching.rb +80 -82
  53. data/lib/github_api/request.rb +5 -9
  54. data/lib/github_api/users.rb +26 -16
  55. data/lib/github_api/users/emails.rb +47 -47
  56. data/lib/github_api/users/followers.rb +85 -86
  57. data/lib/github_api/users/keys.rb +73 -75
  58. data/lib/github_api/validations.rb +25 -0
  59. data/lib/github_api/validations/format.rb +23 -0
  60. data/lib/github_api/validations/presence.rb +25 -0
  61. data/lib/github_api/validations/required.rb +21 -0
  62. data/lib/github_api/validations/token.rb +41 -0
  63. data/lib/github_api/version.rb +3 -3
  64. data/spec/fixtures/repos/commit_comparison.json +112 -0
  65. data/spec/github/api_factory_spec.rb +17 -1
  66. data/spec/github/authorizations_spec.rb +36 -34
  67. data/spec/github/gists/comments_spec.rb +39 -45
  68. data/spec/github/gists_spec.rb +50 -53
  69. data/spec/github/git_data/blobs_spec.rb +27 -20
  70. data/spec/github/git_data/commits_spec.rb +20 -19
  71. data/spec/github/git_data/references_spec.rb +83 -46
  72. data/spec/github/git_data/tags_spec.rb +16 -15
  73. data/spec/github/git_data/trees_spec.rb +20 -19
  74. data/spec/github/git_data_spec.rb +10 -1
  75. data/spec/github/issues/comments_spec.rb +78 -68
  76. data/spec/github/issues/events_spec.rb +42 -34
  77. data/spec/github/issues/labels_spec.rb +89 -101
  78. data/spec/github/issues/milestones_spec.rb +76 -54
  79. data/spec/github/issues_spec.rb +53 -57
  80. data/spec/github/orgs/members_spec.rb +64 -49
  81. data/spec/github/orgs/teams_spec.rb +112 -101
  82. data/spec/github/orgs_spec.rb +41 -31
  83. data/spec/github/paged_request_spec.rb +6 -5
  84. data/spec/github/pull_requests/comments_spec.rb +39 -44
  85. data/spec/github/pull_requests_spec.rb +32 -48
  86. data/spec/github/repos/collaborators_spec.rb +40 -29
  87. data/spec/github/repos/commits_spec.rb +108 -64
  88. data/spec/github/repos/downloads_spec.rb +46 -45
  89. data/spec/github/repos/forks_spec.rb +23 -24
  90. data/spec/github/repos/hooks_spec.rb +69 -71
  91. data/spec/github/repos/keys_spec.rb +39 -34
  92. data/spec/github/repos/pub_sub_hubbub_spec.rb +4 -4
  93. data/spec/github/repos/watching_spec.rb +31 -33
  94. data/spec/github/repos_spec.rb +74 -83
  95. data/spec/github/request_spec.rb +31 -2
  96. data/spec/github/users/emails_spec.rb +19 -17
  97. data/spec/github/users/followers_spec.rb +30 -28
  98. data/spec/github/users/keys_spec.rb +37 -33
  99. data/spec/github/users_spec.rb +124 -125
  100. data/spec/github/validations/format_spec.rb +42 -0
  101. data/spec/github/validations/presence_spec.rb +18 -0
  102. data/spec/github/validations/required_spec.rb +28 -0
  103. data/spec/github/validations/token_spec.rb +19 -0
  104. data/spec/github/validations_spec.rb +23 -0
  105. metadata +33 -10
  106. data/features/cassettes/pagination/repos.yml +0 -177
  107. data/features/cassettes/pagination/repos/next.yml +0 -177
  108. data/lib/github_api/validation.rb +0 -53
  109. data/spec/github/validation_spec.rb +0 -62
@@ -410,4 +410,49 @@ http_interactions:
410
410
 
411
411
  http_version:
412
412
  recorded_at: Sat, 10 Mar 2012 23:14:13 GMT
413
+ - request:
414
+ method: get
415
+ uri: https://api.github.com/repos/https://api.github.com/users/wycats/repos/%7B%22page%22=%3E2,%20%22per_page%22=%3E30%7D
416
+ body:
417
+ encoding: US-ASCII
418
+ string: ""
419
+ headers:
420
+ Accept-Encoding:
421
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
422
+ Accept:
423
+ - "*/*"
424
+ User-Agent:
425
+ - Ruby
426
+ response:
427
+ status:
428
+ code: 404
429
+ message: Not Found
430
+ headers:
431
+ Server:
432
+ - nginx/1.0.13
433
+ Date:
434
+ - Mon, 09 Apr 2012 15:18:37 GMT
435
+ Content-Type:
436
+ - application/json; charset=utf-8
437
+ Transfer-Encoding:
438
+ - chunked
439
+ Connection:
440
+ - keep-alive
441
+ Status:
442
+ - 404 Not Found
443
+ X-Ratelimit-Limit:
444
+ - "5000"
445
+ Etag:
446
+ - "\"e66a7a6c91e2c26803f3f49feb7a883f\""
447
+ X-Ratelimit-Remaining:
448
+ - "4998"
449
+ Content-Encoding:
450
+ - gzip
451
+ body:
452
+ encoding: ASCII-8BIT
453
+ string: !binary |
454
+ H4sIAAAAAAAAA6tWyk0tLk5MT1WyUvLLL1Fwyy/NS1GqBQB8+Ys1FwAAAA==
455
+
456
+ http_version:
457
+ recorded_at: Mon, 09 Apr 2012 15:18:37 GMT
413
458
  recorded_with: VCR 2.0.0
@@ -0,0 +1,92 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.github.com/users/peter-murach/repos
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ""
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Server:
22
+ - nginx/1.0.13
23
+ Date:
24
+ - Mon, 09 Apr 2012 17:55:27 GMT
25
+ Content-Type:
26
+ - application/json; charset=utf-8
27
+ Transfer-Encoding:
28
+ - chunked
29
+ Connection:
30
+ - keep-alive
31
+ Status:
32
+ - 200 OK
33
+ X-Ratelimit-Limit:
34
+ - "5000"
35
+ Etag:
36
+ - "\"8fdb914bd8bb00728968cb0942542ec8\""
37
+ X-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jeOO3T45LqIvqCE9rd+OBofAcRmpTRS/40EsZFNf22Hz3nBN
76
+ TuRoqZ8GXMgZgbzdXxwdyuGeaiO3LWsmO3oDZej1gY8X2wCAVjE6gEM2HeNE
77
+ fTqALYoHIIZ2yQqqOHmea2z87RYpyWOYDL9F6auq//My1DRjTbulC/nJkWwo
78
+ yYzh1gDo3wBocRYQpUwfDN206Wy4Wt+L0rUP7lLXBMXhATo+qPR1R+9V7Fea
79
+ BuCKmigFOeAAoWnxNcihZoKSDf70dx/6VPpHfumWTRzd1APpxZ4xlakjHG/d
80
+ EooBEopayDSh/VMUrv0NJoPzQcMcjvmRIgsCbfesZaH/GYcL0X72EMOMxJyj
81
+ ZTNQNhFw/tiKf2y1qCDQELAdM5/fu/TwUGoZAPulGAXuTyy9Bu5L9UrM920F
82
+ 1PzQDe+1G9RYJ2aHEeMC64WTp5gWuO3q/Xf1MkyOcJ6hd7/iiYYmHIoIFnra
83
+ w8eYu3KqkLtFS79APoazUV54mEIO8ynkakgIyJ+Z8qhmIOS7mLQXacLCaIyj
84
+ yzGGDjGQdIYKiqkha+5YeR/9UipQqh2AG9rkKsni8Cx5Y+QaZNFmz1XYQ6ns
85
+ VXXDOQlqfpl3pZdy3Axvs+SvstxGEfuNIio9hXVt8s3vWZAC3rJBcbhBzihg
86
+ eHmzpxQ6tWzpx4EopRiBWLpB/goPbDqaWi5KCrzQgnzC6jl9eNA1AHk0hCkY
87
+ A2VF0+prMEbDiKvQxIl/uqUaJ7epCcGYd2gjIAQwnEwWqCwMzKXciosBiotG
88
+ 4BylHR/ej1d4ecHTmOtyIeSg0tvDRMF+UAmdZrzsdZpc/Ps/lLXz8uY4AAA=
89
+
90
+ http_version:
91
+ recorded_at: Mon, 09 Apr 2012 17:55:27 GMT
92
+ recorded_with: VCR 2.0.0
@@ -6,7 +6,7 @@ Feature: Handles HTTP error codes
6
6
 
7
7
  Scenario: A response of '401 - Unauthorised access'
8
8
  Given I have "Github::Repos" instance
9
- When I am looking for "create_repo"
9
+ When I want to create resource
10
10
  And I pass the following request options:
11
11
  | name |
12
12
  | basic_auth |
@@ -7,7 +7,7 @@ Feature: Accessing Gists Main API
7
7
  Given I have "Github::Gists" instance
8
8
 
9
9
  Scenario: Lists all user's gists
10
- When I am looking for "gists" with the following params:
10
+ When I want to list resources with the following params:
11
11
  | user |
12
12
  | peter-murach |
13
13
  And I make request within a cassette named "gists/gists/user_all"
@@ -15,7 +15,7 @@ Feature: Accessing Gists Main API
15
15
  And the response type should be "JSON"
16
16
 
17
17
  Scenario: Lists all public gists
18
- When I am looking for "gists" with the following params:
18
+ When I want to list resources with the following params:
19
19
  | user |
20
20
  | nil |
21
21
  And I make request within a cassette named "gists/gists/public_all"
@@ -23,9 +23,18 @@ Feature: Accessing Gists Main API
23
23
  And the response type should be "JSON"
24
24
 
25
25
  Scenario: Gets a single gist
26
- When I am looking for "gist" with the following params:
26
+ When I want to get resource with the following params:
27
27
  | gist_id |
28
28
  | 1738161 |
29
29
  And I make request within a cassette named "gists/gist"
30
30
  Then the response should be "200"
31
31
  And the response type should be "JSON"
32
+
33
+ Scenario: Check if gist is starred
34
+ When I want to starred? resource with the following params:
35
+ | gist_id |
36
+ | 1738161 |
37
+ And I make request within a cassette named "gists/starred"
38
+ Then the response should equal false
39
+
40
+
@@ -4,10 +4,10 @@ Feature: Accessing Gists Comments API
4
4
  Should return the expected results depending on passed parameters
5
5
 
6
6
  Background:
7
- Given I have "Github::Gists" instance
7
+ Given I have "Github::Gists::Comments" instance
8
8
 
9
9
  Scenario: Lists comments on a gist
10
- When I am looking for "comments" with the following params:
10
+ When I want to list resources with the following params:
11
11
  | gist_id |
12
12
  | 999390 |
13
13
  And I make request within a cassette named "gists/comments/all"
@@ -16,7 +16,7 @@ Feature: Accessing Gists Comments API
16
16
  And the response should have 18 items
17
17
 
18
18
  Scenario: Gets a single gist's comment
19
- When I am looking for "comment" with the following params:
19
+ When I want to get resource with the following params:
20
20
  | comment_id |
21
21
  | 33469 |
22
22
  And I make request within a cassette named "gists/comments/first"
@@ -1,7 +1,8 @@
1
1
  Feature: Github API components
2
2
 
3
- In order to interact with full Github API
4
- A user needs to request a Github class instance
3
+ In order to navigate within Github API hierachy
4
+ A user
5
+ I want to be able to with a given Github API instance
5
6
 
6
7
  Scenario: Accessing repositories API
7
8
  Given I have github instance
@@ -13,6 +14,16 @@ Feature: Github API components
13
14
  When I fetch "orgs"
14
15
  Then I will have access to "Github::Orgs" API
15
16
 
17
+ Scenario: Accessing members API
18
+ Given I have "Github::Orgs" instance
19
+ When I call members
20
+ Then I will have access to "Github::Orgs::Members" API
21
+
22
+ Scenario: Accessing teams API
23
+ Given I have "Github::Orgs" instance
24
+ When I call teams
25
+ Then I will have access to "Github::Orgs::Teams" API
26
+
16
27
  Scenario: Accessing gists API
17
28
  Given I have github instance
18
29
  When I fetch "gists"
@@ -5,73 +5,74 @@ Feature: Githu API pagination
5
5
 
6
6
  Scenario: Passing per_page param
7
7
  Given I have "Github::Repos" instance
8
- When I am looking for "repos"
9
- And I pass the following request options:
10
- | user | per_page |
11
- | wycats | 45 |
12
- And I make request within a cassette named "pagination/repos"
8
+ When I want to list resources
9
+ And I pass the following request options:
10
+ | user | per_page |
11
+ | wycats | 45 |
12
+ And I make request within a cassette named "pagination/repos/list"
13
13
  Then the response should be "200"
14
- And the response type should be "JSON"
15
- And the response should have 45 items
14
+ And the response type should be "JSON"
15
+ And the response should have 45 items
16
16
 
17
- When I request "next" page within a cassette named "pagination/repos/next"
17
+ When I request "next" page within a cassette named "pagination/repos/list/next"
18
18
  Then the response should be "200"
19
- And the response should have 45 items
19
+ And the response should have 45 items
20
20
 
21
21
  Scenario: Returned paginated resources are different
22
22
  Given I have "Github::Repos" instance
23
- When I am looking for "repos"
24
- And I pass the following request options:
25
- | user |
26
- | wycats |
27
- And I make request within a cassette named "pagination/repos/diff"
23
+ When I want to list resources
24
+ And I pass the following request options:
25
+ | user |
26
+ | wycats |
27
+ And I make request within a cassette named "pagination/repos/diff"
28
28
  Then the response should be "200"
29
- And the response type should be "JSON"
30
- And the response should have 30 items
29
+ And the response type should be "JSON"
30
+ And the response should have 30 items
31
31
 
32
32
  When I request "next" page within a cassette named "pagination/repos/diff/next"
33
33
  Then the response should be "200"
34
- And the response should have 30 items
35
- And the response collection of resources is different for "name" attribute
34
+ And the response should have 30 items
35
+ And the response collection of resources is different for "name" attribute
36
36
 
37
37
  Scenario: Calling 'commits' for Github::Repos with per_page param
38
- Given I have "Github::Repos" instance
39
- When I am looking for "commits" with the following params:
38
+ Given I have "Github::Repos::Commits" instance
39
+ When I am looking for "list" with the following params:
40
40
  | user | repo |
41
41
  | peter-murach | github |
42
- And I pass the following request options:
43
- | per_page |
44
- | 45 |
45
- And I make request within a cassette named "pagination/repos/commits"
42
+ And I pass the following request options:
43
+ | per_page |
44
+ | 45 |
45
+ And I make request within a cassette named "pagination/repos/commits/list"
46
46
  Then the response should be "200"
47
- And the response type should be "JSON"
48
- And the response should have 45 items
47
+ And the response type should be "JSON"
48
+ And the response should have 45 items
49
49
 
50
50
  When I request "next" page within a cassette named "pagination/repos/commits/next"
51
51
  Then the response should be "200"
52
- And the response should have 45 items
52
+ And the response should have 45 items
53
53
 
54
- Scenario: Calling 'commits' for Github::Repos returns different collections
55
- Given I have "Github::Repos" instance
56
- When I am looking for "commits" with the following params:
54
+ Scenario: Calling 'list' for Github::Repos::Commits returns different collections
55
+ Given I have "Github::Repos::Commits" instance
56
+ When I am looking for "list" with the following params:
57
57
  | user | repo |
58
58
  | peter-murach | github |
59
- And I make request within a cassette named "pagination/repos/commits/sha"
59
+ And I make request within a cassette named "pagination/repos/commits/sha"
60
60
  Then the response should be "200"
61
- And the response should have 30 items
61
+ And the response should have 30 items
62
62
 
63
63
  When I request "next" page within a cassette named "pagination/repos/commits/sha/next"
64
64
  Then the response should be "200"
65
- And the response should have 30 items
66
- And the response collection of resources is different for "sha" attribute
65
+ And the response should have 30 items
66
+ And the response collection of resources is different for "sha" attribute
67
67
 
68
68
  Scenario: Requesting resources with per_page helper
69
69
  Given I have "Github::Repos" instance
70
- When I am looking for "repos"
71
- And I pass the following request options:
72
- | user |
73
- | wycats |
74
- And I make request within a cassette named "pagination/repos/per_page/first"
70
+ When I want to list resources
71
+ And I pass the following request options:
72
+ | user |
73
+ | wycats |
74
+ And I make request within a cassette named "pagination/repos/per_page/first"
75
75
  Then the response should be "200"
76
76
  When I iterate through collection pages within a cassette named "pagination/repos/per_page/each_page"
77
77
  Then this collection should include first page
78
+
@@ -23,10 +23,10 @@ Feature: Accessing Repos Main API
23
23
  And the response type should be "JSON"
24
24
 
25
25
  Scenario: Returning all repositories for the user
26
- When I am looking for "list_repos"
26
+ When I want to list resources
27
27
  And I pass the following request options:
28
28
  | user |
29
29
  | peter-murach |
30
- And I make request within a cassette named "repos/tags"
30
+ And I make request within a cassette named "repos/list"
31
31
  Then the response should be "200"
32
32
  And the response type should be "JSON"
@@ -10,6 +10,18 @@ Then /^the response should be "([^"]*)"$/ do |expected_response|
10
10
  @response.status.should eql expected_response.to_i
11
11
  end
12
12
 
13
+ Then /^the response should equal (.*)$/ do |expected_response|
14
+ expected = case expected_response
15
+ when /t/
16
+ true
17
+ when /f/
18
+ false
19
+ else
20
+ raise ArgumentError 'Expected boolean type!'
21
+ end
22
+ @response.should == expected
23
+ end
24
+
13
25
  Then /^the response type should be "([^"]*)"$/ do |type|
14
26
  @response.content_type.should =~ /application\/#{type.downcase}/
15
27
  end
@@ -10,14 +10,25 @@ When /^I fetch "([^"]*)"$/ do |method|
10
10
  @response = @github.send(method.to_sym)
11
11
  end
12
12
 
13
+ When /^I call (.*)$/ do |api_part|
14
+ @response = @instance.send(api_part.to_sym)
15
+ end
16
+
13
17
  When /^I will have access to "([^"]*)" API$/ do |api|
14
18
  @response.class.to_s.should match api
15
19
  end
16
20
 
17
- When /^I am looking for "([^"]*)"$/ do |method|
21
+ When /^I want to (.*) (?:resource|resources)$/ do |method|
18
22
  @method = method
19
23
  end
20
24
 
25
+ When /^I want to (.*) (?:resource|resources) with the following params:$/ do |method, table|
26
+ table.hashes.each do |attributes|
27
+ @method = method.to_sym
28
+ @attributes = attributes
29
+ end
30
+ end
31
+
21
32
  When /^I pass the following request options:$/ do |table|
22
33
  table.hashes.each do |options|
23
34
  @options = options
data/lib/github_api.rb CHANGED
@@ -81,7 +81,7 @@ module Github
81
81
  :PageLinks => 'page_links',
82
82
  :PageIterator => 'page_iterator',
83
83
  :PagedRequest => 'paged_request',
84
- :Validation => 'validation',
84
+ :Validations => 'validations',
85
85
  :Filter => 'filter'
86
86
 
87
87
  end # Github
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'github_api/configuration'
4
4
  require 'github_api/connection'
5
- require 'github_api/validation'
5
+ require 'github_api/validations'
6
6
  require 'github_api/request'
7
7
  require 'github_api/mime_type'
8
8
  require 'github_api/core_ext/hash'
@@ -19,9 +19,11 @@ module Github
19
19
  include MimeType
20
20
  include Connection
21
21
  include Request
22
- include Validation
22
+ # TODO Validation & Filter will be optional
23
+ include Validations
23
24
  include Filter
24
25
 
26
+
25
27
  attr_reader *Configuration::VALID_OPTIONS_KEYS
26
28
  attr_accessor *VALID_API_KEYS
27
29