Skip to content

Commit

Permalink
valid_or_correct? changed to valid_or_correct_mobile?
Browse files Browse the repository at this point in the history
I'm only interested in Dutch and Belgian mobile numbers, so just be specific here.
  • Loading branch information
Narnach committed Jan 8, 2010
1 parent 6e6d138 commit feab850
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/number_recognizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ def initialize(number)
@number = number
end

def valid_or_correct?
valid? or correct
def valid_or_correct_mobile?
return false unless valid? or correct
['Dutch mobile', 'Belgian mobile'].include? type
end

# Set type, country and local_number
Expand Down
13 changes: 11 additions & 2 deletions spec/number_recognizer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,24 @@
@nc.local_number.should == '612345678'
end

describe 'valid or correct' do
describe 'valid or correct mobile' do
it 'should correct 0612345678 to 0031612345678' do
@nc = NumberRecognizer.new('0612345678')
@nc.should be_valid_or_correct
@nc.should be_valid_or_correct_mobile

@nc.type.should == 'Dutch mobile'
@nc.country.should == '31'
@nc.local_number.should == '612345678'
end

it 'should accept 0032412345678' do
@nc = NumberRecognizer.new('0032412345678')
@nc.should be_valid_or_correct_mobile

@nc.type.should == 'Belgian mobile'
@nc.country.should == '32'
@nc.local_number.should == '412345678'
end
end
end
end

0 comments on commit feab850

Please sign in to comment.