Skip to content

Instantly share code, notes, and snippets.

@Jaym3s
Created November 17, 2011 18:24
Show Gist options
  • Save Jaym3s/1373996 to your computer and use it in GitHub Desktop.
Save Jaym3s/1373996 to your computer and use it in GitHub Desktop.
Database Garbage collection for cucumber
module Cucumber
RETAINED_OBJECTS_FOR_CUCUMBER = []
end
Before('@release') do
module ActiveRecord
class Base
def create_with_cucumber *args
Cucumber::RETAINED_OBJECTS_FOR_CUCUMBER << self
create_without_cucumber *args
end
alias_method_chain :create, :cucumber
end
end
end
After('@release') do
Cucumber::RETAINED_OBJECTS_FOR_CUCUMBER.each do |obj|
obj.destroy
end
Cucumber::RETAINED_OBJECTS_FOR_CUCUMBER = []
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment