Skip to content

Instantly share code, notes, and snippets.

@ga-wolf
Created July 6, 2015 06:33
Show Gist options
  • Save ga-wolf/c7e388f34e84e5af36d9 to your computer and use it in GitHub Desktop.
Save ga-wolf/c7e388f34e84e5af36d9 to your computer and use it in GitHub Desktop.
Phone Test
require 'minitest/autorun'
require 'minitest/pride'
require_relative './phone'
class PhoneTest < MiniTest::Test
def test_cleans_number
number = Phone.new("(123) 456-7890").number
assert_equal "1234567890", number
end
def test_cleans_number_with_dots
skip
number = Phone.new("123.456.7890").number
assert_equal "1234567890", number
end
def test_valid_when_11_digits_and_first_is_1
skip
number = Phone.new("11234567890").number
assert_equal "1234567890", number
end
def test_invalid_when_11_digits
skip
number = Phone.new("21234567890").number
assert_equal "0000000000", number
end
def test_invalid_when_9_digits
skip
number = Phone.new("123456789").number
assert_equal "0000000000", number
end
def test_area_code
skip
number = Phone.new("1234567890")
assert_equal "123", number.area_code
end
def test_pretty_print
skip
number = Phone.new("1234567890")
assert_equal "(123) 456-7890", number.to_s
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment