Skip to content

Instantly share code, notes, and snippets.

@johncip
Last active February 17, 2016 06:01
Show Gist options
  • Save johncip/a16fdad84cc39e3a6b27 to your computer and use it in GitHub Desktop.
Save johncip/a16fdad84cc39e3a6b27 to your computer and use it in GitHub Desktop.
Print fixtures used
log = StringIO.new
ActiveRecord::Base.logger = Logger.new(log)
Gradescope::Application.config.colorize_logging = false
RSpec.configure do |config|
config.after :suite do
lines = log.tap(&:rewind).readlines.to_a
matching = lines.map do |line|
next unless line =~ /Load/
next if line =~ /SchemaMigration/
line.match(/(\w+) Load/)[1]
end
table_names = matching.uniq.compact.map do |x|
x.underscore.pluralize.to_sym
end
puts "fixtures #{table_names.inspect}\n"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment