Sha256: 5e03da052c5e9426b59192596fce067168355882525dfaba1971581e9b27dfc6

Contents?: true

Size: 987 Bytes

Versions: 1

Compression:

Stored size: 987 Bytes

Contents

require 'helper'

class AxleAttributes::DumperTest < ActiveSupport::TestCase
  class TestModel
    def self.attributes
      {
        'foo'   => AxleAttributes::ParentDefinition.new(self, 'foo',    type: :string, version: true),
        'momma' => AxleAttributes::ParentDefinition.new(self, 'momma',  type: :integer, version: false),
      }
    end

    def self.attribute_set
      attributes.keys.to_set
    end
  end

  test 'dump_internal' do
    result = dumper.dump_internal

    assert_match /Attribute,Display Name,Type,Deprecation/, result
    assert_match Regexp.new('foo,Foo'), result
    assert_match Regexp.new('momma,Momma'), result
  end

  test 'dump_public' do
    result = dumper.dump_public(['foo'])

    assert_match /Attribute,Display Name,Type,Description/, result
    assert_match Regexp.new('foo,Foo'), result
    refute_match Regexp.new('momma,Momma'), result
  end

  private

    def dumper
      @dumper ||= AxleAttributes::Dumper.new(TestModel)
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
axle_attributes-1.13.2 test/lib/dumper_test.rb