Sha256: 2eb654d68d11d54e8255c6a067f7deac5c9b06732bb2ecaf8293d4a5f67015bc

Contents?: true

Size: 842 Bytes

Versions: 2

Compression:

Stored size: 842 Bytes

Contents

require 'test/unit'
require 'phoner'

def parse_test(raw, country_code, area_code, number, country_name = nil, is_mobile = nil)
  pn = Phoner::Phone.parse(raw)

  assert_not_nil pn, %Q{parse should pass}
  assert_equal pn.country_code, country_code
  assert_equal pn.area_code, area_code
  assert_equal pn.number, number
  if country_name
    assert_equal pn.country.name, country_name
  end

  unless is_mobile.nil?
    assert_equal is_mobile, pn.is_mobile?
  end
end


class Phoner::TestCase < Test::Unit::TestCase

  def setup
    Phoner::Phone.default_country_code = nil
    Phoner::Phone.default_area_code = nil
  end

  def default_test
    klass = self.class.to_s
    ancestors = (self.class.ancestors - [self.class]).collect { |ancestor| ancestor.to_s }
    super unless klass =~ /TestCase/ or ancestors.first =~ /TestCase/
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
phoner-1.0.1 test/test_helper.rb
phoner-1.0 test/test_helper.rb