fb_graph 2.2.2 → 2.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. data/Gemfile.lock +11 -15
  2. data/VERSION +1 -1
  3. data/lib/fb_graph/album.rb +1 -1
  4. data/lib/fb_graph/connections/comments.rb +1 -5
  5. data/lib/fb_graph/connections/former_participants.rb +1 -5
  6. data/lib/fb_graph/connections/likes.rb +1 -5
  7. data/lib/fb_graph/connections/messages.rb +1 -5
  8. data/lib/fb_graph/connections/participants.rb +1 -5
  9. data/lib/fb_graph/connections/question_options.rb +2 -6
  10. data/lib/fb_graph/connections/senders.rb +1 -5
  11. data/lib/fb_graph/connections/tags.rb +7 -8
  12. data/lib/fb_graph/link.rb +1 -1
  13. data/lib/fb_graph/message.rb +1 -1
  14. data/lib/fb_graph/node.rb +32 -7
  15. data/lib/fb_graph/note.rb +1 -1
  16. data/lib/fb_graph/open_graph/action.rb +1 -2
  17. data/lib/fb_graph/page.rb +2 -2
  18. data/lib/fb_graph/photo.rb +1 -2
  19. data/lib/fb_graph/post.rb +1 -2
  20. data/lib/fb_graph/question.rb +2 -4
  21. data/lib/fb_graph/searchable.rb +2 -1
  22. data/lib/fb_graph/status.rb +1 -2
  23. data/lib/fb_graph/thread.rb +5 -11
  24. data/lib/fb_graph/user_achievement.rb +1 -2
  25. data/lib/fb_graph/video.rb +1 -1
  26. data/spec/fb_graph/connections/comments_spec.rb +25 -13
  27. data/spec/fb_graph/connections/former_participants_spec.rb +30 -12
  28. data/spec/fb_graph/connections/likes_spec.rb +32 -0
  29. data/spec/fb_graph/connections/messages_spec.rb +30 -12
  30. data/spec/fb_graph/connections/participants_spec.rb +30 -12
  31. data/spec/fb_graph/connections/question_options_spec.rb +3 -3
  32. data/spec/fb_graph/connections/questions_spec.rb +13 -0
  33. data/spec/fb_graph/connections/senders_spec.rb +30 -12
  34. data/spec/fb_graph/page_spec.rb +9 -6
  35. data/spec/fb_graph/question_spec.rb +26 -25
  36. data/spec/fb_graph/searchable_spec.rb +17 -5
  37. data/spec/fb_graph/thread_spec.rb +0 -30
  38. data/spec/mock_json/pages/platform_public.json +2 -1
  39. data/spec/mock_json/users/questions/sample.json +465 -0
  40. data/spec/spec_helper.rb +0 -3
  41. metadata +21 -19
data/Gemfile.lock CHANGED
@@ -1,35 +1,34 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fb_graph (2.2.1)
4
+ fb_graph (2.2.2)
5
5
  httpclient (>= 2.2.0.2)
6
6
  rack-oauth2 (>= 0.9.4)
7
7
 
8
8
  GEM
9
9
  remote: http://rubygems.org/
10
10
  specs:
11
- actionpack (3.1.1)
12
- activemodel (= 3.1.1)
13
- activesupport (= 3.1.1)
11
+ actionpack (3.1.3)
12
+ activemodel (= 3.1.3)
13
+ activesupport (= 3.1.3)
14
14
  builder (~> 3.0.0)
15
15
  erubis (~> 2.7.0)
16
16
  i18n (~> 0.6)
17
- rack (~> 1.3.2)
17
+ rack (~> 1.3.5)
18
18
  rack-cache (~> 1.1)
19
19
  rack-mount (~> 0.8.2)
20
20
  rack-test (~> 0.6.1)
21
- sprockets (~> 2.0.2)
22
- activemodel (3.1.1)
23
- activesupport (= 3.1.1)
21
+ sprockets (~> 2.0.3)
22
+ activemodel (3.1.3)
23
+ activesupport (= 3.1.3)
24
24
  builder (~> 3.0.0)
25
25
  i18n (~> 0.6)
26
- activesupport (3.1.1)
26
+ activesupport (3.1.3)
27
27
  multi_json (~> 1.0)
28
28
  addressable (2.2.6)
29
29
  attr_required (0.0.3)
