mirror of
https://github.com/nov/fb_graph2
synced 2023-03-27 23:22:15 -04:00
more spec
This commit is contained in:
parent
dc9e265b9d
commit
d98934f193
4 changed files with 62 additions and 2 deletions
18
spec/fb_graph2/edge/pokes_spec.rb
Normal file
18
spec/fb_graph2/edge/pokes_spec.rb
Normal 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
|
25
spec/fb_graph2/request_filter/authenticator_spec.rb
Normal file
25
spec/fb_graph2/request_filter/authenticator_spec.rb
Normal 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
|
|
@ -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 }
|
||||
|
||||
|
|
17
spec/mock_json/user/pokes.json
Normal file
17
spec/mock_json/user/pokes.json
Normal 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"
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue