Sha256: ae55753e55629e98a3e3ed4b91cf5752ac831cac27e1e756ef44840509bef308

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

# -*- coding: utf-8 -*-
# vim:ft=ruby:enc=utf-8

require File.dirname(__FILE__)+'/helper'

class TestConverters < Test::Unit::TestCase
  def test_presence
    assert_module_defined ToPass::Converters
  end

  def test_downcase
    assert_converter 'test', 'downcase', 'tEsT'
  end

  def test_remove_repetition
    assert_converter 'helo',  'remove_repetition', 'helo'
    assert_converter 'hel2o', 'remove_repetition', 'hello'
    assert_converter 'hel3o', 'remove_repetition', 'helllo'
  end

  def test_expand_below
    assert_converter 'kFsNotestKrb87d', { 'expand_below' => 5 }, 'test'
    assert_converter 'testtest', { 'expand_below' => 5 }, 'testtest'

  end

  def test_reverse
    assert_converter 'tset', 'reverse', 'test'
  end

  protected

  def assert_converter(expected, rule, string = 'test')
    assert_nothing_raised LoadError do
      result = converter.send(:apply_rule, string, rule)
      assert_equal expected, result, "Converter '#{rule.inspect}' should convert #{string} to #{expected}."
    end
  end

  def converter
    ToPass::Converter.new({})
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
to_pass-0.6.0 test/test_converters.rb
to_pass-0.5.2 test/test_converters.rb