Skip to content

Instantly share code, notes, and snippets.

@replaid
replaid / spec_helper.rb
Last active December 30, 2015 00:38
Instrumenting the spec run to catch test data leakage at the source. Use like this: bundle exec rspec --seed _(seed number here)_ file1 file2 file3 ...
...
def check_for_pollution
tables_with_records = []
all_tables = ActiveRecord::Base.connection.tables
all_tables.each do |table_name|
has_records = (ActiveRecord::Base.connection.select_value("select exists (select 1 from #{table_name} limit 1)") > 0)
tables_with_records << table_name if has_records
end
expected_tables_with_records = ['schema_migrations']
@replaid
replaid / command to run
Created October 7, 2011 15:34
Dig domains in an input file
sh my-fancy-script.sh input.txt > log-file