Permalink
Browse files

Get tests passing again

  • Loading branch information...
1 parent b869925 commit 9475e534ebfb0542c00cbbc9f9f4b9bb84c174ed @arsduo committed Jan 7, 2013
@@ -127,8 +127,6 @@ graph_api:
with_token: '[{"code": 200, "body":"{\"id\": \"MOCK_PHOTO\"}"}, {"code": 200, "body":"{\"id\": \"MOCK_PHOTO\"}"}]'
-
-
/me:
no_args:
get:
@@ -405,7 +403,7 @@ graph_api:
no_args:
<<: *item_deleted
get:
- with_token: '{"link":"http://oauth.twoalex.com/", "name": "OAuth Playground"}'
+ with_token: '{"link":"http://oauth.twoalex.com/", "message": "Hello, world, from the test suite again!", "name": "OAuth Playground"}'
/FEED_ITEM_CATS:
no_args:
@@ -1,15 +1,15 @@
require "spec_helper"
-module koala
- module facebook
- describe api do
+module Koala
+ module Facebook
+ describe API do
before :each do
- @api = koala::facebook::api.new(@token)
- @api_without_token = koala::facebook::api.new
+ @api = Koala::Facebook::API.new(@token)
+ @api_without_token = Koala::Facebook::API.new
# app api
- @app_id = koalatest.app_id
- @app_access_token = koalatest.app_access_token
- @app_api = koala::facebook::api.new(@app_access_token)
+ @app_id = KoalaTest.app_id
+ @app_access_token = KoalaTest.app_access_token
+ @app_api = Koala::Facebook::API.new(@app_access_token)
end
describe "the Batch API" do
@@ -490,11 +490,11 @@ module facebook
end
it 'makes mixed calls inside of a batch' do
- me, friends = @api.batch do |batch_api|
+ results = @api.batch do |batch_api|
batch_api.get_object('me')
batch_api.get_connections('me', 'friends')
end
- friends.should be_a(Koala::Facebook::GraphCollection)
+ results.last.should be_a(Koala::Facebook::GraphCollection)
end
it 'turns pageable results into GraphCollections' do
@@ -536,7 +536,7 @@ module facebook
result = @api.put_wall_post("Hello, world, from the test suite batch API!")
wall_post = result["id"]
- wall_post, koppel = @api.batch do |batch_api|
+ @api.batch do |batch_api|
batch_api.put_like(wall_post)
batch_api.delete_object(wall_post)
end
@@ -590,7 +590,7 @@ module facebook
describe "binary files" do
it "posts binary files" do
- file = File.open(File.join(File.dirname(__FILE__), "..", "fixtures", "beach.jpg"))
+ file = File.open(File.join(File.dirname(__FILE__), "../../fixtures", "beach.jpg"))
Koala::Facebook::GraphBatchAPI::BatchOperation.instance_variable_set(:@identifier, 0)
result = @api.batch do |batch_api|
@@ -602,8 +602,8 @@ module facebook
end
it "posts binary files with multiple requests" do
- file = File.open(File.join(File.dirname(__FILE__), "..", "fixtures", "beach.jpg"))
- file2 = File.open(File.join(File.dirname(__FILE__), "..", "fixtures", "beach.jpg"))
+ file = File.open(File.join(File.dirname(__FILE__), "../../fixtures", "beach.jpg"))
+ file2 = File.open(File.join(File.dirname(__FILE__), "../../fixtures", "beach.jpg"))
Koala::Facebook::GraphBatchAPI::BatchOperation.instance_variable_set(:@identifier, 0)
results = @api.batch do |batch_api|
@@ -17,7 +17,7 @@ module Facebook
context "without an access token" do
it "can't delete posts" do
# test post on the Ruby SDK Test application
- lambda { @result = @api.delete_object("115349521819193_113815981982767") }.should raise_error(Koala::Facebook::AuthenticationError)
+ lambda { @result = @api_without_token.delete_object("115349521819193_113815981982767") }.should raise_error(Koala::Facebook::AuthenticationError)
end
end
@@ -34,7 +34,7 @@ module Facebook
describe "#delete_like" do
context "without an access token" do
it "can't delete a like" do
- lambda { @api.delete_like("7204941866_119776748033392") }.should raise_error(Koala::Facebook::AuthenticationError)
+ lambda { @api_without_token.delete_like("7204941866_119776748033392") }.should raise_error(Koala::Facebook::AuthenticationError)
end
end
@@ -16,25 +16,25 @@ module Facebook
describe "#get_object" do
context "without an access token" do
it "gets public data about a user" do
- result = @api.get_object(KoalaTest.user1)
+ result = @api_without_token.get_object(KoalaTest.user1)
# the results should have an ID and a name, among other things
(result["id"] && result["name"]).should_not be_nil
end
it "gets public data about a Page" do
- result = @api.get_object(KoalaTest.page)
+ result = @api_without_token.get_object(KoalaTest.page)
# the results should have an ID and a name, among other things
(result["id"] && result["name"]).should
end
it "can't get private data about a user" do
- result = @api.get_object(KoalaTest.user1)
+ result = @api_without_token.get_object(KoalaTest.user1)
# updated_time should be a pretty fixed test case
result["updated_time"].should be_nil
end
it "can't get data about 'me'" do
- lambda { @api.get_object("me") }.should raise_error(Koala::Facebook::ClientError)
+ lambda { @api_without_token.get_object("me") }.should raise_error(Koala::Facebook::ClientError)
end
end
@@ -93,12 +93,12 @@ module Facebook
context "without an access token" do
it "can access connections from public Pages" do
- result = @api.get_connections(KoalaTest.page, "photos")
+ result = @api_without_token.get_connections(KoalaTest.page, "photos")
result.should be_a(Array)
end
it "can't access connections from users" do
- lambda { @api.get_connections(KoalaTest.user2, "friends") }.should raise_error(Koala::Facebook::ClientError)
+ lambda { @api_without_token.get_connections(KoalaTest.user2, "friends") }.should raise_error(Koala::Facebook::ClientError)
end
end
@@ -165,10 +165,10 @@ module Facebook
end
it "can't access protected information via FQL" do
- lambda { @api.fql_query("select read_stream from permissions where uid = #{KoalaTest.user2_id}") }.should raise_error(Koala::Facebook::APIError)
+ lambda { @api_without_token.fql_query("select read_stream from permissions where uid = #{KoalaTest.user2_id}") }.should raise_error(Koala::Facebook::APIError)
end
end
-
+
context "with an access token" do
it "can access protected information via FQL" do
# Tests agains the permissions fql table
@@ -239,7 +239,7 @@ module Facebook
it "can't access protected information via FQL.multiquery" do
lambda {
- @api.fql_multiquery(
+ @api_without_token.fql_multiquery(
:query1 => "select post_id from stream where source_id = me()",
:query2 => "select fromid from comment where post_id in (select post_id from #query1)",
:query3 => "select uid, name from user where uid in (select fromid from #query2)"
@@ -16,9 +16,9 @@ module Facebook
describe "#put_connections" do
context "without an access token" do
it "can't put an object" do
- lambda { @result = @api.put_connections(KoalaTest.user2, "feed", :message => "Hello, world") }.should raise_error(Koala::Facebook::AuthenticationError)
+ lambda { @result = @api_without_token.put_connections(KoalaTest.user2, "feed", :message => "Hello, world") }.should raise_error(Koala::Facebook::AuthenticationError)
# legacy put_object syntax
- lambda { @result = @api.put_object(KoalaTest.user2, "feed", :message => "Hello, world") }.should raise_error(Koala::Facebook::AuthenticationError)
+ lambda { @result = @api_without_token.put_object(KoalaTest.user2, "feed", :message => "Hello, world") }.should raise_error(Koala::Facebook::AuthenticationError)
end
end
end
@@ -30,36 +30,37 @@ module Facebook
it "can't post to a feed" do
(lambda do
attachment = {:name => "OAuth Playground", :link => "http://oauth.twoalex.com/"}
- @result = @api.put_wall_post("Hello, world", attachment, "facebook")
+ @result = @api_without_token.put_wall_post("Hello, world", attachment, "facebook")
end).should raise_error(Koala::Facebook::AuthenticationError)
end
end
context "with an access token" do
it "writes a message to the wall" do
- result = @api.put_wall_post("Hello, world, from the test suite!")
+ message = "Hello, world, from the test suite!"
put_result = @api.put_wall_post(message)
@temporary_object_id = put_result["id"]
- get_result = @api.get_object(@temporary_object_id)
-
- # make sure the message we sent is the message that got posted
- get_result["message"].should == message
end
it "posts a message with an attachment to a feed" do
- result = @api.put_wall_post("Hello, world, from the test suite again!", {
- :name => "OAuth Playground",
- :link => "http://oauth.twoalex.com/"
- })
+ attachment = {
+ "name" => "OAuth Playground",
+ "link" => "http://oauth.twoalex.com/"
+ }
+ result = @api.put_wall_post(
+ "Hello, world, from the test suite again!",
+ attachment
+ )
@temporary_object_id = result["id"]
@temporary_object_id.should_not be_nil
# verify it posted
get_result = @api.get_object(@temporary_object_id)
# make sure the result we fetch includes all the parameters we sent
- it_matches = attachment.inject(true) {|valid, param| valid && (get_result[param[0]] == attachment[param[0]])}
- it_matches.should == true
+ attachment.each_pair do |key, value|
+ expect(get_result[key]).to eq(value)
+ end
end
it "can post a message whose attachment has a properties dictionary" do
@@ -85,7 +86,7 @@ module Facebook
describe "#put_picture" do
it "can post photos to the user's wall with an open file object" do
content_type = "image/jpg"
- file = File.open(File.join(File.dirname(__FILE__), "..", "fixtures", "beach.jpg"))
+ file = File.open(File.join(File.dirname(__FILE__), "../../fixtures", "beach.jpg"))
result = @api.put_picture(file, content_type)
@temporary_object_id = result["id"]
@@ -137,7 +138,7 @@ module Facebook
describe "#put_video" do
before :each do
- @cat_movie = File.join(File.dirname(__FILE__), "..", "fixtures", "cat.m4v")
+ @cat_movie = File.join(File.dirname(__FILE__), "../..//fixtures", "cat.m4v")
@content_type = "video/mpeg4"
end
@@ -171,6 +172,13 @@ module Facebook
describe "#put_comment" do
context "without an access token" do
+ it "can't comment on an object" do
+ # random public post on the facebook wall
+ lambda { @result = @api_without_token.put_comment("7204941866_119776748033392", "The hackathon was great!") }.should raise_error(Koala::Facebook::AuthenticationError)
+ end
+ end
+
+ context "with an access token" do
it "posts a comment to another object" do
message_text = "Hello, world, from the test suite, testing comments again!"
result = @api.put_wall_post(message_text)
@@ -185,13 +193,6 @@ module Facebook
get_result["message"].should == comment_text
end
end
-
- context "with an access token" do
- it "can't comment on an object" do
- # random public post on the facebook wall
- lambda { @result = @api.put_comment("7204941866_119776748033392", "The hackathon was great!") }.should raise_error(Koala::Facebook::AuthenticationError)
- end
- end
end
describe "#put_like" do
@@ -201,9 +202,10 @@ module Facebook
like_result = @api.put_like(@temporary_object_id)
like_result.should be_true
end
+
context "without an access token" do
it "can't like an object" do
- lambda { @api.put_like("7204941866_119776748033392") }.should raise_error(Koala::Facebook::AuthenticationError)
+ lambda { @api_without_token.put_like("7204941866_119776748033392") }.should raise_error(Koala::Facebook::AuthenticationError)
end
end
end
@@ -239,4 +241,4 @@ module Facebook
end
end
end
-end
+end
@@ -112,8 +112,6 @@
it_should_behave_like "Koala RestAPI"
it_should_behave_like "Koala RestAPI with an access token"
-
- it_should_behave_like "Koala GraphAPI with GraphCollection"
end
describe "without an access token" do
@@ -123,7 +121,5 @@
it_should_behave_like "Koala RestAPI"
it_should_behave_like "Koala RestAPI without an access token"
-
- it_should_behave_like "Koala GraphAPI with GraphCollection"
end
end
View
@@ -40,7 +40,6 @@
# load supporting files for our tests
require 'support/rest_api_shared_examples'
-require 'support/graph_api_shared_examples'
require 'support/uploadable_io_shared_examples'
BEACH_BALL_PATH = File.join(File.dirname(__FILE__), "fixtures", "beach.jpg")

0 comments on commit 9475e53

Please sign in to comment.