fb_graph 1.7.5 → 1.8.0.alpha

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. data/Gemfile.lock +4 -2
  2. data/VERSION +1 -1
  3. data/fb_graph.gemspec +2 -1
  4. data/lib/fb_graph/album.rb +0 -9
  5. data/lib/fb_graph/connections/picture.rb +3 -2
  6. data/lib/fb_graph/node.rb +23 -33
  7. data/lib/fb_graph/query.rb +6 -10
  8. data/lib/fb_graph.rb +1 -0
  9. data/spec/fb_graph/album_spec.rb +54 -75
  10. data/spec/fb_graph/app_request_spec.rb +2 -2
  11. data/spec/fb_graph/checkin_spec.rb +2 -3
  12. data/spec/fb_graph/collection_spec.rb +1 -3
  13. data/spec/fb_graph/connection_spec.rb +6 -12
  14. data/spec/fb_graph/connections/accounts_spec.rb +2 -6
  15. data/spec/fb_graph/connections/activities_spec.rb +1 -3
  16. data/spec/fb_graph/connections/albums_spec.rb +2 -5
  17. data/spec/fb_graph/connections/app_requests_spec.rb +1 -3
  18. data/spec/fb_graph/connections/attending_spec.rb +2 -6
  19. data/spec/fb_graph/connections/books_spec.rb +1 -3
  20. data/spec/fb_graph/connections/checkins_spec.rb +2 -6
  21. data/spec/fb_graph/connections/comments_spec.rb +1 -1
  22. data/spec/fb_graph/connections/declined_spec.rb +2 -6
  23. data/spec/fb_graph/connections/events_spec.rb +1 -3
  24. data/spec/fb_graph/connections/family_spec.rb +1 -3
  25. data/spec/fb_graph/connections/feed_spec.rb +1 -3
  26. data/spec/fb_graph/connections/former_participants_spec.rb +1 -2
  27. data/spec/fb_graph/connections/friend_lists_spec.rb +1 -3
  28. data/spec/fb_graph/connections/friends_spec.rb +2 -6
  29. data/spec/fb_graph/connections/games_spec.rb +1 -3
  30. data/spec/fb_graph/connections/groups_spec.rb +1 -3
  31. data/spec/fb_graph/connections/home_spec.rb +2 -6
  32. data/spec/fb_graph/connections/insights_spec.rb +3 -9
  33. data/spec/fb_graph/connections/interests_spec.rb +1 -3
  34. data/spec/fb_graph/connections/invited_spec.rb +1 -3
  35. data/spec/fb_graph/connections/likes_spec.rb +4 -8
  36. data/spec/fb_graph/connections/links_spec.rb +1 -3
  37. data/spec/fb_graph/connections/maybe_spec.rb +1 -3
  38. data/spec/fb_graph/connections/members_spec.rb +1 -3
  39. data/spec/fb_graph/connections/messages_spec.rb +1 -4
  40. data/spec/fb_graph/connections/movies_spec.rb +1 -3
  41. data/spec/fb_graph/connections/music_spec.rb +1 -3
  42. data/spec/fb_graph/connections/noreply_spec.rb +1 -3
  43. data/spec/fb_graph/connections/notes_spec.rb +2 -5
  44. data/spec/fb_graph/connections/participants_spec.rb +1 -4
  45. data/spec/fb_graph/connections/permissions_spec.rb +1 -3
  46. data/spec/fb_graph/connections/photos_spec.rb +1 -3
  47. data/spec/fb_graph/connections/senders_spec.rb +1 -4
  48. data/spec/fb_graph/connections/statuses_spec.rb +2 -6
  49. data/spec/fb_graph/connections/subscriptions_spec.rb +3 -5
  50. data/spec/fb_graph/connections/television_spec.rb +1 -3
  51. data/spec/fb_graph/connections/test_users_spec.rb +1 -3
  52. data/spec/fb_graph/connections/threads_spec.rb +1 -3
  53. data/spec/fb_graph/connections/videos_spec.rb +1 -3
  54. data/spec/fb_graph/node_spec.rb +31 -28
  55. data/spec/fb_graph/post_spec.rb +2 -6
  56. data/spec/fb_graph/query/core_spec.rb +0 -10
  57. data/spec/fb_graph/test_user_spec.rb +5 -5
  58. data/spec/fb_graph/user_spec.rb +2 -6
  59. data/spec/helpers/webmock_helper.rb +14 -10
  60. data/spec/mock_json/users/home/me_private.json +2 -2
  61. metadata +26 -15
