Permalink
Browse files

Adios, Context Optional

  • Loading branch information...
1 parent 6e151d0 commit 88a8dcea0f0c8829459188d9d8739eaf703512bb @arsduo committed Sep 12, 2012
Showing with 22 additions and 22 deletions.
  1. +6 −6 spec/fixtures/mock_facebook_responses.yml
  2. +3 −3 spec/support/graph_api_shared_examples.rb
  3. +13 −13 spec/support/koala_test.rb
@@ -44,7 +44,7 @@ graph_api:
# OAuth error response
oauth_error: &oauth_error
- no_token:
+ no_token:
code: 400
body: '{"error": {"code"=>2500, "type": "OAuthException", "message": "Error validating verification code."}}'
@@ -68,10 +68,10 @@ graph_api:
# -- Stubbed Responses --
root:
- ids=contextoptional,koppel:
+ ids=facebook,koppel:
get:
- with_token: '{"contextoptional":"{}","koppel":"{}"}'
- no_token: '{"contextoptional":"{}","koppel":"{}"}'
+ with_token: '{"facebook":"{}","koppel":"{}"}'
+ no_token: '{"facebook":"{}","koppel":"{}"}'
# Ruby 1.8.7 and 1.9.2 generate JSON with different key ordering, hence we have to dynamically generate it here
batch=<%= MultiJson.dump([{"method" => "get", "relative_url" => "me"},{"method" => "get", "relative_url" => "koppel"}]) %>:
@@ -204,13 +204,13 @@ graph_api:
with_token: '{"id": 1, "name": 1, "updated_time": 1}'
no_token: '{"id": 1, "name": 1}'
- /contextoptional:
+ /facebook:
no_args:
get:
with_token: '{"id": 1, "name": 1}'
no_token: '{"id": 1, "name": 1}'
- /contextoptional/photos:
+ /facebook/photos:
no_args:
get:
with_token: '{"data": [{}], "paging": {"previous": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000", "next": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000"}}'
@@ -81,7 +81,7 @@
end
it "gets multiple objects if they're a string" do
- results = @api.get_objects("contextoptional,#{KoalaTest.user1}")
+ results = @api.get_objects("facebook,#{KoalaTest.user1}")
results.should have(2).items
end
@@ -602,12 +602,12 @@
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, "contextoptional")
+ @result = @api.put_wall_post("Hello, world", attachment, "facebook")
end).should raise_error(Koala::Facebook::AuthenticationError)
end
it "can't comment on an object" do
- # random public post on the ContextOptional wall
+ # 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
View
@@ -6,19 +6,19 @@ class << self
attr_accessor :oauth_test_data, :subscription_test_data, :search_time
attr_accessor :test_user_api
end
-
+
# Test setup
-
+
def self.setup_test_environment!
setup_rspec
-
+
unless ENV['LIVE']
# By default the Koala specs are run using stubs for HTTP requests,
# so they won't fail due to Facebook-imposed rate limits or server timeouts.
#
# However as a result they are more brittle since
# we are not testing the latest responses from the Facebook servers.
- # To be certain all specs pass with the current Facebook services,
+ # To be certain all specs pass with the current Facebook services,
# run LIVE=true bundle exec rake spec.
Koala.http_service = Koala::MockHTTPService
KoalaTest.setup_test_data(Koala::MockHTTPService::TEST_DATA)
@@ -36,7 +36,7 @@ def self.setup_test_environment!
rescue LoadError
puts "Unable to load adapter #{adapter}, using Net::HTTP."
end
-
+
Koala.http_service.http_options[:beta] = true if ENV["beta"] || ENV["BETA"]
# use a test user unless the developer wants to test against a real profile
@@ -47,7 +47,7 @@ def self.setup_test_environment!
end
end
end
-
+
def self.setup_rspec
# set up a global before block to set the token for tests
# set the token up for
@@ -85,15 +85,15 @@ def self.setup_test_data(data)
self.secret = data["oauth_test_data"]["secret"]
self.code = data["oauth_test_data"]["code"]
self.session_key = data["oauth_test_data"]["session_key"]
-
+
# fix the search time so it can be used in the mock responses
self.search_time = data["search_time"] || (Time.now - 3600).to_s
end
def self.testing_permissions
"read_stream, publish_stream, user_photos, user_videos, read_insights"
end
-
+
def self.setup_test_users
print "Setting up test users..."
@test_user_api = Koala::Facebook::TestUsers.new(:app_id => self.app_id, :secret => self.secret)
@@ -103,7 +103,7 @@ def self.setup_test_users
# before each test module, create two test users with specific names and befriend them
KoalaTest.create_test_users
end
-
+
config.after :suite do
# after each test module, delete the test users to avoid cluttering up the application
KoalaTest.destroy_test_users
@@ -122,9 +122,9 @@ def self.create_test_users
rescue Exception => e
Kernel.warn("Problem creating test users! #{e.message}")
raise
- end
+ end
end
-
+
def self.destroy_test_users
[@live_testing_user, @live_testing_friend].each do |u|
puts "Unable to delete test user #{u.inspect}" if u && !(@test_user_api.delete(u) rescue false)
@@ -144,7 +144,7 @@ def self.validate_user_info(token)
end
puts "done!"
end
-
+
# Info about the testing environment
def self.real_user?
!(mock_interface? || @test_user_api)
@@ -189,7 +189,7 @@ def self.user2_name
end
def self.page
- "contextoptional"
+ "facebook"
end
def self.app_properties

0 comments on commit 88a8dce

Please sign in to comment.