Sha256: 36a7fad07201702fd7d4e6a65503a08579cef90cfff2d216394045f2db58bd9e

Contents?: true

Size: 869 Bytes

Versions: 1

Compression:

Stored size: 869 Bytes

Contents

module DefinitionHelpers
  def with_function_definition(name:, sql_definition:, version: 1, &block)
    definition = Fx::Definition.function(name: name, version: version)

    with_definition(
      definition: definition,
      sql_definition: sql_definition,
      block: block
    )
  end

  def with_trigger_definition(name:, sql_definition:, version: 1, &block)
    definition = Fx::Definition.trigger(name: name, version: version)

    with_definition(
      definition: definition,
      sql_definition: sql_definition,
      block: block
    )
  end

  def with_definition(definition:, sql_definition:, block:)
    FileUtils.mkdir_p(File.dirname(definition.full_path))
    File.write(definition.full_path, sql_definition)
    block.call
  ensure
    File.delete definition.full_path
  end
end

RSpec.configure do |config|
  config.include DefinitionHelpers
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fx-0.9.0 spec/support/definition_helpers.rb