diff --git a/ruby/spec/spec_helper.rb b/ruby/spec/spec_helper.rb index 9a43ca42f..77cdf2ddd 100644 --- a/ruby/spec/spec_helper.rb +++ b/ruby/spec/spec_helper.rb @@ -78,6 +78,10 @@ Spork.prefork do DatabaseCleaner.clean end + config.after(:suite) do + wipe_s3_test_bucket + end + # If you're not using ActiveRecord, or you'd prefer not to run each of your # examples within a transaction, remove the following line or assign false # instead of true. diff --git a/ruby/spec/support/utilities.rb b/ruby/spec/support/utilities.rb index 822d07c51..9a22c1b8d 100644 --- a/ruby/spec/support/utilities.rb +++ b/ruby/spec/support/utilities.rb @@ -1,8 +1,9 @@ +JAMKAZAM_TESTING_BUCKET = 'jamkazam-testing' # cuz i'm not comfortable using aws_bucket accessor directly def app_config klass = Class.new do def aws_bucket - 'jamkazam-testing' + JAMKAZAM_TESTING_BUCKET end def aws_access_key_id @@ -15,4 +16,16 @@ def app_config end return klass.new +end + +def wipe_s3_test_bucket + test_config = app_config + s3 = AWS::S3.new(:access_key_id => test_config.aws_access_key_id, + :secret_access_key => test_config.aws_secret_access_key) + test_bucket = s3.buckets[JAMKAZAM_TESTING_BUCKET] + + if test_bucket.name == JAMKAZAM_TESTING_BUCKET + puts "Ruby - Pretending to delete all contents of #{test_bucket.name}" + #test_bucket.delete_all + end end \ No newline at end of file diff --git a/web/spec/spec_helper.rb b/web/spec/spec_helper.rb index 968e32400..aa70cebc0 100644 --- a/web/spec/spec_helper.rb +++ b/web/spec/spec_helper.rb @@ -99,10 +99,11 @@ Spork.prefork do config.include Snapshot config.before(:suite) do + set_up_snapshot end config.before(:all) do - set_up_snapshot + end config.before(:each) do @@ -120,10 +121,6 @@ Spork.prefork do config.before(:each, :js => true) do end - config.before(:each) do - - end - config.append_after(:each) do Capybara.reset_sessions! @@ -144,7 +141,12 @@ Spork.prefork do end config.after(:all) do + + end + + config.after(:suite) do tear_down_snapshot + wipe_s3_test_bucket end end end diff --git a/web/spec/support/utilities.rb b/web/spec/support/utilities.rb index c8a076009..f755a6e48 100644 --- a/web/spec/support/utilities.rb +++ b/web/spec/support/utilities.rb @@ -29,6 +29,39 @@ def cookie_jar Capybara.current_session.driver.browser.current_session.instance_variable_get(:@rack_mock_session).cookie_jar end +#these S3 functions copied from ruby/spec/support/utilities.rb +JAMKAZAM_TESTING_BUCKET = 'jamkazam-testing' # cuz i'm not comfortable using aws_bucket accessor directly + +def app_config + klass = Class.new do + def aws_bucket + JAMKAZAM_TESTING_BUCKET + end + + def aws_access_key_id + 'AKIAJESQY24TOT542UHQ' + end + + def aws_secret_access_key + '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' + end + end + + return klass.new +end + +def wipe_s3_test_bucket + test_config = app_config + s3 = AWS::S3.new(:access_key_id => test_config.aws_access_key_id, + :secret_access_key => test_config.aws_secret_access_key) + test_bucket = s3.buckets[JAMKAZAM_TESTING_BUCKET] + + if test_bucket.name == JAMKAZAM_TESTING_BUCKET + puts "Web - Pretending to delete all contents of #{test_bucket.name}" + #test_bucket.delete_all + end +end +# --end of S3 methods copied from ruby/spec/support/utilities.rb def sign_in(user)