Skip to content

Instantly share code, notes, and snippets.

@amar47shah
Last active August 27, 2015 17:30
Show Gist options
  • Save amar47shah/db8c0829c64c51455274 to your computer and use it in GitHub Desktop.
Save amar47shah/db8c0829c64c51455274 to your computer and use it in GitHub Desktop.
Test for clean database between specs
# spec/clean_database_spec.rb
require 'rails_helper'
describe 'Checking for clean database' do
specify 'no data to start with' do
[
# your model classes
].each do |model|
expect(model.count).to be_zero
end
end
end
# test_db_clean.sh
bundle exec rspec -fd $1
bundle exec rspec -fd spec/clean_database_spec.rb
@amar47shah
Copy link
Author

run all specs with something like:

find spec -name *_spec.rb -exec test_db_clean.sh {} \;

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