Sha256: a1f2018eab1ac3c6249324402e4530a784e08b1906d8c3c5f788077c91f3f54d
Contents?: true
Size: 1.63 KB
Versions: 3
Compression:
Stored size: 1.63 KB
Contents
module LiveTestingDataHelper # in RSpec 2, included example groups no longer share any hooks or state with outside examples # even if in the same block # so we have to use a module to provide setup and teardown hooks for live testing def self.included(base) base.class_eval do before :each do @token = $testing_data["oauth_token"] raise Exception, "Must supply access token to run FacebookWithAccessTokenTests!" unless @token # track temporary objects created @temporary_object_ids = [] end after :each do # clean up any temporary objects @temporary_object_ids << @temporary_object_id if @temporary_object_id count = @temporary_object_ids.length errors = [] if count > 0 print "\nCleaning up #{count} temporary #{count > 1 ? "objects" : "object (#{@temporary_object_ids.first})"}..." @temporary_object_ids.each do |id| # get our API api = @api || (@test_users ? @test_users.graph_api : nil) raise "Unable to locate API when passed temporary object to delete!" unless api # delete the object result = (api.delete_object(id) rescue false) # if we errored out or Facebook returned false, track that errors << id unless result end if errors.length == 0 puts "done." else puts "cleaned up #{count - errors.length} objects, but errored out on the following:\n #{errors.join(", ")}" end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
koala-1.0.0.beta2.1 | spec/koala/live_testing_data_helper.rb |
koala-1.0.0.beta2 | spec/koala/live_testing_data_helper.rb |
koala-1.0.0.beta | spec/koala/live_testing_data_helper.rb |