30
- bouncy-castle-java (1.5.0146.1)
31
30
  builder (3.0.0)
32
- configatron (2.8.3)
31
+ configatron (2.8.4)
33
32
  yamler (>= 0.1.0)
34
33
  cover_me (1.2.0)
35
34
  configatron
@@ -41,8 +40,6 @@ GEM
41
40
  hike (1.2.1)
42
41
  httpclient (2.2.3)
43
42
  i18n (0.6.0)
44
- jruby-openssl (0.7.4)
45
- bouncy-castle-java
46
43
  json (1.6.1)
47
44
  multi_json (1.0.3)
48
45
  rack (1.3.5)
@@ -73,13 +70,12 @@ GEM
73
70
  rack (~> 1.0)
74
71
  tilt (~> 1.1, != 1.3.0)
75
72
  tilt (1.3.3)
76
- webmock (1.7.7)
73
+ webmock (1.7.8)
77
74
  addressable (~> 2.2, > 2.2.5)
78
75
  crack (>= 0.1.7)
79
76
  yamler (0.1.0)
80
77
 
81
78
  PLATFORMS
82
- java
83
79
  ruby
84
80
 
85
81
  DEPENDENCIES
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.2.2
1
+ 2.2.3
@@ -39,7 +39,7 @@ module FbGraph
39
39
  end
40
40
 
41
41
  # cached connection
42
- @_comments_ = Collection.new(attributes[:comments])
42
+ cache_collection attributes, :comments
43
43
  end
44
44
 
45
45
  def picture_with_access_token(size = nil)
@@ -2,11 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Comments
4
4
  def comments(options = {})
5
- comments = if @_comments_ && options.blank?
6
- self.connection(:comments, options.merge(:cached_collection => @_comments_))
7
- else
8
- self.connection(:comments, options)
9
- end
5
+ comments = self.connection(:comments, options)
10
6
  comments.map! do |comment|
