jim/carmen — pull request #98 by thrillcall (2012-07-10 00:54:20+00:00)
Title: 0.2.x Branch : BugFix w/ Tests : Carmen::state_code should not return 'AL' when 'MA' is passed as arg.

If you happen to pass a state code (as opposed to the expected state name) to the Carmen::state_code method it will now return the very same state code. Previously it would return a non-sensical result when it was doing a regex match on the state name.

e.g. Carmen::state_code('MA') => 'AL'

^ since 'al' was a regex match against 'ALabama' in the list of state names.

e.g. Carmen::state_code('WA') => 'DE'

^ since 'wa' was a regex match against 'DelaWAre' in the list of state names.

Added a failing test which now works. All other tests still pass.

We needed this since we are trying to handle some dirty data where there are cases when we are given a state code in a field intended to be a state name. Now it will work for both cases.

Also fixed an incorrect comment.