test/phonelib_test.rb in phonelib-0.2.4 vs test/phonelib_test.rb in phonelib-0.2.5
- old
+ new
@@ -94,11 +94,11 @@
end
end
context 'valid_for_country?' do
context 'with correct data' do
- ['IL', :il].each do |country|
+ ['IL', 'il', :il].each do |country|
context "with #{country} as country" do
should 'be valid' do
assert Phonelib.valid_for_country?('972541234567', country)
end
@@ -115,11 +115,11 @@
end
end
end
end
- ['US', :us].each do |country|
+ ['US', 'us', :us].each do |country|
context "with #{country} as country" do
context 'with incorrect data' do
should 'not be valid' do
assert !Phonelib.valid_for_country?('972541234567', country)
end
@@ -134,21 +134,21 @@
end
end
context '.invalid_for_country?' do
context 'with correct data' do
- ['IL', :il].each do |country|
+ ['IL', 'il', :il].each do |country|
context "with #{country} as country" do
should 'not be invalid' do
assert !Phonelib.invalid_for_country?('972541234567', country)
end
end
end
end
context 'with incorrect data' do
- ['US', :us].each do |country|
+ ['US', 'us', :us].each do |country|
context "with #{country} as country" do
should 'be invalid' do
assert Phonelib.invalid_for_country?('972541234567', country)
end
end
@@ -180,9 +180,40 @@
end
should 'return without leading digit for CN number' do
phone = Phonelib.parse('18621374266', 'CN')
assert_equal '186 2137 4266', phone.national
+ end
+ end
+
+ context 'types' do
+ setup { @phone = Phonelib.parse('972541234567') }
+ should 'return :mobile type' do
+ assert_equal :mobile, @phone.type
+ end
+
+ should 'return Mobile human type' do
+ assert_equal 'Mobile', @phone.human_type
+ end
+
+ should 'return [:mobile] as all types' do
+ assert_equal [:mobile], @phone.types
+ end
+
+ should 'return [Mobile] as all human types' do
+ assert_equal %w(Mobile), @phone.human_types
+ end
+ end
+
+ context 'country' do
+ should 'return IL as country' do
+ phone = Phonelib.parse('972541234567')
+ assert 'IL', phone.country
+ end
+
+ should 'return RU as country' do
+ phone = Phonelib.parse('78005500500')
+ assert 'RU', phone.country
end
end
context 'default_country' do
should 'be invalid with no default country set' do