Skip to content

Instantly share code, notes, and snippets.

@wrburgess
Created April 4, 2012 19:38
Show Gist options
  • Save wrburgess/2305010 to your computer and use it in GitHub Desktop.
Save wrburgess/2305010 to your computer and use it in GitHub Desktop.
refactoring
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
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