github_api 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/README.md +2 -2
  2. data/features/authentication.feature +8 -0
  3. data/features/cassettes/errors/repos/create.yml +36 -0
  4. data/features/cassettes/gists/gist.yml +64 -0
  5. data/features/cassettes/gists/gist/first.yml +65 -0
  6. data/features/cassettes/gists/gists/public_all.yml +71 -0
  7. data/features/cassettes/gists/gists/user_all.yml +48 -0
  8. data/features/cassettes/gists/star.yml +34 -0
  9. data/features/cassettes/pagination/repos/per_page/1.yml +134 -0
  10. data/features/cassettes/pagination/repos/per_page/each_page.yml +395 -0
  11. data/features/cassettes/pagination/repos/per_page/first.yml +135 -0
  12. data/features/error_codes.feature +13 -0
  13. data/features/gists.feature +31 -0
  14. data/features/pagination.feature +10 -0
  15. data/features/repos.feature +12 -10
  16. data/features/step_definitions/github_api_steps.rb +20 -5
  17. data/features/support/env.rb +8 -0
  18. data/features/support/helpers.rb +7 -0
  19. data/lib/github_api.rb +6 -6
  20. data/lib/github_api/api.rb +19 -11
  21. data/lib/github_api/authorization.rb +3 -3
  22. data/lib/github_api/connection.rb +1 -1
  23. data/lib/github_api/core_ext/array.rb +1 -2
  24. data/lib/github_api/core_ext/hash.rb +16 -2
  25. data/lib/github_api/deprecation.rb +39 -0
  26. data/lib/github_api/gists.rb +27 -10
  27. data/lib/github_api/page_uri_processor.rb +6 -2
  28. data/lib/github_api/response/raise_error.rb +1 -1
  29. data/lib/github_api/result.rb +2 -1
  30. data/lib/github_api/version.rb +1 -1
  31. data/spec/fixtures/gists/gist.json +58 -0
  32. data/spec/fixtures/gists/gists.json +28 -0
  33. data/spec/github/api_spec.rb +15 -0
  34. data/spec/github/authorization_spec.rb +5 -0
  35. data/spec/github/client_spec.rb +4 -0
  36. data/spec/github/core_ext/hash_spec.rb +45 -18
  37. data/spec/github/deprecation_spec.rb +31 -0
  38. data/spec/github/gists_spec.rb +461 -3
  39. data/spec/github/repos/watching_spec.rb +12 -4
  40. data/spec/github/request_spec.rb +3 -0
  41. data/spec/github_spec.rb +34 -29
  42. data/spec/spec_helper.rb +1 -0
  43. metadata +22 -4
@@ -85,13 +85,18 @@ describe Github::Repos::Watching, :type => :base do
85
85
  before do
86
86
  github.user = nil
87
87
  github.oauth_token = OAUTH_TOKEN
88
- stub_get("/user/watched?access_token=#{OAUTH_TOKEN}").
88
+ stub_get("/user/watched").
89
+ with(:query => {:access_token => OAUTH_TOKEN}).
89
90
  to_return(:body => fixture("repos/watched.json"), :status => 200, :headers => {})
90
91
  end
92
+ after do
93
+ github.oauth_token = nil
94
+ end
91
95
 
92
96
  it "should get the resources" do
93
97
  github.repos.watched
94
- a_get("/user/watched?access_token=#{OAUTH_TOKEN}").should have_been_made
98
+ a_get("/user/watched").with(:query => {:access_token => OAUTH_TOKEN}).
99
+ should have_been_made
95
100
  end
96
101
 
97
102
  it "should return array of resources" do
@@ -149,7 +154,8 @@ describe Github::Repos::Watching, :type => :base do
149
154
  before do
150
155
  github.user, github.repo = nil, nil
151
156
  github.oauth_token = OAUTH_TOKEN
152
- stub_put("/user/watched/#{user}/#{repo}?access_token=#{OAUTH_TOKEN}").
157
+ stub_put("/user/watched/#{user}/#{repo}").
158
+ with(:query => {:access_token => OAUTH_TOKEN}).
153
159
  to_return(:body => "", :status => 204, :headers => {})
154
160
  end
155
161
 
@@ -159,7 +165,9 @@ describe Github::Repos::Watching, :type => :base do
159
165
 
160
166
  it "should successfully watch a repo" do
161
167
  github.repos.start_watching(user, repo)
162
- a_put("/user/watched/#{user}/#{repo}?access_token=#{OAUTH_TOKEN}").should have_been_made
168
+ a_put("/user/watched/#{user}/#{repo}").
169
+ with(:query => {:access_token => OAUTH_TOKEN}).
170
+ should have_been_made
163
171
  end
164
172
  end
165
173
 
