Skip to content

Commit

Permalink
Add vanity specs.
Browse files Browse the repository at this point in the history
  • Loading branch information
floere committed Jan 22, 2017
1 parent 2b2d2bc commit b5419b7
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/phony/vanity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def self.replace number
end

# Returns true if there is a character in the number
# after the first four numbers.
# after the first three numbers.
#
@@vanity_regexp = /\A\d{3}[a-zA-Z]{6,12}\Z/
def self.vanity? number
Expand Down
30 changes: 30 additions & 0 deletions spec/lib/phony/vanity_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# encoding: utf-8
#
require 'spec_helper'

describe Phony::Vanity do

let(:vanity) { described_class }

describe '.replace' do
it 'replaces letters with digits' do
vanity.replace('1-800-HELLO').should == '1-800-43556'
end
end

describe '.vanity?' do
it 'returns true on a vanity number' do
vanity.vanity?('123HELLOES').should == true
end
it 'returns false on a non-vanity number' do
vanity.vanity?('1234355637').should == false
end
end

describe '.normalized' do
it 'normalizes the vanity number' do
vanity.normalized('1-800-HELLO').should == '1800HELLO'
end
end

end

0 comments on commit b5419b7

Please sign in to comment.