support nil charset

noticed nil failing when dropping the 772 fix into our mail parser project

@bf4 
extracted into a separate test case for clarity

On Sat, Nov 15, 2014 at 9:25 AM, Michael Grosser <grosser.michael@gmail.com>
wrote:

> The point of the test is to test against passing nil, no matter what the
> internal implementation is.
> The first part of the test is just to make sure the new encoding did not
> get added to ruby / we are actually doing work.
>
> On Sat, Nov 15, 2014 at 9:05 AM, Benjamin Fleischer <
> notifications@github.com> wrote:
>
>> In spec/mail/encoding_spec.rb:
>>
>> >        }.each do |from, to|
>> >          it "should support #{from}" do
>> > -          expect { ::Encoding.find(from) }.to raise_error(ArgumentError)
>> > +          expect { ::Encoding.find(from) }.to raise_error(ArgumentError) if from
>>
>> In the implementation you're casting nil.to_s. Encoding.find(nil) raises
>> a TypeError, but Encoding.find('') raises an ArgumentError. I'd argue
>> that since you're handling the nil case as empty string, your test should
>> be empty string, and thus you don't need to affix if from (which I
>> generally don't like at the end of long statements)
>>
>> —
>> Reply to this email directly or view it on GitHub
>> <https://github.com/mikel/mail/pull/831/files#r20403513>.
>>
>
>