Sha256: fb0876d4124591e9ed6a3eefd1758b319ad787f31c6d07248ede768fe0aa30e8

Contents?: true

Size: 1.76 KB

Versions: 6

Compression:

Stored size: 1.76 KB

Contents

require_relative 'helpers/test_helper'

class ValueTest < Minitest::Test
  def test_equal_by_symbol
    status = Status.draft

    assert_equal true, status == :draft
  end

  def test_equal_by_string
    status = Status.draft

    assert_equal true, status == 'draft'
  end

  def test_equal_by_enumeration
    status = Status.draft

    assert_equal true, status == Status.draft
  end

  def test_not_equal_by_enumeration
    status = Status.draft

    assert_equal false, status == Status.published
  end

  def test_with_defined_custom_attributes_visible
    status = Status.find(:none)

    assert_equal true, status.visible
  end

  def test_with_defined_custom_attributes_deleted
    status = Status.find(:deleted)

    assert_equal true, status.deleted
  end

  def test_without_defined_custom_attributes
    status = Status.find(:draft)

    assert_nil status.visible
  end

  def test_enumeration_to_i_return_ordinal
    first_status = Status.find(:draft)
    second_status = Status.find(:review_pending)

    assert_equal first_status.to_i, 1
    assert_equal second_status.to_i, 2
  end

  def test_enumeration_to_sym
    status = Status.find(:draft)

    assert_equal status.to_sym, :draft
  end

  def test_enumeration_to_param
    status = Status.find(:draft)

    assert_equal status.to_param, 'draft'
  end

  def test_enumeration_when_attribute_value_is_symbol
    role = Role.find(:lecturer)

    assert_equal role.type, 'croatist'
  end

  def test_enumeration_attribute_predicate_methods
    status = Status.none

    assert_equal status.name?, true
    assert_equal status.visible?, true
    assert_equal status.deleted?, false
  end

  def test_enumeration_attribute_predicate_method_on_undefined_attribute
    status = Status.deleted

    assert_equal status.name?, false
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
enumerations-2.5.1 test/value_test.rb
enumerations-2.5.0 test/value_test.rb
enumerations-2.4.0 test/value_test.rb
enumerations-2.3.3 test/value_test.rb
enumerations-2.3.2 test/value_test.rb
enumerations-2.3.1 test/value_test.rb