Sha256: 21a77c7e019f367066ed1055bfd3c350d2f750ff8b1354ff0d31e209e774020a

Contents?: true

Size: 957 Bytes

Versions: 2

Compression:

Stored size: 957 Bytes

Contents

Bundler.require :default, :test

$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))

require 'factories'
require 'enum_type'

ActiveRecord::Base.establish_connection(
  adapter: (defined?(JRuby) ? 'jdbcpostgresql' : 'postgresql'),
  database: 'enum_type_test',
  username: 'enum_type_tester',
  host: 'localhost'
)

class Model < ActiveRecord::Base
  extend EnumType
  enum_type :state, allow_nil: true, values: %w( pending processing completed failed )
end

RSpec.configure do |config|
  config.before(:each) do
    Model.connection.execute "DROP TABLE IF EXISTS models"
    Model.connection.execute "DROP TYPE IF EXISTS state_type"
    Model.connection.execute "CREATE TYPE state_type AS ENUM ('pending', 'processing', 'completed', 'failed')"
    Model.connection.execute "CREATE TABLE models (id SERIAL PRIMARY KEY, state state_type DEFAULT 'pending')"
    Model.connection.reconnect!
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
enum_type-2.1.2 spec/spec_helper.rb
enum_type-2.1.1 spec/spec_helper.rb