Sha256: 6ece45be45643e4b5d69d752d977dd308d1adf82d8e46e60a6b1a1d9ca751ef0

Contents?: true

Size: 1.37 KB

Versions: 3

Compression:

Stored size: 1.37 KB

Contents

# encoding: utf-8

require 'helper'

class TestActsAsCode < Test::Unit::TestCase

  def test_constants
    assert_equal 'single', Codes::CivilStatus::CodeSingle
  end

  def test_constants
    assert_equal 2, Codes::CivilStatus::all.size

    assert_equal Codes::CivilStatus.for_code('single'),  Codes::CivilStatus::all.first
    assert_equal Codes::CivilStatus.for_code('married'), Codes::CivilStatus::all.last
  end

  def test_ar_code_all
    Codes::ArCode.delete_all

    Codes::ArCode.create(:code => 'code_1', :name => "Code_1_name")
    Codes::ArCode.create(:code => 'code_2', :name => "Code_2_name")

    assert_equal 2, Codes::ArCode.all.size
  end

  def test_ar_code_lookup
    Codes::ArCode.delete_all
    code_1 = Codes::ArCode.create(:code => 'code_1', :name => "Code_1_name")
    code_2 = Codes::ArCode.create(:code => 'code_2', :name => "Code_2_name")

    assert_equal code_2, Codes::ArCode.for_code('code_2')
  end

  def test_constant_definition
    assert Codes::CivilStatus.const_defined?('CodeSingle')
    assert Codes::CivilStatus.const_defined?('CodeMarried')

    assert_equal Codes::CivilStatus::CodeMarried, 'married'
    assert_equal Codes::CivilStatus::CodeSingle,  'single'
  end

  def test_code_translation
    code = Codes::CivilStatus.new('married')

    assert_equal code.translated_code, 'married'
    assert_equal code.translated_code(:de), 'verheiratet'
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
code-box-0.3.1 test/code-box/test_acts_as_code.rb
code-box-0.3.0 test/code-box/test_acts_as_code.rb
code-box-0.2.0 test/code-box/test_acts_as_code.rb