aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby/core/exception/destination_encoding_spec.rb
blob: 5709c31e55a6e290e625064d1c9714afaaa792e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
require_relative '../../spec_helper'

describe "Encoding::UndefinedConversionError#destination_encoding" do
  it "returns the destination encoding" do
    ec = Encoding::Converter.new("ISO-8859-1", "EUC-JP")
    begin
      ec.convert("\xa0")
    rescue Encoding::UndefinedConversionError => e
      e.destination_encoding.should == Encoding::EUC_JP
    end
  end
end

describe "Encoding::InvalidByteSequenceError#destination_encoding" do
  it "returns the destination encoding" do
    ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
    begin
      ec.convert("\xa0")
    rescue Encoding::InvalidByteSequenceError => e
      e.destination_encoding.should == Encoding::UTF_8
    end
  end
end