11
7
  Comment.new(comment[:id], comment.merge(
12
8
  :access_token => options[:access_token] || self.access_token
@@ -2,11 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module FormerParticipants
4
4
  def former_participants(options = {})
5
- users = if @_former_participants_ && options.blank?
6
- self.connection(:former_participants, options.merge(:cached_collection => @_former_participants_))
7
- else
8
- self.connection(:former_participants, options)
9
- end
5
+ users = self.connection(:former_participants, options)
10
6
  users.map! do |user|
11
7
  User.new(user[:id], user.merge(
12
8
  :access_token => options[:access_token] || self.access_token
@@ -2,11 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Likes
4
4
  def likes(options = {})
5
- likes = if @_likes_ && options.blank?
6
- self.connection(:likes, options.merge(:cached_collection => @_likes_))
7
- else
8
- self.connection(:likes, options)
9
- end
5
+ likes = self.connection(:likes, options)
10
6
  likes.map! do |like|
11
7
  like.merge!(
12
8
  :access_token => options[:access_token] || self.access_token
@@ -2,11 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Messages
4
4
  def messages(options = {})
5
- messages = if @_messages_ && options.blank?
6
- self.connection(:messages, options.merge(:cached_collection => @_messages_))
7
- else
8
- self.connection(:messages, options)
9
- end
5
+ messages = self.connection(:messages, options)
10
6
  messages.map! do |message|
11
7
  Message.new(message[:id], message.merge(
12
8
  :access_token => options[:access_token] || self.access_token
@@ -2,11 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Participants
4
4
  def participants(options = {})
5
- users = if @_participants_ && options.blank?
6
- self.connection(:participants, options.merge(:cached_collection => @_participants_))
7
- else
8
- self.connection(:participants, options)
9
- end
5
+ users = self.connection(:participants, options)
10
6
  users.map! do |user|
11
7
  User.new(user[:id], user.merge(
12
8
  :access_token => options[:access_token] || self.access_token
@@ -1,12 +1,8 @@
1
1
  module FbGraph
2
2
  module Connections
3
3
  module QuestionOptions
4
- def options(opts = {})
5
- question_options = if @_options_ && opts.blank?
6
- self.connection(:question_options, opts.merge(:cached_collection => @_options_))
7
- else
8
- self.connection(:question_options, opts)
9
- end
4
+ def question_options(opts = {})
5
+ question_options = self.connection(:question_options, opts)
10
6
  question_options.map! do |option|
11
7
  QuestionOption.new(option[:id], option.merge(
12
8
  :access_token => opts[:access_token] || self.access_token
@@ -2,11 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Senders
4
4
  def senders(options = {})
5
- users = if @_senders_ && options.blank?
6
- self.connection(:senders, options.merge(:cached_collection => @_senders_))
7
- else
8
- self.connection(:senders, options)
9
- end
5
+ users = self.connection(:senders, options)
10
6
  users.map! do |user|
11
7
  User.new(user[:id], user.merge(
12
8
  :access_token => options[:access_token] || self.access_token
@@ -2,15 +2,14 @@ module FbGraph
2
2
  module Connections
3
3
  module Tags
4
4
  def tags(options = {})
5
- tags = if @_tags_ && options.blank?
6
- return @_tags_ if @_tags_.first.is_a?(Tag)
7
- self.connection(:tags, options.merge(:cached_collection => @_tags_))
5
+ tags = self.connection(:tags, options)
6
+ if tags.first.is_a?(Tag)
7
+ tags
8
8
  else
9
- self.connection(:tags, options)
10
- end
11
- tags.map! do |tag|
12
- tag[:access_token] ||= options[:access_token] || self.access_token
13
- Tag.new(tag)
9
+ tags.map! do |tag|
10
+ tag[:access_token] ||= options[:access_token] || self.access_token
11
+ Tag.new(tag)
12
+ end
14
13
  end
15
14
  end
16
15
 
data/lib/fb_graph/link.rb CHANGED
@@ -26,7 +26,7 @@ module FbGraph
26
26
  end
27
27
 
28
28
  # cached connection
29
- @_comments_ = Collection.new(attributes[:comments])
29
+ cache_collection attributes, :comments
30
30
  end
31
31
  end
32
32
  end
@@ -24,7 +24,7 @@ module FbGraph
24
24
  end
25
25
 
26
26
  # cached connection
27
- @_tags_ = Collection.new(attributes[:tags])
27
+ cache_collection attributes, :tags
28
28
  end
29
29
  end
30
30
  end
data/lib/fb_graph/node.rb CHANGED
@@ -7,9 +7,10 @@ module FbGraph
7
7
  attr_accessor :identifier, :endpoint, :access_token
8
8
 
9
9
  def initialize(identifier, options = {})
10
- @identifier = identifier
11
- @endpoint = File.join(ROOT_URL, identifier.to_s)
12
- @access_token = options[:access_token]
10
+ @identifier = identifier
11
+ @endpoint = File.join(ROOT_URL, identifier.to_s)
12
+ @access_token = options[:access_token]
13
+ @cached_collections = {}
13
14
  end
14
15
 
15
16
  def fetch(options = {})
@@ -24,16 +25,21 @@ module FbGraph
24
25
  end
25
26
 
26
27
  def connection(connection, options = {})
27
- collection = options[:cached_collection] || Collection.new(get(options.merge(:connection => connection)))
28
- Connection.new(self, connection, options.merge(:collection => collection))
28
+ Connection.new(
29
+ self,
30
+ connection,
31
+ options.merge(
32
+ :collection => collection_for(connection, options)
33
+ )
34
+ )
29
35
  end
30
36
 
31
37
  def update(options = {})
32
- post(options)
38
+ post options
33
39
  end
34
40
 
35
41
  def destroy(options = {})
36
- delete(options)
42
+ delete options
37
43
  end
38
44
 
39
45
  protected
@@ -68,6 +74,25 @@ module FbGraph
68
74
 
69
75
  private
70
76
 
77
+ def collection_for(connection, options = {})
78
+ collection = if @cached_collections.has_key?(connection) && options.blank?
79
+ @cached_collections[connection]
80
+ else
81
+ get options.merge(:connection => connection)
82
+ end
83
+ Collection.new collection
84
+ end
85
+
86
+ def cache_collections(attributes, *connections)
87
+ if (attributes.keys - [:access_token]).present?
88
+ connections.each do |connection|
89
+ attribute_key, connection = connection.to_a.flatten if connection.is_a?(Hash)
90
+ @cached_collections[connection] = attributes[attribute_key || connection]
91
+ end
92
+ end
93
+ end
94
+ alias_method :cache_collection, :cache_collections
95
+
71
96
  def build_endpoint(params = {})
72
97
  File.join([self.endpoint, params.delete(:connection), params.delete(:connection_scope)].compact.collect(&:to_s))
73
98
  end
data/lib/fb_graph/note.rb CHANGED
@@ -26,7 +26,7 @@ module FbGraph
26
26
  @icon = attributes[:icon]
27
27
 
28
28
  # cached connection
29
- @_comments_ = Collection.new(attributes[:comments])
29
+ cache_collection attributes, :comments
30
30
  end
31
31
  end
32
32
  end
@@ -30,8 +30,7 @@ module FbGraph
30
30
  end
31
31
 
32
32
  # cached connection
33
- @_likes_ = Collection.new(attributes[:likes])
34
- @_comments_ = Collection.new(attributes[:comments])
33
+ cache_collections attributes, :comments, :likes
35
34
  end
36
35
  end
37
36
  end
data/lib/fb_graph/page.rb CHANGED
@@ -22,11 +22,11 @@ module FbGraph
22
22
  include Connections::Videos
23
23
  extend Searchable
24
24
 
25
- attr_accessor :name, :username, :category, :like_count
25
+ attr_accessor :name, :username, :category, :like_count, :talking_about_count
26
26
 
27
27
  def initialize(identifier, attributes = {})
28
28
  super
29
- [:name, :username, :category].each do |key|
29
+ [:name, :username, :category, :talking_about_count].each do |key|
30
30
  self.send :"#{key}=", attributes[key]
31
31
  end
32
32
  @like_count = attributes[:likes] || attributes[:fan_count]
@@ -42,8 +42,7 @@ module FbGraph
42
42
  end
43
43
 
44
44
  # cached connection
45
- @_tags_ = Collection.new(attributes[:tags])
46
- @_comments_ = Collection.new(attributes[:comments])
45
+ cache_collections attributes, :comments, :tags
47
46
  end
48
47
  end
49
48
  end
data/lib/fb_graph/post.rb CHANGED
@@ -105,8 +105,7 @@ module FbGraph
105
105
  end
106
106
 
107
107
  # cached connection
108
- @_likes_ = Collection.new(attributes[:likes])
109
- @_comments_ = Collection.new(attributes[:comments])
108
+ cache_collections attributes, :comments, :likes
110
109
  end
111
110
  end
112
111
  end
@@ -17,10 +17,8 @@ module FbGraph
17
17
  Time.parse(attributes[:updated_time]).utc
18
18
  end
19
19
 
20
- @_options_ = if attributes[:options]
21
- # cached options
22
- Collection.new(attributes[:options])
23
- end
20
+ # cached connection
21
+ cache_collection attributes, :options => :question_options
24
22
  end
25
23
  end
26
24
  end
@@ -23,9 +23,10 @@ module FbGraph
23
23
 
24
24
  # The majority of Graph API searches use 'q' but some, like AdKeywordSuggestion
25
25
  # use an alternate search query param
26
- def search_query_param
26
+ def self.search_query_param
27
27
  :q
28
28
  end
29
+ delegate :search_query_param, :to => Searchable
29
30
  end
30
31
  end
31
32
 
@@ -21,8 +21,7 @@ module FbGraph
21
21
  end
22
22
 
23
23
  # cached connection
24
- @_comments_ = Collection.new(attributes[:comments])
25
- @_likes_ = Collection.new(attributes[:likes])
24
+ cache_collections attributes, :comments, :likes
26
25
  end
27
26
  end
28
27
  end
@@ -18,11 +18,7 @@ module FbGraph
18
18
  end
19
19
 
20
20
  # cached connection
21
- @_messages_ = Collection.new(attributes[:messages])
22
- @_participants_ = Collection.new(attributes[:participants])
23
- @_former_participants_ = Collection.new(attributes[:former_articipants])
24
- @_senders_ = Collection.new(attributes[:senders])
25
- @_tags_ = Collection.new(attributes[:tags])
21
+ cache_collections attributes, :messages, :participants, :former_participants, :senders, :tags
26
22
  end
27
23
 
28
24
  # NOTE:
@@ -52,18 +48,16 @@ module FbGraph
52
48
  end
53
49
  @unread = attributes[:unread] == 1
54
50
  @unseen = attributes[:unseen] == 1
55
- @_messages_ = Collection.new(attributes[:comments])
51
+
52
+ # cached connection
53
+ cache_collection attributes, :comments
56
54
  end
57
55
 
58
56
  # NOTE:
59
57
  # This is a connection named "comments" but returns "messages" and different from normal "comments" connection.
60
58
  # Therefore I put this connection here not under FbGraph::Connections.
61
59
  def messages(options = {})
62
- messages = if @_messages_ && options.blank?
63
- self.connection(:comments, options.merge(:cached_collection => @_messages_))
64
- else
65
- self.connection(:comments, options)
66
- end
60
+ messages = self.connection(:comments, options)
67
61
  messages.map! do |message|
68
62
  Message.new(message[:id], message.merge(
69
63
  :access_token => options[:access_token] || self.access_token
@@ -24,8 +24,7 @@ module FbGraph
24
24
  end
25
25
 
26
26
  # cached connection
27
- @_likes_ = Collection.new(attributes[:likes])
28
- @_comments_ = Collection.new(attributes[:comments])
27
+ cache_collections attributes, :comments, :likes
29
28
  end
30
29
 
31
30
  def destroy(options = {})
@@ -35,7 +35,7 @@ module FbGraph
35
35
  end
36
36
 
37
37
  # cached connection
38
- @_comments_ = Collection.new(attributes[:comments])
38
+ cache_collections attributes, :comments
39
39
  end
40
40
  end
41
41
  end
@@ -8,16 +8,32 @@ describe FbGraph::Connections::Comments, '#comments' do
8
8
  end
9
9
  end
10
10
 
11
- it 'should use cached @_comments_ as default' do
12
- lambda do
13
- post.comments
14
- end.should_not request_to "#{post.identifier}/comments"
15
- end
11
+ describe 'cached comments' do
12
+ context 'when cached' do
13
+ it 'should use cache' do
14
+ lambda do
15
+ post.comments
16
+ end.should_not request_to "#{post.identifier}/comments"
17
+ end
18
+
19
+ context 'when options are specified' do
20
+ it 'should not use cache' do
21
+ lambda do
22
+ post.comments(:no_cache => true)
23
+ end.should request_to "#{post.identifier}/comments?no_cache=true"
24
+ end
25
+ end
26
+ end
16
27
 
17
- it 'should ignore cached @_comments_ when options are given' do
18
- lambda do
19
- post.comments(:no_cache => true)
20
- end.should request_to "#{post.identifier}/comments"
28
+ context 'otherwise' do
29
+ let(:post) { FbGraph::Post.new(12345, :access_token => 'access_token') }
30
+
31
+ it 'should not use cache' do
32
+ lambda do
33
+ post.comments
34
+ end.should request_to '12345/comments?access_token=access_token'
35
+ end
36
+ end
21
37
  end
22
38
  end
23
39
  end
@@ -45,10 +61,6 @@ describe FbGraph::Connections::Comments, '#comment!' do
45
61
  end
46
62
 
47
63
  context 'when valid access_token is given' do
48
- before do
49
-
50
- end
51
-
52
64
  it 'should return generated comment' do
53
65
  mock_graph :post, '12345/comments', 'posts/comments/post_with_valid_access_token' do
54
66
  comment = FbGraph::Post.new('12345', :access_token => 'valid').comment!(:message => 'hello')
@@ -1,18 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe FbGraph::Connections::FormerParticipants, '#former_participants' do
4
- it 'should use cached contents as default' do
5
- lambda do
6
- FbGraph::Thread.new(12345, :access_token => 'access_token').former_participants
7
- end.should_not request_to '12345/former_participants?access_token=access_token'
8
- end
9
-
10
- it 'should not use cached contents when options are specified' do
11
- lambda do
12
- FbGraph::Thread.new(12345).former_participants(:no_cache => true)
13
- end.should request_to '12345/former_participants?no_cache=true'
14
- end
15
-
16
4
  it 'should return former_participants as FbGraph::User' do
17
5
  mock_graph :get, '12345/former_participants', 'thread/former_participants/private', :access_token => 'access_token', :params => {
18
6
  :no_cache => 'true'
@@ -23,4 +11,34 @@ describe FbGraph::Connections::FormerParticipants, '#former_participants' do
23
11
  end
24
12
  end
25
13
  end
14
+
15
+ describe 'cached messages' do
16
+ context 'when cached' do
17
+ let(:thread) { FbGraph::Thread.new(12345, :access_token => 'access_token', :former_participants => {}) }
18
+
19
+ it 'should use cache' do
20
+ lambda do
21
+ thread.former_participants
22
+ end.should_not request_to '12345/former_participants?access_token=access_token'
23
+ end
24
+
25
+ context 'when options are specified' do
26
+ it 'should not use cache' do
27
+ lambda do
28
+ thread.former_participants(:no_cache => true)
29
+ end.should request_to '12345/former_participants?access_token=access_token&no_cache=true'
30
+ end
31
+ end
32
+ end
33
+
34
+ context 'otherwise' do
35
+ let(:thread) { FbGraph::Thread.new(12345, :access_token => 'access_token') }
36
+
37
+ it 'should not use cache' do
38
+ lambda do
39
+ thread.former_participants
40
+ end.should request_to '12345/former_participants?access_token=access_token'
41
+ end
42
+ end
43
+ end
26
44
  end
@@ -12,6 +12,38 @@ describe FbGraph::Connections::Likes do
12
12
  end
13
13
  end
14
14
 
15
+ context 'when included by FbGraph::Post' do
16
+ let(:post) { FbGraph::Post.new('post_id', :access_token => 'access_token', :likes => {}) }
17
+
18
+ describe 'cached likes' do
19
+ context 'when cached' do
20
+ it 'should use cache' do
21
+ lambda do
22
+ post.likes
23
+ end.should_not request_to 'post_id/likes?access_token=access_token'
24
+ end
25
+
26
+ context 'when options are specified' do
27
+ it 'should not use cache' do
28
+ lambda do
29
+ post.likes(:no_cache => true)
30
+ end.should request_to 'post_id/likes?access_token=access_token&no_cache=true'
31
+ end
32
+ end
33
+ end
34
+
35
+ context 'otherwise' do
36
+ let(:post) { FbGraph::Post.new(12345, :access_token => 'access_token') }
37
+
38
+ it 'should not use cache' do
39
+ lambda do
40
+ post.likes
41
+ end.should request_to '12345/likes?access_token=access_token'
42
+ end
43
+ end
44
+ end
45
+ end
46
+
15
47
  context 'when included by FbGraph::Status' do
16
48
  context 'when cached collection exists' do
17
49
  before do
@@ -1,18 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe FbGraph::Connections::Messages, '#messages' do
4
- it 'should use cached contents as default' do
5
- lambda do
6
- FbGraph::Thread.new(12345, :access_token => 'access_token').messages
7
- end.should_not request_to '12345/messages?access_token=access_token'
8
- end
9
-
10
- it 'should not use cached contents when options are specified' do
11
- lambda do
12
- FbGraph::Thread.new(12345).messages(:no_cache => true)
13
- end.should request_to '12345/messages?no_cache=true'
14
- end
15
-
16
4
  it 'should return threads as FbGraph::Message' do
17
5
  mock_graph :get, '12345/messages', 'thread/messages/private', :params => {:no_cache => 'true'}, :access_token => 'access_token' do
18
6
  messages = FbGraph::Thread.new(12345, :access_token => 'access_token').messages(:no_cache => true)
@@ -21,4 +9,34 @@ describe FbGraph::Connections::Messages, '#messages' do
21
9
  end
22
10
  end
23
11
  end
12
+
13
+ describe 'cached messages' do
14
+ context 'when cached' do
15
+ let(:thread) { FbGraph::Thread.new(12345, :access_token => 'access_token', :messages => {}) }
16
+
17
+ it 'should use cache' do
18
+ lambda do
19
+ thread.messages
20
+ end.should_not request_to '12345/messages?access_token=access_token'
21
+ end
22
+
23
+ context 'when options are specified' do
24
+ it 'should not use cache' do
25
+ lambda do
26
+ thread.messages(:no_cache => true)
27
+ end.should request_to '12345/messages?access_token=access_token&no_cache=true'
28
+ end
29
+ end
30
+ end
31
+
32
+ context 'otherwise' do
33
+ let(:thread) { FbGraph::Thread.new(12345, :access_token => 'access_token') }
34
+
35
+ it 'should not use cache' do
36
+ lambda do
37
+ thread.messages
38
+ end.should request_to '12345/messages?access_token=access_token'
39
+ end
40
+ end
41
+ end
24
42
  end