data/Gemfile.lock CHANGED
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fb_graph (1.7.4)
5
- rack-oauth2 (>= 0.6.5)
4
+ fb_graph (1.8.0.alpha)
5
+ httpclient (>= 2.2.0.2)
6
+ rack-oauth2 (>= 0.6.9)
6
7
 
7
8
  GEM
8
9
  remote: http://rubygems.org/
@@ -12,6 +13,7 @@ GEM
12
13
  attr_required (0.0.3)
13
14
  crack (0.1.8)
14
15
  diff-lcs (1.1.2)
16
+ httpclient (2.2.0.2)
15
17
  i18n (0.5.0)
16
18
  json (1.5.1)
17
19
  mime-types (1.16)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.7.5
1
+ 1.8.0.alpha
data/fb_graph.gemspec CHANGED
@@ -12,7 +12,8 @@ Gem::Specification.new do |s|
12
12
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
13
13
  s.files = `git ls-files`.split("\n")
14
14
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
- s.add_runtime_dependency "rack-oauth2", ">= 0.6.5"
15
+ s.add_runtime_dependency "httpclient", ">= 2.2.0.2"
16
+ s.add_runtime_dependency "rack-oauth2", ">= 0.6.9"
16
17
  s.add_development_dependency "rake", ">= 0.8"
17
18
  s.add_development_dependency "rcov", ">= 0.9"
18
19
  s.add_development_dependency "rspec", ">= 2"
@@ -3,7 +3,6 @@ module FbGraph
3
3
  include Connections::Photos
4
4
  include Connections::Comments
5
5
  include Connections::Likes
6
- include Connections::Picture
7
6
 
8
7
  attr_accessor :from, :name, :description, :location, :link, :privacy, :count, :created_time, :updated_time, :type
9
8
 
@@ -39,13 +38,5 @@ module FbGraph
39
38
  # cached connection
40
39
  @_comments_ = Collection.new(attributes[:comments])
41
40
  end
42
-
43
- def picture_with_access_token(size = nil)
44
- raise Unauthorized.new('Album picture connection requires an access token') unless self.access_token
45
- _endpoint_ = URI.parse picture_without_access_token(size)
46
- _endpoint_.query = [_endpoint_.query, {:access_token => self.access_token.to_s}.to_query].compact.join('&')
47
- _endpoint_.to_s
48
- end
49
- alias_method_chain :picture, :access_token
50
41
  end
51
42
  end
@@ -4,9 +4,10 @@ module FbGraph
4
4
  def picture(size = nil)
5
5
  _endpoint_ = "#{self.endpoint}/picture"
6
6
  if size
7
- _endpoint_ += "?type=#{size}"
7
+ "#{_endpoint_}?type=#{size}"
8
+ else
9
+ _endpoint_
8
10
  end
9
- _endpoint_
10
11
  end
11
12
  end
12
13
  end
data/lib/fb_graph/node.rb CHANGED
@@ -36,54 +36,45 @@ module FbGraph
36
36
  protected
37
37
 
38
38
  def get(params = {})
39
- _params_ = stringfy_params(params)
40
- _endpoint_ = build_endpoint(_params_.merge!(:method => :get))
41
39
  handle_response do
42
- RestClient.get(_endpoint_)
40
+ HTTPClient.new.get build_endpoint(params), build_params(params)
43
41
  end
44
42
  end
45
43
 
46
44
  def post(params = {})
47
- _params_ = stringfy_params(params)
48
- _endpoint_ = build_endpoint(_params_.merge!(:method => :post))
49
45
  handle_response do
50
- RestClient.post(_endpoint_, _params_)
46
+ HTTPClient.new.post build_endpoint(params), build_params(params)
51
47
  end
52
48
  end
53
49
 
54
50
  def delete(params = {})
55
- _params_ = stringfy_params(params)
56
- _endpoint_ = build_endpoint(_params_.merge!(:method => :delete))
51
+ _endpoint_, _params_ = build_endpoint(params), build_params(params)
52
+ _endpoint_ = [_endpoint_, _params_.try(:to_query)].compact.join('?')
57
53
  handle_response do
