Sha256: f9707c660bd89298ccad73248be5b5f36062f3740282b2ed115f6ebe2e19df2c

Contents?: true

Size: 1.01 KB

Versions: 13

Compression:

Stored size: 1.01 KB

Contents

$:.unshift(File.dirname(__FILE__) + '/../lib')

require 'rubygems'

require 'test/unit'
require 'phonie'

def parse_test(raw, country_code, area_code, number, country_name = nil, is_mobile = nil)
  pn = Phonie::Phone.parse!(raw)
  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?
    text = pn.is_mobile? ? :mobile : :local
    assert_equal is_mobile ? :mobile : :local, text
  end
end

def parse_failure(raw)
  pn = Phonie::Phone.parse(raw)
  assert_equal pn, nil
end

class Phonie::TestCase < Test::Unit::TestCase

  def setup
    Phonie.configure do |config|
      config.default_country_code = nil
      config.default_area_code = nil
    end
  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

13 entries across 13 versions & 1 rubygems

Version Path
phonie-3.3.1 test/test_helper.rb
phonie-3.2.2 test/test_helper.rb
phonie-3.2.1 test/test_helper.rb
phonie-3.2.0 test/test_helper.rb
phonie-3.1.15 test/test_helper.rb
phonie-3.1.14 test/test_helper.rb
phonie-3.1.13 test/test_helper.rb
phonie-3.1.12 test/test_helper.rb
phonie-3.1.11 test/test_helper.rb
phonie-3.1.10 test/test_helper.rb
phonie-3.1.9 test/test_helper.rb
phonie-3.1.8 test/test_helper.rb
phonie-3.1.7 test/test_helper.rb