This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Phone do | |
@doc """ | |
Remove formatting from a phone number. | |
Returns "0000000000" if phone number is not valid | |
(10 digits or "1" followed by 10 digits) | |
## Examples | |
iex> Phone.number("123-456-7890") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test "invalid when proper number of digits but letters mixed in" do | |
assert Phone.number("1a2a3a4a5a6a7a8a9a0a") == "0000000000" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe "Bottles Song" do | |
it "the first verse" do | |
expected = "99 bottles of beer on the wall, " + | |
"99 bottles of beer.\n" + | |
"Take one down and pass it around, " + | |
"98 bottles of beer on the wall.\n" | |
expect(expected).to eq(Bottles.verse(99)) | |
end |
OlderNewer