Sha256: 3f31cdbb389a4d79e7613df6037491ed8f35742790d13225c7c7bbe2773700bc

Contents?: true

Size: 1.34 KB

Versions: 20

Compression:

Stored size: 1.34 KB

Contents

require 'spec_helper'

describe FbGraph::Connections::Messages, '#messages' do
  it 'should return threads as FbGraph::Message' do
    mock_graph :get, '12345/messages', 'thread/messages/private', :params => {:no_cache => 'true'}, :access_token => 'access_token' do
      messages = FbGraph::Thread.new(12345, :access_token => 'access_token').messages(:no_cache => true)
      messages.each do |message|
        message.should be_instance_of(FbGraph::Message)
      end
    end
  end

  describe 'cached messages' do
    context 'when cached' do
      let(:thread) { FbGraph::Thread.new(12345, :access_token => 'access_token', :messages => {}) }

      it 'should use cache' do
        lambda do
          thread.messages
        end.should_not request_to '12345/messages?access_token=access_token'
      end

      context 'when options are specified' do
        it 'should not use cache' do
          lambda do
            thread.messages(:no_cache => true)
          end.should request_to '12345/messages?access_token=access_token&no_cache=true'
        end
      end
    end

    context 'otherwise' do
      let(:thread) { FbGraph::Thread.new(12345, :access_token => 'access_token') }

      it 'should not use cache' do
        lambda do
          thread.messages
        end.should request_to '12345/messages?access_token=access_token'
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
fb_graph-2.4.13 spec/fb_graph/connections/messages_spec.rb
fb_graph-2.4.12 spec/fb_graph/connections/messages_spec.rb
fb_graph-2.4.11 spec/fb_graph/connections/messages_spec.rb
fb_graph-2.4.10 spec/fb_graph/connections/messages_spec.rb
fb_graph-2.4.9 spec/fb_graph/connections/messages_spec.rb
fb_graph-2.4.8 spec/fb_graph/connections/messages_spec.rb
fb_graph-2.4.7 spec/fb_graph/connections/messages_spec.rb
fb_graph-2.4.6 spec/fb_graph/connections/messages_spec.rb
fb_graph-2.4.4 spec/fb_graph/connections/messages_spec.rb
fb_graph-2.4.3 spec/fb_graph/connections/messages_spec.rb
fb_graph-2.4.2 spec/fb_graph/connections/messages_spec.rb
fb_graph-2.4.1 spec/fb_graph/connections/messages_spec.rb
fb_graph-2.4.0 spec/fb_graph/connections/messages_spec.rb
fb_graph-2.3.2 spec/fb_graph/connections/messages_spec.rb
fb_graph-2.3.1 spec/fb_graph/connections/messages_spec.rb
fb_graph-2.3.0 spec/fb_graph/connections/messages_spec.rb
fb_graph-2.2.6 spec/fb_graph/connections/messages_spec.rb
fb_graph-2.2.5 spec/fb_graph/connections/messages_spec.rb
fb_graph-2.2.4 spec/fb_graph/connections/messages_spec.rb
fb_graph-2.2.3 spec/fb_graph/connections/messages_spec.rb