So I have used minitest for about 8 months now for testing and all in all it turns out that I loved it more than I expected. I just moved back to an in progress in house project written using Rspec with FactoryGirl and realized I want my minitest and fixtures back. So i found a great script that will generate fixturess based on my database seed.
[ruby]
sql = "SELECT * FROM %s"
skip_tables = ["schema_info"]
ActiveRecord::Base.establish_connection
ActiveRecord::Base.connection.tables.each do |table_name|
i = "000"
File.open("#{Rails.root}/test/fixtures/#{table_name}.yml", 'w') do |file|
data = ActiveRecord::Base.connection.select_all(sql % table_name)
file.write data.inject({}) { |hash, record|
hash["#{table_name}_#{i.succ!}"] = record
hash
}.to_yaml
end
end[/ruby]
Thanks for the script. There are a small typo, missing parenthesis at beginning of line 4