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

describe Mail::FieldList do
  it "should be able to add new fields" do
    fl = Mail::FieldList.new
    fl << Mail::Field.new("To: mikel@me.com")
    fl << Mail::Field.new("From: mikel@me.com")
    expect(fl.length).to eq 2
  end
  
  it "should be able to add new fields in the right order" do
    fl = Mail::FieldList.new
    fl << Mail::Field.new("To: mikel@me.com")
    fl << Mail::Field.new("From: mikel@me.com")
    fl << Mail::Field.new("Received: from xxx.xxxx.xxx by xxx.xxxx.xxx with ESMTP id 6AAEE3B4D23 for <xxx@xxxx.xxx>; Sun, 8 May 2005 12:30:23 -0500")
    fl << Mail::Field.new("Return-Path: mikel@me.com")
    expect(fl[0].field.class).to eq Mail::ReturnPathField
    expect(fl[1].field.class).to eq Mail::ReceivedField
    expect(fl[2].field.class).to eq Mail::FromField
    expect(fl[3].field.class).to eq Mail::ToField
  end
  
  it "should add new Received items after the existing ones" do
    fl = Mail::FieldList.new
    fl << Mail::Field.new("To: mikel@me.com")
    fl << Mail::Field.new("From: mikel@me.com")
    fl << Mail::Field.new("Received: from xxx.xxxx.xxx by xxx.xxxx.xxx with ESMTP id 6AAEE3B4D23 for <xxx@xxxx.xxx>; Sun, 8 May 2005 12:30:23 -0500")
    fl << Mail::Field.new("Return-Path: mikel@me.com")
    fl << Mail::Field.new("Received: from 123.xxxx.xxx by xxx.xxxx.xxx with ESMTP id 6AAEE3B4D23 for <xxx@xxxx.xxx>; Sun, 8 May 2005 12:30:23 -0500")
    expect(fl[2].field.value).to eq 'from 123.xxxx.xxx by xxx.xxxx.xxx with ESMTP id 6AAEE3B4D23 for <xxx@xxxx.xxx>; Sun, 8 May 2005 12:30:23 -0500'
  end
  
end