Sha256: dfe115359768278328d9fcaff2b52df98a06755f7349e77413436f171dbe1b95

Contents?: true

Size: 682 Bytes

Versions: 1

Compression:

Stored size: 682 Bytes

Contents

# frozen_string_literal: true

require 'test_helper'

module Upgrow
  class ModelTest < ActiveSupport::TestCase
    class SampleModel < Model
      attribute :title
      attribute :body
    end

    test '.attribute_names includes :id, :created_at, and :updated_at' do
      expected = [:id, :created_at, :updated_at, :title, :body]
      assert_equal expected, SampleModel.attribute_names
    end

    test '.new requires all attributes' do
      error = assert_raises(KeyError) do
        SampleModel.new(
          title: 'volmer', id: 1, created_at: Time.now, updated_at: Time.now
        )
      end

      assert_equal 'key not found: :body', error.message
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
upgrow-0.0.2 test/upgrow/model_test.rb