Skip to content

Instantly share code, notes, and snippets.

@jmgarnier
Created June 19, 2013 10:02
Show Gist options
  • Save jmgarnier/5813179 to your computer and use it in GitHub Desktop.
Save jmgarnier/5813179 to your computer and use it in GitHub Desktop.
When you need to truncate the test DB before each test, Zeus won't do it automatically. You need a custom plan for that: Run zeus init and then copy paste the following code.
require 'zeus/rails'
class CustomPlan < Zeus::Rails
def truncate_db
require 'database_cleaner'
DatabaseCleaner.clean_with :truncation
end
def test
if spec_file?(ARGV) && defined?(RSpec)
# disable autorun in case the user left it in spec_helper.rb
RSpec::Core::Runner.disable_autorun!
exit_code = RSpec::Core::Runner.run(ARGV)
truncate_db
exit exit_code
else
Zeus::M.run(ARGV)
end
end
end
Zeus.plan = CustomPlan.new
@pawurb
Copy link

pawurb commented Mar 21, 2015

Thanks a lot !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment