Sha256: 6e67ed92a51eda0d8ca0627af66ed23f56ae8d8991d1258d3581aa56147ba841

Contents?: true

Size: 1.07 KB

Versions: 5

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

describe ActiveRecord::Migration, "#create_enum" do
  before_all { run_migration "create_schema :finances" }

  context "with a full definition" do
    let(:migration) do
      <<~RUBY
        create_enum "finances.currency" do |e|
          e.values "EUR", "USD"
          e.comment "Supported currency values"
        end
      RUBY
    end
    let(:query) { "SELECT 'EUR'::finances.currency;" }

    its(:execution) { is_expected.to enable_sql_request(query) }
    its(:execution) { is_expected.to insert(migration).into_schema }
    its(:inversion) { is_expected.to disable_sql_request(query) }
    its(:inversion) { is_expected.not_to change_schema }
  end

  context "without values" do
    let(:migration) { "create_enum :currency" }

    it { is_expected.to fail_validation.because(/values can't be blank/i) }
  end

  context "without name" do
    let(:migration) do
      <<~RUBY
        create_enum do |e|
          e.values "EUR", "USD"
        end
      RUBY
    end

    it { is_expected.to fail_validation.because(/name can't be blank/i) }
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pg_trunk-0.2.0 spec/operations/enums/create_enum_spec.rb
pg_trunk-0.1.3 spec/operations/enums/create_enum_spec.rb
pg_trunk-0.1.2 spec/operations/enums/create_enum_spec.rb
pg_trunk-0.1.1 spec/operations/enums/create_enum_spec.rb
pg_trunk-0.1.0 spec/operations/enums/create_enum_spec.rb