58
- RestClient.delete(_endpoint_)
54
+ HTTPClient.new.delete _endpoint_
59
55
  end
60
56
  end
61
57
 
62
58
  private
63
59
 
64
60
  def build_endpoint(params = {})
65
- _endpoint_ = File.join([self.endpoint, params.delete(:connection), params.delete(:connection_scope)].compact.collect(&:to_s))
66
- params.delete_if do |k, v|
67
- v.blank?
68
- end
69
- if [:get, :delete].include?(params.delete(:method)) && params.present?
70
- _endpoint_ << "?#{params.to_query}"
71
- end
72
- _endpoint_
61
+ File.join([self.endpoint, params.delete(:connection), params.delete(:connection_scope)].compact.collect(&:to_s))
73
62
  end
74
63
 
75
- def stringfy_params(params)
64
+ def build_params(params)
76
65
  _params_ = params.dup
77
- _params_[:access_token] ||= self.access_token
78
- if _params_[:access_token].is_a?(Rack::OAuth2::AccessToken::Legacy)
79
- _params_[:access_token] = _params_[:access_token].access_token
66
+ _params_[:oauth_token] = (_params_.delete(:access_token) || self.access_token).to_s
67
+ _params_.delete_if do |k, v|
68
+ v.blank?
80
69
  end
81
70
  _params_.each do |key, value|
82
71
  if value.present? && ![Symbol, String, Numeric, IO].any? { |klass| value.is_a? klass }
83
72
  _params_[key] = value.to_json
73
+ else
74
+ _params_[key] = value.to_s
84
75
  end
85
76
  end
86
- _params_
77
+ _params_.blank? ? nil : _params_
87
78
  end
88
79
 
89
80
  def handle_response
@@ -103,27 +94,26 @@ module FbGraph
103
94
  nil
104
95
  else
105
96
  _response_ = JSON.parse(response.body)
106
- case _response_
97
+ _response_ = case _response_
107
98
  when Array
108
99
  _response_.map!(&:with_indifferent_access)
109
100
  when Hash
110
- _response_.with_indifferent_access
101
+ _response_ = _response_.with_indifferent_access
102
+ handle_httpclient_error(_response_) if _response_[:error]
103
+ _response_
111
104
  end
112
105
  end
113
- rescue RestClient::Exception => e
114
- handle_restclient_error(e)
106
+ rescue JSON::ParserError
107
+ raise Exception.new(response.status, 'Unparsable Error Response')
115
108
  end
116
109
 
117
- def handle_restclient_error(e)
118
- _response_ = JSON.parse(e.http_body).with_indifferent_access
119
- case _response_[:error][:type]
110
+ def handle_httpclient_error(response)
111
+ case response[:error][:type]
120
112
  when /OAuth/
121
- raise Unauthorized.new(e.message, e.http_body)
113
+ raise Unauthorized.new("#{response[:error][:type]} :: #{response[:error][:message]}")
122
114
  else
123
- raise BadRequest.new(e.message, e.http_body)
115
+ raise BadRequest.new("#{response[:error][:type]} :: #{response[:error][:message]}")
124
116
  end
125
- rescue JSON::ParserError
126
- raise Exception.new(e.http_code, e.message, e.http_body)
127
117
  end
128
118
  end
129
119
  end
@@ -1,5 +1,7 @@
1
1
  module FbGraph
2
2
  class Query < Node
3
+ ENDPOINT = 'https://api.facebook.com/method/fql.query'
4
+
3
5
  attr_accessor :access_token, :query
4
6
 
5
7
  def initialize(query, access_token = nil)
@@ -8,25 +10,19 @@ module FbGraph
8
10
  end
9
11
 
10
12
  def fetch(access_token = nil)
11
- self.access_token ||= access_token
12
13
  handle_response do
13
- RestClient.get build_endpoint
14
+ HTTPClient.new.get ENDPOINT, :query => build_params(access_token)
14
15
  end
15
16
  end
16
17
 
17
18
  private
18
19
 
