Skip to content

Instantly share code, notes, and snippets.

@lowjoel
lowjoel / with_temporary_table.rb
Last active March 1, 2023 21:39
RSpec test group helpers for creating tables.
# Test group helpers for creating tables.
# The latest version can be gound at https://gist.github.com/lowjoel/bda0d44b48aac2925079
module ActiveRecord::TemporaryTable; end
module ActiveRecord::TemporaryTable::TestGroupHelpers
# Defines a temporary table that is instantiated when needed, within a `with_temporary_table`
# block.
#
# @param [Symbol] table_name The name of the table to define.
# @param [Proc] proc The table definition, same as that of a block given to
# +ActiveRecord::Migration::create_table+