File: message_ids_element_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 (44 lines) | stat: -rw-r--r-- 1,569 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
# frozen_string_literal: true
require 'spec_helper'

describe Mail::MessageIdsElement do

  it "should parse a message_id" do
    msg_id_text  = '<1234@test.lindsaar.net>'
    expect { Mail::MessageIdsElement.new(msg_id_text) }.not_to raise_error
  end

  it "should parse multiple message_ids" do
    msg_id_text  = '<1234@test.lindsaar.net> <1234@test.lindsaar.net>'
    expect { Mail::MessageIdsElement.new(msg_id_text) }.not_to raise_error
  end

  it "should raise an error if the input is useless" do
    msg_id_text = nil
    expect { Mail::MessageIdsElement.new(msg_id_text) }.to raise_error(Mail::Field::ParseError)
  end

  it "should raise an error if the input is useless" do
    msg_id_text  = '""""""""""""""""'
    expect { Mail::MessageIdsElement.new(msg_id_text) }.to raise_error(Mail::Field::ParseError)
  end

  it "should respond to message_ids" do
    msg_id_text  = '<1234@test.lindsaar.net> <1234@test.lindsaar.net>'
    msg_ids = Mail::MessageIdsElement.new(msg_id_text)
    expect(msg_ids.message_ids).to eq ['1234@test.lindsaar.net', '1234@test.lindsaar.net']
  end

  it "should respond to message_id" do
    msg_id_text  = '<1234@test.lindsaar.net>'
    msg_ids = Mail::MessageIdsElement.new(msg_id_text)
    expect(msg_ids.message_id).to eq '1234@test.lindsaar.net'
  end

  it "should not fail to parse a message id with dots in it" do
    text = "<4afb664ca3078_48dc..fdbe32b865532b@ax-desktop.mail>"
    m = Mail::MessageIdsElement.new(text)
    expect(m.message_id).to eq "4afb664ca3078_48dc..fdbe32b865532b@ax-desktop.mail"
  end

end