1
0
Fork 0
mirror of https://github.com/nov/fb_graph2 synced 2023-03-27 23:22:15 -04:00

more spec

This commit is contained in:
nov 2014-06-03 18:41:25 +09:00
parent dc9e265b9d
commit d98934f193
4 changed files with 62 additions and 2 deletions

View file

@ -0,0 +1,18 @@
require 'spec_helper'
describe FbGraph2::Edge::Pokes do
context 'included in User' do
describe '#pokes' do
let(:me) { FbGraph2::User.me('token') }
it 'should return an Array of FbGraph2::Struct::Poke' do
pokes = mock_graph :get, 'me/pokes', 'user/pokes', access_token: 'token' do
me.pokes
end
pokes.should_not be_blank
pokes.each do |poke|
poke.should be_instance_of FbGraph2::Struct::Poke
end
end
end
end
end

View file

@ -0,0 +1,25 @@
require 'spec_helper'
describe FbGraph2::RequestFilter::Authenticator do
let(:klass) { FbGraph2::RequestFilter::Authenticator }
let(:endpoint) { 'https://graph.facebook.com/matake' }
let(:request) { HTTP::Message.new_request(:get, URI.parse(endpoint)) }
let(:request_filter) { klass.new token }
context 'when String given' do
let(:token) { 'token' }
it do
request_filter.filter_request(request)
request.header["Authorization"].should == ["Bearer #{token}"]
end
end
context 'when Rack::OAuth2::AccessToken::Bearer given' do
let(:token) { Rack::OAuth2::AccessToken::Bearer.new access_token: 'token' }
it do
request_filter.filter_request(request)
request.header["Authorization"].should == ["Bearer #{token.access_token}"]
end
end
end

View file

@ -1,8 +1,8 @@
require 'spec_helper'
describe FbGraph2::RequestFilter::Debugger do
let(:resource_endpoint) { 'https://graph.facebook.com/matake' }
let(:request) { HTTP::Message.new_request(:get, URI.parse(resource_endpoint)) }
let(:endpoint) { 'https://graph.facebook.com/matake' }
let(:request) { HTTP::Message.new_request(:get, URI.parse(endpoint)) }
let(:response) { HTTP::Message.new_response({:hello => 'world'}.to_json) }
let(:request_filter) { FbGraph2::RequestFilter::Debugger.new }

View file

@ -0,0 +1,17 @@
{
"data": [{
"to": {
"id": "579612276",
"name": "Nov Matake"
},
"from": {
"id": "10203783534727236",
"name": "Taizo Matsuoka"
},
"created_time": "2014-06-03T09:01:25+0000"
}],
"paging": {
"previous": "https://graph.facebook.com/v2.0/579612276/pokes?limit=25&since=1401786085",
"next": "https://graph.facebook.com/v2.0/579612276/pokes?limit=25&until=1401786085"
}
}