@@ -0,0 +1,3 @@
1
+ require 'spec_helper'
2
+
3
+
@@ -3,95 +3,100 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
3
  describe Github do
4
4
 
5
5
  before do
6
- Github.user = nil
7
- Github.repo = nil
6
+ subject.user = nil
7
+ subject.repo = nil
8
8
  end
9
9
 
10
10
  it "should respond to 'new' message" do
11
- Github.should respond_to :new
11
+ subject.should respond_to :new
12
12
  end
13
13
 
14
- it "should receive 'new' and initialize Github::Client instance" do
15
- Github.new.should be_a Github::Client
14
+ it "should receive 'new' and initialize subject::Client instance" do
15
+ subject.new.should be_a Github::Client
16
16
  end
17
17
 
18
18
  it "should respond to 'configure' message" do
19
- Github.should respond_to :configure
19
+ subject.should respond_to :configure
20
20
  end
21
21
 
22
22
  describe "setting configuration options" do
23
23
 
24
24
  it "should return default adapter" do
25
- Github.adapter.should == Github::Configuration::DEFAULT_ADAPTER
25
+ subject.adapter.should == Github::Configuration::DEFAULT_ADAPTER
26
26
  end
27
27
 
28
28
  it "should allow to set adapter" do
29
- Github.adapter = :typhoeus
30
- Github.adapter.should == :typhoeus
29
+ subject.adapter = :typhoeus
30
+ subject.adapter.should == :typhoeus
31
31
  end
32
32
 
33
33
  it "should return the default end point" do
34
- Github.endpoint.should == Github::Configuration::DEFAULT_ENDPOINT
34
+ subject.endpoint.should == Github::Configuration::DEFAULT_ENDPOINT
35
35
  end
36
36
 
37
37
  it "should allow to set endpoint" do
38
- Github.endpoint = 'http://linkedin.com'
39
- Github.endpoint.should == 'http://linkedin.com'
38
+ subject.endpoint = 'http://linkedin.com'
39
+ subject.endpoint.should == 'http://linkedin.com'
40
40
  end
41
41
 
42
42
  it "should return the default user agent" do
43
- Github.user_agent.should == Github::Configuration::DEFAULT_USER_AGENT
43
+ subject.user_agent.should == Github::Configuration::DEFAULT_USER_AGENT
44
44
  end
45
45
 
46
46
  it "should allow to set new user agent" do
47
- Github.user_agent = 'New User Agent'
48
- Github.user_agent.should == 'New User Agent'
47
+ subject.user_agent = 'New User Agent'
48
+ subject.user_agent.should == 'New User Agent'
49
49
  end
50
50
 
51
51
  it "should have not set oauth token" do
52
- Github.oauth_token.should be_nil
52
+ subject.oauth_token.should be_nil
53
53
  end
54
54
 
55
55
  it "should allow to set oauth token" do
56
- Github.oauth_token = ''
56
+ subject.oauth_token = ''
57
57
  end
58
58
 
59
59
  it "should have not set default user" do
60
- Github.user.should be_nil
60
+ subject.user.should be_nil
61
61
  end
62
62
 
63
63
  it "should allow to set new user" do
64
- Github.user = 'github'
65
- Github.user.should == 'github'
64
+ subject.user = 'github'
65
+ subject.user.should == 'github'
66
66
  end
67
67
 
68
68
  it "should have not set default repository" do
69
- Github.repo.should be_nil
69
+ subject.repo.should be_nil
70
70
  end
71
71
 
72
72
  it "should allow to set new repository" do
73
- Github.repo = 'github'
74
- Github.repo.should == 'github'
73
+ subject.repo = 'github'
74
+ subject.repo.should == 'github'
75
75
  end
76
76
 
77
77
  it "should have connection options as hash" do
78
- Github.connection_options.should be_a Hash
78
+ subject.connection_options.should be_a Hash
79
79
  end
80
80
 
81
81
  it "should initialize connection options to empty hash" do
82
- Github.connection_options.should be_empty
82
+ subject.connection_options.should be_empty
83
83
  end
84
84
 
85
85
  it "shoulve have not set user's login" do
86
- Github.login.should be_nil
86
+ subject.login.should be_nil
87
87
  end
88
88
 
89
89
  it "should have not set user's password" do
90
- Github.password.should be_nil
90
+ subject.password.should be_nil
91
91
  end
92
92
 
93
93
  it "should have set mime type to json" do
94
- Github.mime_type.should == :json
94
+ subject.mime_type.should == :json
95
+ end
96
+
97
+ it "should allow to set current api client" do
98
+ subject.should respond_to :api_client=
99
+ subject.should respond_to :api_client
95
100
  end
96
101
  end
97
102
 
@@ -106,4 +111,4 @@ describe Github do
106
111
  end
107
112
  end
108
113
 
109
- end
114
+ end # Github
@@ -11,6 +11,7 @@ require 'github_api'
11
11
  if RUBY_VERSION > '1.9' and ENV['COVERAGE']
12
12
  require 'coverage_adapter'
13
13
  SimpleCov.start 'github_api'
14
+ SimpleCov.coverage_dir 'coverage/rspec'
14
15
  end
15
16
 
16
17
  # Requires supporting files with custom matchers and macros, etc,
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: github_api
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.4.2
5
+ version: 0.4.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Piotr Murach
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-01-21 00:00:00 +00:00
13
+ date: 2012-02-04 00:00:00 +00:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -107,9 +107,9 @@ dependencies:
107
107
  requirement: &id009 !ruby/object:Gem::Requirement
108
108
  none: false
109
109
  requirements:
110
- - - ~>
110
+ - - ">="
111
111
  - !ruby/object:Gem::Version
112
- version: 1.6.4
112
+ version: "0"
113
113
  type: :development
114
114
  version_requirements: *id009
115
115
  - !ruby/object:Gem::Dependency
@@ -177,6 +177,13 @@ extra_rdoc_files: []
177
177
 
178
178
  files:
179
179
  - Rakefile
180
+ - features/authentication.feature
181
+ - features/cassettes/errors/repos/create.yml
182
+ - features/cassettes/gists/gist/first.yml
183
+ - features/cassettes/gists/gist.yml
184
+ - features/cassettes/gists/gists/public_all.yml
185
+ - features/cassettes/gists/gists/user_all.yml
186
+ - features/cassettes/gists/star.yml
180
187
  - features/cassettes/pagination/repos/commits/next.yml
181
188
  - features/cassettes/pagination/repos/commits/sha/next.yml
182
189
  - features/cassettes/pagination/repos/commits/sha.yml
@@ -184,10 +191,15 @@ files:
184
191
  - features/cassettes/pagination/repos/diff/next.yml
185
192
  - features/cassettes/pagination/repos/diff.yml
186
193
  - features/cassettes/pagination/repos/next.yml
194
+ - features/cassettes/pagination/repos/per_page/1.yml
195
+ - features/cassettes/pagination/repos/per_page/each_page.yml
196
+ - features/cassettes/pagination/repos/per_page/first.yml
187
197
  - features/cassettes/pagination/repos.yml
188
198
  - features/cassettes/repos/branches.yml
189
199
  - features/cassettes/repos/tags.yml
190
200
  - features/cassettes/repos/teams.yml
201
+ - features/error_codes.feature
202
+ - features/gists.feature
191
203
  - features/github_api.feature
192
204
  - features/options.feature
193
205
  - features/pagination.feature
@@ -196,6 +208,7 @@ files:
196
208
  - features/step_definitions/common_steps.rb
197
209
  - features/step_definitions/github_api_steps.rb
198
210
  - features/support/env.rb
211
+ - features/support/helpers.rb
199
212
  - features/support/vcr.rb
200
213
  - lib/github_api/api/actions.rb
201
214
  - lib/github_api/api.rb
@@ -209,6 +222,7 @@ files:
209
222
  - lib/github_api/constants.rb
210
223
  - lib/github_api/core_ext/array.rb
211
224
  - lib/github_api/core_ext/hash.rb
225
+ - lib/github_api/deprecation.rb
212
226
  - lib/github_api/error.rb
213
227
  - lib/github_api/events.rb
214
228
  - lib/github_api/gists/comments.rb
@@ -264,6 +278,8 @@ files:
264
278
  - spec/fixtures/auths/authorization.json
265
279
  - spec/fixtures/auths/authorizations.json
266
280
  - spec/fixtures/events/events.json
281
+ - spec/fixtures/gists/gist.json
282
+ - spec/fixtures/gists/gists.json
267
283
  - spec/fixtures/git_data/blob.json
268
284
  - spec/fixtures/git_data/blob_sha.json
269
285
  - spec/fixtures/git_data/commit.json
@@ -317,6 +333,7 @@ files:
317
333
  - spec/github/authorizations_spec.rb
318
334
  - spec/github/client_spec.rb
319
335
  - spec/github/core_ext/hash_spec.rb
336
+ - spec/github/deprecation_spec.rb
320
337
  - spec/github/events_spec.rb
321
338
  - spec/github/gists/comments_spec.rb
322
339
  - spec/github/gists_spec.rb
@@ -347,6 +364,7 @@ files:
347
364
  - spec/github/repos/pub_sub_hubbub_spec.rb
348
365
  - spec/github/repos/watching_spec.rb
349
366
  - spec/github/repos_spec.rb
367
+ - spec/github/request_spec.rb
350
368
  - spec/github/response/helpers_spec.rb
351
369
  - spec/github/result_spec.rb
352
370
  - spec/github/users_spec.rb