19
- ENDPOINT = 'https://api.facebook.com/method/fql.query'
20
- def build_endpoint
21
- params = stringfy_params(
20
+ def build_params(access_token)
21
+ super(
22
22
  :query => self.query,
23
- :access_token => self.access_token,
23
+ :access_token => access_token || self.access_token,
24
24
  :format => :json
25
25
  )
26
- params.delete_if do |k, v|
27
- v.blank?
28
- end
29
- ENDPOINT + "?#{params.to_query}"
30
26
  end
31
27
 
32
28
  def handle_response
data/lib/fb_graph.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'httpclient'
1
2
  require 'rack/oauth2'
2
3
 
3
4
  module FbGraph
@@ -1,84 +1,63 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe FbGraph::Album do
3
+ describe FbGraph::Album, '.new' do
4
4
 
5
- describe '.new' do
6
- it 'should setup all supported attributes' do
7
- attributes = {
8
- :id => '12345',
9
- :from => {
10
- :id => '23456',
11
- :name => 'nov matake'
12
- },
13
- :name => 'album 1',
14
- :description => 'an album for fb_graph test',
15
- :location => 'Tokyo, Japan',
16
- :link => 'http://www.facebook.com/album/12345',
17
- :count => 10,
18
- :type => 'normal',
19
- :created_time => '2009-12-29T15:24:50+0000',
20
- :updated_time => '2010-01-02T15:37:41+0000',
21
- :comments => {
22
- :data => [{
23
- :id => '909694472945_418735',
24
- :from => {
25
- :id => '520739622',
26
- :name => 'Alison Marie Weber',
27
- },
28
- :message => 'Love all the pix!',
29
- :created_time => '2009-08-15T14:57:36+0000'
30
- }]
31
- }
32
- }
33
- album = FbGraph::Album.new(attributes.delete(:id), attributes)
34
- album.identifier.should == '12345'
35
- album.from.should == FbGraph::User.new('23456', :name => 'nov matake')
36
- album.name.should == 'album 1'
37
- album.description.should == 'an album for fb_graph test'
38
- album.location.should == 'Tokyo, Japan'
39
- album.link.should == 'http://www.facebook.com/album/12345'
40
- album.count.should == 10
41
- album.type.should == 'normal'
42
- album.created_time.should == Time.parse('2009-12-29T15:24:50+0000')
43
- album.updated_time.should == Time.parse('2010-01-02T15:37:41+0000')
44
- album.comments.should == [FbGraph::Comment.new(
45
- '909694472945_418735',
46
- :from => {
47
- :id => '520739622',
48
- :name => 'Alison Marie Weber',
49
- },
50
- :message => 'Love all the pix!',
51
- :created_time => '2009-08-15T14:57:36+0000'
52
- )]
53
- end
54
-
55
- it 'should support page as from' do
56
- page_album = FbGraph::Album.new('12345', :from => {
5
+ it 'should setup all supported attributes' do
6
+ attributes = {
7
+ :id => '12345',
8
+ :from => {
57
9
  :id => '23456',
58
- :name => 'Smart.fm',
59
- :category => 'Web Site'
60
- })
61
- page_album.from.should == FbGraph::Page.new('23456', :name => 'Smart.fm', :category => 'Web Site')
62
- end
10
+ :name => 'nov matake'
11
+ },
12
+ :name => 'album 1',
13
+ :description => 'an album for fb_graph test',
14
+ :location => 'Tokyo, Japan',
15
+ :link => 'http://www.facebook.com/album/12345',
16
+ :count => 10,
17
+ :type => 'normal',
18
+ :created_time => '2009-12-29T15:24:50+0000',
19
+ :updated_time => '2010-01-02T15:37:41+0000',
20
+ :comments => {
21
+ :data => [{
22
+ :id => '909694472945_418735',
23
+ :from => {
24
+ :id => '520739622',
25
+ :name => 'Alison Marie Weber',
26
+ },
27
+ :message => 'Love all the pix!',
28
+ :created_time => '2009-08-15T14:57:36+0000'
29
+ }]
30
+ }
31
+ }
32
+ album = FbGraph::Album.new(attributes.delete(:id), attributes)
33
+ album.identifier.should == '12345'
34
+ album.from.should == FbGraph::User.new('23456', :name => 'nov matake')
35
+ album.name.should == 'album 1'
36
+ album.description.should == 'an album for fb_graph test'
37
+ album.location.should == 'Tokyo, Japan'
38
+ album.link.should == 'http://www.facebook.com/album/12345'
39
+ album.count.should == 10
40
+ album.type.should == 'normal'
41
+ album.created_time.should == Time.parse('2009-12-29T15:24:50+0000')
42
+ album.updated_time.should == Time.parse('2010-01-02T15:37:41+0000')
43
+ album.comments.should == [FbGraph::Comment.new(
44
+ '909694472945_418735',
45
+ :from => {
46
+ :id => '520739622',
47
+ :name => 'Alison Marie Weber',
48
+ },
49
+ :message => 'Love all the pix!',
50
+ :created_time => '2009-08-15T14:57:36+0000'
51
+ )]
63
52
  end
64
53
 
65
- describe '#picture' do
66
- let(:album) { FbGraph::Album.new('12345') }
67
- subject { album }
68
-
69
- context 'when access token is given' do
70
- before { album.access_token = 'access_token' }
71
- its(:picture) { should == File.join(FbGraph::ROOT_URL, '12345/picture?access_token=access_token') }
72
- it 'should support size' do
73
- album.picture(:small).should == File.join(FbGraph::ROOT_URL, '12345/picture?type=small&access_token=access_token')
74
- end
75
- end
76
-
77
- context 'otherwise' do
78
- it do
79
- expect { album.picture }.should raise_error(FbGraph::Unauthorized)
80
- end
81
- end
54
+ it 'should support page as from' do
55
+ page_album = FbGraph::Album.new('12345', :from => {
56
+ :id => '23456',
57
+ :name => 'Smart.fm',
58
+ :category => 'Web Site'
59
+ })
60
+ page_album.from.should == FbGraph::Page.new('23456', :name => 'Smart.fm', :category => 'Web Site')
82
61
  end
83
62
 
84
63
  end
@@ -33,8 +33,8 @@ end
33
33
 
34
34
  describe FbGraph::AppRequest, '#destroy' do
35
35
  it 'should request DELETE /:request_id' do
36
- lambda do
36
+ mock_graph :delete, '12345', 'true', :access_token => 'access_token' do
37
37
  FbGraph::AppRequest.new('12345', :access_token => 'access_token').destroy
38
- end.should request_to '12345?access_token=access_token', :delete
38
+ end
39
39
  end
40
40
  end
@@ -29,9 +29,8 @@ describe FbGraph::Checkin, '.search' do
29
29
 
30
30
  context 'when access_token is given' do
31
31
  it 'should return checkins as FbGraph::Checkin' do
32
- mock_graph :get, 'search', 'checkins/search_private', :params => {
33
- :type => 'checkin',
34
- :access_token => 'access_token'
32
+ mock_graph :get, 'search', 'checkins/search_private', :access_token => 'access_token', :params => {
33
+ :type => 'checkin'
35
34
  } do
36
35
  checkins = FbGraph::Checkin.search(:access_token => 'access_token')
37
36
  checkins.each do |checkin|
@@ -3,9 +3,7 @@ require 'spec_helper'
3
3
  describe FbGraph::Collection, '.new' do
4
4
 
5
5
  it 'should return an array with pagination info' do
6
- mock_graph :get, 'platform/statuses', 'pages/statuses/platform_private', :params => {
7
- :access_token => 'access_token'
8
- } do
6
+ mock_graph :get, 'platform/statuses', 'pages/statuses/platform_private', :access_token => 'access_token' do
9
7
  collection = FbGraph::Page.new('platform', :access_token => 'access_token').statuses.collection
10
8
  collection.should be_kind_of(Array)
11
9
  collection.previous.should be_kind_of(Hash)
@@ -2,9 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe FbGraph::Connection, '.new' do
4
4
  it 'should return an array with connection info' do
5
- mock_graph :get, 'platform/statuses', 'pages/statuses/platform_private', :params => {
6
- :access_token => 'access_token'
7
- } do
5
+ mock_graph :get, 'platform/statuses', 'pages/statuses/platform_private', :access_token => 'access_token' do
8
6
  page = FbGraph::Page.new('platform', :access_token => 'access_token')
9
7
  statuses = page.statuses
10
8
  statuses.should be_kind_of(Array)
@@ -19,26 +17,22 @@ describe FbGraph::Connection do
19
17
  it 'should be useful for pagenation' do
20
18
  me = FbGraph::User.new('me', :access_token => 'access_token')
21
19
  posts = nil
22
- mock_graph :get, 'me/home', 'users/home/me_private', :params => {
23
- :access_token => 'access_token'
24
- } do
20
+ mock_graph :get, 'me/home', 'users/home/me_private', :access_token => 'access_token' do
25
21
  posts = me.home
26
22
  posts.first.created_time.should == Time.parse('2010-04-27T13:06:14+0000')
27
23
  posts.last.created_time.should == Time.parse('2010-04-27T11:07:48+0000')
28
24
  end
29
- mock_graph :get, 'me/home', 'users/home/me_private_previous', :params => {
30
- :access_token => 'access_token',
25
+ mock_graph :get, 'me/home', 'users/home/me_private_previous', :access_token => 'access_token', :params => {
31
26
  :limit => '25',
32
- :since => '2010-04-27T13:06:14+0000'
27
+ :since => '123456789'
33
28
  } do
34
29
  previous_posts = posts.previous
35
30
  previous_posts.first.created_time.should == Time.parse('2010-04-27T13:23:08+0000')
36
31
  previous_posts.last.created_time.should == Time.parse('2010-04-27T13:10:56+0000')
37
32
  end
38
- mock_graph :get, 'me/home', 'users/home/me_private_next', :params => {
39
- :access_token => 'access_token',
33
+ mock_graph :get, 'me/home', 'users/home/me_private_next', :access_token => 'access_token', :params => {
40
34
  :limit => '25',
41
- :until => '2010-04-27T11:07:48+0000'
35
+ :until => '123456789'
42
36
  } do
43
37
  next_posts = posts.next
44
38
  next_posts.first.created_time.should == Time.parse('2010-04-27T11:06:29+0000')
@@ -14,9 +14,7 @@ describe FbGraph::Connections::Accounts, '#accounts' do
14
14
 
15
15
  context 'when access_token is given' do
16
16
  it 'should return accounts as FbGraph::Page' do
17
- mock_graph :get, 'matake/accounts', 'users/accounts/matake_private', :params => {
18
- :access_token => 'access_token'
19
- } do
17
+ mock_graph :get, 'matake/accounts', 'users/accounts/matake_private', :access_token => 'access_token' do
20
18
  accounts = FbGraph::User.new('matake', :access_token => 'access_token').accounts
21
19
  accounts.class.should == FbGraph::Connection
22
20
  accounts.first.should == FbGraph::Page.new(
@@ -33,9 +31,7 @@ describe FbGraph::Connections::Accounts, '#accounts' do
33
31
 
34
32
  context 'when manage_pages permission given' do
35
33
  it 'should has special access_token behalf of the page' do
36
- mock_graph :get, 'matake/accounts', 'users/accounts/matake_private_with_manage_pages_permission', :params => {
37
- :access_token => 'access_token_for_user'
38
- } do
34
+ mock_graph :get, 'matake/accounts', 'users/accounts/matake_private_with_manage_pages_permission', :access_token => 'access_token_for_user' do
39
35
  accounts = FbGraph::User.new('matake', :access_token => 'access_token_for_user').accounts
40
36
  accounts.first.should == FbGraph::Page.new(
41
37
  '140478125968442',
@@ -15,9 +15,7 @@ describe FbGraph::Connections::Activities, '#activities' do
15
15
 
16
16
  context 'when access_token is given' do
17
17
  it 'should return activities as FbGraph::Page' do
18
- mock_graph :get, 'arjun/activities', 'users/activities/arjun_private', :params => {
19
- :access_token => 'access_token'
20
- } do
18
+ mock_graph :get, 'arjun/activities', 'users/activities/arjun_private', :access_token => 'access_token' do
21
19
  activities = FbGraph::User.new('arjun', :access_token => 'access_token').activities
22
20
  activities.class.should == FbGraph::Connection
23
21
  activities.first.should == FbGraph::Page.new(
@@ -15,9 +15,7 @@ describe FbGraph::Connections::Albums, '#albums' do
15
15
 
16
16
  context 'when access_token is given' do
17
17
  it 'should return albums as FbGraph::Album' do
18
- mock_graph :get, 'matake/albums', 'users/albums/matake_private', :params => {
19
- :access_token => 'access_token'
20
- } do
18
+ mock_graph :get, 'matake/albums', 'users/albums/matake_private', :access_token => 'access_token' do
21
19
  albums = FbGraph::User.new('matake', :access_token => 'access_token').albums
22
20
  albums.first.should == FbGraph::Album.new(
23
21
  '19351532276',
@@ -47,8 +45,7 @@ end
47
45
  describe FbGraph::Connections::Albums, '#album!' do
48
46
  context 'when included by FbGraph::User' do
49
47
  it 'should return generated album' do
50
- mock_graph :post, 'matake/albums', 'users/albums/post_with_valid_access_token', :params => {
51
- :access_token => 'valid',
48
+ mock_graph :post, 'matake/albums', 'users/albums/post_with_valid_access_token', :access_token => 'valid', :params => {
52
49
  :name => 'FbGraph test',
53
50
  :message => 'test test test'
54
51
  } do
@@ -2,9 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe FbGraph::Connections::AppRequests, '#app_requests' do
4
4
  it 'should return app_requests as FbGraph::AppRequest' do
5
- mock_graph :get, 'me/apprequests', 'users/app_requests/me_private', :params => {
6
- :access_token => 'access_token'
7
- } do
5
+ mock_graph :get, 'me/apprequests', 'users/app_requests/me_private', :access_token => 'access_token' do
8
6
  app_requests = FbGraph::User.me('access_token').app_requests
9
7
  app_requests.each do |app_request|
10
8
  app_request.should be_instance_of(FbGraph::AppRequest)
@@ -2,9 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe FbGraph::Connections::Attending, '#attending' do
4
4
  it 'should return attending users as FbGraph::User' do
5
- mock_graph :get, 'smartday/attending', 'events/attending/smartday_private', :params => {
6
- :access_token => 'access_token'
7
- } do
5
+ mock_graph :get, 'smartday/attending', 'events/attending/smartday_private', :access_token => 'access_token' do
8
6
  users = FbGraph::Event.new('smartday', :access_token => 'access_token').attending
9
7
  users.each do |user|
10
8
  user.should be_instance_of(FbGraph::User)
@@ -15,9 +13,7 @@ end
15
13
 
16
14
  describe FbGraph::Connections::Attending, '#attending!' do
17
15
  it 'should return true' do
18
- mock_graph :post, '12345/attending', 'events/attending/post_with_valid_access_token', :params => {
19
- :access_token => 'valid'
20
- } do
16
+ mock_graph :post, '12345/attending', 'events/attending/post_with_valid_access_token', :access_token => 'valid' do
21
17
  FbGraph::Event.new('12345', :access_token => 'valid').attending!.should be_true
22
18
  end
23
19
  end
@@ -14,9 +14,7 @@ describe FbGraph::Connections::Books, '#books' do
14
14
 
15
15
  context 'when access_token is given' do
16
16
  it 'should return books as FbGraph::Page' do
17
- mock_graph :get, 'matake/books', 'users/books/matake_private', :params => {
18
- :access_token => 'access_token'
19
- } do
17
+ mock_graph :get, 'matake/books', 'users/books/matake_private', :access_token => 'access_token' do
20
18
  books = FbGraph::User.new('matake', :access_token => 'access_token').books
21
19
  books.first.should == FbGraph::Page.new(
22
20
  '102253616477130',
@@ -14,9 +14,7 @@ describe FbGraph::Connections::Checkins, '#checkins' do
14
14
 
15
15
  context 'when access_token is given' do
16
16
  it 'should return checkins as FbGraph::Checkin' do
17
- mock_graph :get, 'mattt/checkins', 'users/checkins/mattt_private', :params => {
18
- :access_token => 'access_token'
19
- } do
17
+ mock_graph :get, 'mattt/checkins', 'users/checkins/mattt_private', :access_token => 'access_token' do
20
18
  checkins = FbGraph::User.new('mattt', :access_token => 'access_token').checkins
21
19
  checkins.first.should == FbGraph::Checkin.new(
22
20
  '696876187499',
@@ -67,9 +65,7 @@ describe FbGraph::Connections::Checkins, '#checkins' do
67
65
 
68
66
  context 'when access_token is given' do
69
67
  it 'should return checkins as FbGraph::Checkin' do
70
- mock_graph :get, 'gowalla/checkins', 'pages/checkins/gowalla_private', :params => {
71
- :access_token => 'access_token'
72
- } do
68
+ mock_graph :get, 'gowalla/checkins', 'pages/checkins/gowalla_private', :access_token => 'access_token' do
73
69
  checkins = FbGraph::Page.new('gowalla', :access_token => 'access_token').checkins
74
70
  checkins.first.should == FbGraph::Checkin.new(
75
71
  '696876187499',
@@ -96,7 +96,7 @@ end
96
96
 
97
97
  describe FbGraph::Connections::Comments, '#unlike!' do
98
98
  it 'should DELETE /:object_id/likes' do
99
- mock_graph :delete, '12345/likes', 'true', :params => {:access_token => 'valid'} do
99
+ mock_graph :delete, '12345/likes', 'true', :access_token => 'valid' do
100
100
  FbGraph::Post.new('12345', :access_token => 'valid').unlike!
101
101
  end
102
102
  end
@@ -6,9 +6,7 @@ describe FbGraph::Connections::Declined, '#declined' do
6
6
  end
7
7
 
8
8
  it 'should return declined users as FbGraph::User' do
9
- mock_graph :get, 'smartday/declined', 'events/declined/smartday_private', :params => {
10
- :access_token => 'access_token'
11
- } do
9
+ mock_graph :get, 'smartday/declined', 'events/declined/smartday_private', :access_token => 'access_token' do
12
10
  users = FbGraph::Event.new('smartday', :access_token => 'access_token').declined
13
11
  users.each do |user|
14
12
  user.should be_instance_of(FbGraph::User)
@@ -19,9 +17,7 @@ end
19
17
 
20
18
  describe FbGraph::Connections::Declined, '#declined!' do
21
19
  it 'should return true' do
22
- mock_graph :post, '12345/declined', 'events/declined/post_with_valid_access_token', :params => {
23
- :access_token => 'valid'
24
- } do
20
+ mock_graph :post, '12345/declined', 'events/declined/post_with_valid_access_token', :access_token => 'valid' do
25
21
  FbGraph::Event.new('12345', :access_token => 'valid').declined!.should be_true
26
22
  end
27
23
  end
@@ -14,9 +14,7 @@ describe FbGraph::Connections::Events, '#events' do
14
14
 
15
15
  context 'when access_token is given' do
16
16
  it 'should return events as FbGraph::Event' do
17
- mock_graph :get, 'matake/events', 'users/events/matake_private', :params => {
18
- :access_token => 'access_token'
19
- } do
17
+ mock_graph :get, 'matake/events', 'users/events/matake_private', :access_token => 'access_token' do
20
18
  events = FbGraph::User.new('matake', :access_token => 'access_token').events
21
19
  events.first.should == FbGraph::Event.new(
22
20
  '116600818359630',
@@ -14,9 +14,7 @@ describe FbGraph::Connections::Family, '#family' do
14
14
 
15
15
  context 'when access_token is given' do
16
16
  it 'should return family members as FbGraph::User' do
17
- mock_graph :get, 'me/family', 'users/family/me_public', :params => {
18
- :access_token => 'access_token'
19
- } do
17
+ mock_graph :get, 'me/family', 'users/family/me_public', :access_token => 'access_token' do
20
18
  users = FbGraph::User.new('me', :access_token => 'access_token').family
21
19
  users.first.should == FbGraph::User.new(
22
20
  '720112389',
@@ -33,9 +33,7 @@ describe FbGraph::Connections::Feed, '#feed' do
33
33
 
34
34
  context 'when access_token is given' do
35
35
  it 'should return posts on the user\'s wall as FbGraph::Post' do
36
- mock_graph :get, 'arjun/feed', 'users/feed/arjun_private', :params => {
37
- :access_token => 'access_token'
38
- } do
36
+ mock_graph :get, 'arjun/feed', 'users/feed/arjun_private', :access_token => 'access_token' do
39
37
  posts = FbGraph::User.new('arjun').feed(:access_token => 'access_token')
40
38
  posts.first.should == FbGraph::Post.new(
41
39
  '7901103_121392141207495',