Sha256: 754a2217e5b9490c4f11cb8b3e5013103933670cfcf81ec98046e92a4a969190

Contents?: true

Size: 1.26 KB

Versions: 36

Compression:

Stored size: 1.26 KB

Contents

require 'spec_helper'

describe FbGraph::Query do
  let(:raw_query) { 'SELECT uid FROM user WHERE uid = me()' }

  describe '.new' do
    let(:query) { FbGraph::Query.new(raw_query, 'access_token') }

    it 'should setup query and access_token' do
      query.query.should == raw_query
      query.access_token.should == 'access_token'
    end
  end

  describe '.fetch' do
    let(:query) { FbGraph::Query.new(raw_query) }

    context 'when no access token given' do
      it 'should return blank Hash' do
        mock_fql raw_query, 'query/user/without_token' do
          response = query.fetch
          response.should == {}
        end
      end
    end

    context 'when invalid access token given' do
      it 'should raise exception' do
        mock_fql raw_query, 'query/user/with_invalid_token', :access_token => 'invalid' do
          lambda do
            query.fetch('invalid')
          end.should raise_error(FbGraph::Exception)
        end
      end
    end

    context 'when valid access token given' do
      it 'should return an Array of Hash' do
        mock_fql raw_query, 'query/user/with_valid_token', :access_token => 'valid' do
          response = query.fetch('valid')
          response.should == [{'uid' => 579612276}]
        end
      end
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
fb_graph-2.2.0.alpha spec/fb_graph/query/core_spec.rb
fb_graph-2.1.13 spec/fb_graph/query/core_spec.rb
fb_graph-2.1.12 spec/fb_graph/query/core_spec.rb
fb_graph-2.1.11 spec/fb_graph/query/core_spec.rb
fb_graph-2.1.10 spec/fb_graph/query/core_spec.rb
fb_graph-2.1.9 spec/fb_graph/query/core_spec.rb
fb_graph-2.1.8 spec/fb_graph/query/core_spec.rb
fb_graph-2.1.7 spec/fb_graph/query/core_spec.rb
fb_graph-2.1.6 spec/fb_graph/query/core_spec.rb
fb_graph-2.1.5 spec/fb_graph/query/core_spec.rb
fb_graph-2.1.4 spec/fb_graph/query/core_spec.rb
fb_graph-2.1.3 spec/fb_graph/query/core_spec.rb
fb_graph-2.1.2 spec/fb_graph/query/core_spec.rb
fb_graph-2.1.1 spec/fb_graph/query/core_spec.rb
fb_graph-2.1.0 spec/fb_graph/query/core_spec.rb
fb_graph-2.1.0.alpha spec/fb_graph/query/core_spec.rb
fb_graph-2.0.2 spec/fb_graph/query/core_spec.rb
fb_graph-2.0.1 spec/fb_graph/query/core_spec.rb
fb_graph-2.0.0 spec/fb_graph/query/core_spec.rb
fb_graph-2.0.0.beta spec/fb_graph/query/core_spec.rb