diff --git a/spec/fb_graph2/edge/pokes_spec.rb b/spec/fb_graph2/edge/pokes_spec.rb new file mode 100644 index 0000000..a31e24a --- /dev/null +++ b/spec/fb_graph2/edge/pokes_spec.rb @@ -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 \ No newline at end of file diff --git a/spec/fb_graph2/request_filter/authenticator_spec.rb b/spec/fb_graph2/request_filter/authenticator_spec.rb new file mode 100644 index 0000000..e0aa6d4 --- /dev/null +++ b/spec/fb_graph2/request_filter/authenticator_spec.rb @@ -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 \ No newline at end of file diff --git a/spec/fb_graph2/request_filter/debugger_spec.rb b/spec/fb_graph2/request_filter/debugger_spec.rb index b4a1ac4..c9a4dc1 100644 --- a/spec/fb_graph2/request_filter/debugger_spec.rb +++ b/spec/fb_graph2/request_filter/debugger_spec.rb @@ -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 } diff --git a/spec/mock_json/user/pokes.json b/spec/mock_json/user/pokes.json new file mode 100644 index 0000000..619b57b --- /dev/null +++ b/spec/mock_json/user/pokes.json @@ -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" + } +}