Skip to content

Instantly share code, notes, and snippets.

@goromlagche
Created July 3, 2018 06:25
Show Gist options
  • Select an option

  • Save goromlagche/dc2151c43037121b328d9b8651f272bf to your computer and use it in GitHub Desktop.

Select an option

Save goromlagche/dc2151c43037121b328d9b8651f272bf to your computer and use it in GitHub Desktop.
module ArHelpers
def listen_to_insert_ar_calls(table)
ActiveSupport::Notifications
.subscribe('sql.active_record') do |_, _, _, _, details|
if details[:sql] =~ /INSERT INTO `#{table}`/
@sql = details[:sql]
end
end
end
end
RSpec.configure do |config|
config.include ArHelpers
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment