spec/support/koala_test.rb in koala-1.5.0 vs spec/support/koala_test.rb in koala-1.6.0.rc1
- old
+ new
@@ -4,23 +4,23 @@
class << self
attr_accessor :oauth_token, :app_id, :secret, :app_access_token, :code, :session_key
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)
else
# Runs Koala specs through the Facebook servers
@@ -34,22 +34,22 @@
require adapter
Faraday.default_adapter = adapter.to_sym
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
unless token = KoalaTest.oauth_token
KoalaTest.setup_test_users
else
KoalaTest.validate_user_info(token)
end
end
end
-
+
def self.setup_rspec
# set up a global before block to set the token for tests
# set the token up for
RSpec.configure do |config|
config.before :each do
@@ -83,29 +83,29 @@
self.app_id = data["oauth_test_data"]["app_id"]
self.app_access_token = data["oauth_test_data"]["app_access_token"]
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)
RSpec.configure do |config|
config.before :suite do
# 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
end
end
@@ -120,13 +120,13 @@
@test_user_api.befriend(@live_testing_user, @live_testing_friend)
self.oauth_token = @live_testing_user["access_token"]
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)
end
end
@@ -142,11 +142,11 @@
raise ArgumentError, "Your access token must have the read_stream, publish_stream, and user_photos permissions, and lack read_insights. You have: #{perms.inspect}"
end
end
puts "done!"
end
-
+
# Info about the testing environment
def self.real_user?
!(mock_interface? || @test_user_api)
end
@@ -187,10 +187,10 @@
def self.user2_name
"Luke"
end
def self.page
- "contextoptional"
+ "facebook"
end
def self.app_properties
mock_interface? ? {"desktop" => 0} : {"description" => "A test framework for Koala and its users. (#{rand(10000).to_i})"}
end