spec/henkei_spec.rb in henkei-2.9.2.1 vs spec/henkei_spec.rb in henkei-2.9.2.2
- old
+ new
@@ -70,9 +70,29 @@
TEXT
end
end
end
end
+
+ context 'when a valid `encoding` value is provided' do
+ let(:encoding) { 'UTF-32' }
+
+ it 'returns the parsed text in the specified encoding' do
+ text = described_class.read :text, data, encoding: encoding
+
+ expect(text.encoding.name).to eq encoding
+ end
+ end
+
+ context 'when an invalid `encoding` value is provided' do
+ let(:encoding) { 'Beef' }
+
+ it 'raises an error' do
+ expect do
+ described_class.read :text, data, encoding: encoding
+ end.to raise_error(ArgumentError, "unsupported encoding - #{encoding}")
+ end
+ end
end
describe '.new' do
it 'requires parameters' do
expect { described_class.new }.to raise_error ArgumentError