Sha256: 422a399af39e0e104d513aac4fc023fa82e008271c68586e40eb41855015b03e
Contents?: true
Size: 1.58 KB
Versions: 1
Compression:
Stored size: 1.58 KB
Contents
require 'spec_helper' describe FbGraph::Query, '.new' do before do @raw_query = 'SELECT uid FROM user WHERE uid = me()' @query = FbGraph::Query.new(@raw_query, 'access_token') end it 'should setup query and access_token' do @query.query.should == @raw_query @query.access_token.should == 'access_token' end it 'should setup proper endpoint' do endpoint = @query.send :build_endpoint params = { :query => @raw_query, :format => :json, :access_token => 'access_token' } endpoint.should == "#{FbGraph::Query::ENDPOINT}?#{params.to_query}" end end describe FbGraph::Query, '.fetch' do before do @raw_query = 'SELECT uid FROM user WHERE uid = me()' @query = FbGraph::Query.new(@raw_query) end context 'when no access token given' do before do fake_fql_json @raw_query, 'query/user/without_token' end it 'should return blank Hash' do response = @query.fetch response.should == {} end end context 'when invalid access token given' do before do fake_fql_json @raw_query, 'query/user/with_invalid_token', :access_token => 'invalid' end it 'should raise exception' do lambda do @query.fetch('invalid') end.should raise_error(FbGraph::Exception) end end context 'when valid access token given' do before do fake_fql_json @raw_query, 'query/user/with_valid_token', :access_token => 'valid' end it 'should return an Array of Hash' do response = @query.fetch('valid') response.should == [{'uid' => 579612276}] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fb_graph-1.7.1 | spec/fb_graph/query/core_spec.rb |