Last active
February 17, 2016 06:01
-
-
Save johncip/a16fdad84cc39e3a6b27 to your computer and use it in GitHub Desktop.
Print fixtures used
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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