Sha256: 917c21dc5cb65db5b6da7c95521b4e11314998c5e930be7094690e35282395d1

Contents?: true

Size: 491 Bytes

Versions: 2

Compression:

Stored size: 491 Bytes

Contents

# frozen_string_literal: true

module Helpers
  module ActiveRecord
    def run_migrations(&block)
      migration = Class.new(::ActiveRecord::Migration[6.1]).tap do |klass|
        klass.define_method(:up, &block)
      end
      ::ActiveRecord::Migration.suppress_messages { migration.migrate(:up) }
    end

    def create_model(name, &block)
      stub_const(name, Class.new(ApplicationRecord)).tap do |klass|
        klass.class_eval(&block) if block_given?
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
solidus_graphql_api-0.3.1 spec/support/helpers/active_record.rb
solidus_graphql_api-0.3.0 spec/support/helpers/active_record.rb