File: resent_date_field_spec.rb

package info (click to toggle)
ruby-mail 2.6.1%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 4,092 kB
  • ctags: 1,281
  • sloc: ruby: 43,919; makefile: 2
file content (39 lines) | stat: -rw-r--r-- 1,316 bytes parent folder | download | duplicates (2)
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
# encoding: utf-8
require 'spec_helper'

describe Mail::ResentDateField do
  it "should initialize" do
    doing { Mail::ResentDateField.new("12 Aug 2009 00:00:02 GMT") }.should_not raise_error
  end
  
  it "should be able to tell the time" do
    Mail::ResentDateField.new("12 Aug 2009 00:00:02 GMT").date_time.class.should eq DateTime
  end
  
  it "should mix in the CommonAddress module" do
    Mail::ResentDateField.included_modules.should include(Mail::CommonDate) 
  end

  it "should accept a string with the field name" do
    t = Mail::ResentDateField.new('Resent-Date: 12 Aug 2009 00:00:02 GMT')
    t.name.should eq 'Resent-Date'
    t.value.should eq 'Wed, 12 Aug 2009 00:00:02 +0000'
    t.date_time.should eq ::DateTime.parse('12 Aug 2009 00:00:02 GMT')
  end
  
  it "should accept a string without the field name" do
    t = Mail::ResentDateField.new('12 Aug 2009 00:00:02 GMT')
    t.name.should eq 'Resent-Date'
    t.value.should eq 'Wed, 12 Aug 2009 00:00:02 +0000'
    t.date_time.should eq ::DateTime.parse('12 Aug 2009 00:00:02 GMT')
  end
  
  it "should give today's date if no date is specified" do
    now = Time.now
    Time.stub!(:now).and_return(now)
    t = Mail::ResentDateField.new
    t.name.should eq 'Resent-Date'
    t.date_time.should eq ::DateTime.parse(now.to_s)
  end

end