Sha256: be23a3e5341a1264f4c3d43a707fd0ae8781dc2eb0debb6abf177fc0e43a584b

Contents?: true

Size: 762 Bytes

Versions: 1

Compression:

Stored size: 762 Bytes

Contents

# encoding: utf-8

require "ostruct"
require "test/unit"
require "genderify"

class StringExtTest < Test::Unit::TestCase

  def test_0_variants
    assert_equal "foo", "foo".genderify(:f)
  end

  def test_1_variant
    assert_equal "About him", "About (him|her)".genderify(:m)
  end

  def test_2_variants
    str = "Gde si krenu(o|la), sad će da postavljaju... Jesi li sigur(an|na)?"
    assert_equal "Gde si krenuo, sad će da postavljaju... Jesi li siguran?",  str.genderify(:m)
    assert_equal "Gde si krenula, sad će da postavljaju... Jesi li sigurna?", str.genderify(:f)
  end

  def test_genderable_object
    user = OpenStruct.new(gender: 'female', name: 'Jane')
    assert_equal "She is an addict", "(He|She) is an addict".genderify(user)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
genderify-0.0.2 test/string_ext_test.rb