File: content_transfer_encoding_parser_spec.rb

package info (click to toggle)
ruby-mail 2.6.4%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 4,256 kB
  • ctags: 1,327
  • sloc: ruby: 44,678; makefile: 3
file content (63 lines) | stat: -rw-r--r-- 1,996 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'

describe "ContentTransferEncodingParser" do

  it "should work" do
    text = "quoted-printable"
    a = Mail::Parsers::ContentTransferEncodingParser.new
    expect(a.parse(text).error).to be_nil
    expect(a.parse(text).encoding).to eq 'quoted-printable'
  end

  describe "trailing semi colons" do

    it "should parse" do
      text = "quoted-printable;"
      a = Mail::Parsers::ContentTransferEncodingParser.new
      expect(a.parse(text).error).to be_nil
      expect(a.parse(text).encoding).to eq 'quoted-printable'
    end

    it "should parse with pre white space" do
      text = 'quoted-printable  ;'
      a = Mail::Parsers::ContentTransferEncodingParser.new
      expect(a.parse(text).error).to be_nil
      expect(a.parse(text).encoding).to eq 'quoted-printable'
    end

    it "should parse with trailing white space" do
      text = 'quoted-printable; '
      a = Mail::Parsers::ContentTransferEncodingParser.new
      expect(a.parse(text).error).to be_nil
      expect(a.parse(text).encoding).to eq 'quoted-printable'
    end

    it "should parse with pre and trailing white space" do
      text = 'quoted-printable  ;  '
      a = Mail::Parsers::ContentTransferEncodingParser.new
      expect(a.parse(text).error).to be_nil
      expect(a.parse(text).encoding).to eq 'quoted-printable'
    end
  end

  describe "x-token values" do
    it "should work" do
      text = 'x-my-token'
      a = Mail::Parsers::ContentTransferEncodingParser.new
      expect(a.parse(text).error).to be_nil
      expect(a.parse(text).encoding).to eq 'x-my-token'
    end
  end

  describe "wild content-transfer-encoding" do
    %w(7bits 8bits 7-bit 8-bit).each do |mechanism|
      it "should parse #{mechanism} variant" do
        a = Mail::Parsers::ContentTransferEncodingParser.new
        expect(a.parse(mechanism).error).to be_nil
        expect(a.parse(mechanism).encoding).to eq mechanism
      end
    end
  end
end