Sha256: df815f33b8b1f9d9c3377ea63e6457d6e907d97d6289efd4c4772511201cc904

Contents?: true

Size: 924 Bytes

Versions: 11

Compression:

Stored size: 924 Bytes

Contents

module DefinitionHelpers
  def with_function_definition(name:, sql_definition:, version: 1, &block)
    definition = Fx::Definition.new(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.new(
      name: name,
      version: version,
      type: "trigger",
    )

    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.open(definition.full_path, "w") { |f| f.write(sql_definition) }
    block.call
  ensure
    File.delete definition.full_path
  end
end

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

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
fx-0.7.0 spec/support/definition_helpers.rb
fx-jets-0.6.3s spec/support/definition_helpers.rb
fx-0.6.2 spec/support/definition_helpers.rb
fx-0.6.1 spec/support/definition_helpers.rb
fx-0.6.0 spec/support/definition_helpers.rb
fx-0.5.0 spec/support/definition_helpers.rb
fx-0.4.0 spec/support/definition_helpers.rb
fx-0.3.1 spec/support/definition_helpers.rb
fx-0.3.0 spec/support/definition_helpers.rb
fx-0.2.0 spec/support/definition_helpers.rb
fx-0.1.0 spec/support/definition_helpers.rb