Created
April 4, 2012 19:38
-
-
Save wrburgess/2305010 to your computer and use it in GitHub Desktop.
refactoring
This file contains hidden or 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
def process_mdn(mdn) | |
return "0" if mdn.nil? || mdn.length != 10 | |
unless mdn.nil? | |
mdn = mdn[1..-1] #remove the leading "1" | |
else | |
"0" | |
end | |
unless mdn.length != 10 | |
mdn | |
else | |
"0" | |
end | |
end |
This file contains hidden or 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 "process" do | |
it "returns a '0' when the mdn is nil" do | |
process_mdn(nil).should == "0" | |
process_mdn().should == "0" | |
end | |
it "returns '1234567890' when the mdn is '1234567890" do | |
mdn = '1234567890' | |
process_mdn(mdn).should == '1234567890' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment