Sha256: 1fda5619b2491fde7396158bffcebb379402eeb595ca1023501fb88211a7d30b

Contents?: true

Size: 1.18 KB

Versions: 3

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

require 'test_helper'

module Upgrow
  class SchemaTest < ActiveSupport::TestCase
    setup do
      @schema = Schema.new(:name, :email)
    end

    test '#attribute_names is empty by default' do
      assert_empty Schema.new.attribute_names
    end

    test '#attribute_names returns the values from the Schema initialization' do
      assert_equal [:name, :email], @schema.attribute_names
    end

    test '#attribute_names ignores duplicates' do
      schema = Schema.new(:name, :email, :name)
      assert_equal [:name, :email], schema.attribute_names
    end

    test '#attribute defines an extra attribute' do
      @schema.attribute(:phone)

      assert_equal [:name, :email, :phone], @schema.attribute_names
    end

    test '#attribute does not define the same attribute twice' do
      @schema.attribute(:name)

      assert_equal [:name, :email], @schema.attribute_names
    end

    test '#dup creates a Schema with independent attribute names' do
      new_schema = @schema.dup
      new_schema.attribute(:phone)

      assert_equal [:name, :email], @schema.attribute_names
      assert_equal [:name, :email, :phone], new_schema.attribute_names
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
upgrow-0.0.5 test/upgrow/schema_test.rb
upgrow-0.0.4 test/upgrow/schema_test.rb
upgrow-0.0.3 test/upgrow/schema_test.rb