-
Notifications
You must be signed in to change notification settings - Fork 927
/
keywords_field_spec.rb
60 lines (46 loc) · 2.15 KB
/
keywords_field_spec.rb
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
# encoding: utf-8
require File.dirname(__FILE__) + '/../../spec_helper'
describe Mail::KeywordsField do
describe "initializing" do
it "should initialize" do
doing { Mail::KeywordsField.new("this, is, email") }.should_not raise_error
end
it "should accept two strings with the field separate" do
k = Mail::KeywordsField.new('Keywords', 'these are keywords, so there')
k.name.should == 'Keywords'
k.value.should == 'these are keywords, so there'
end
it "should accept a string with the field name" do
k = Mail::KeywordsField.new('Keywords: these are keywords, so there')
k.name.should == 'Keywords'
k.value.should == 'these are keywords, so there'
end
it "should accept a string with the field name" do
k = Mail::KeywordsField.new('these are keywords, so there')
k.name.should == 'Keywords'
k.value.should == 'these are keywords, so there'
end
end
describe "giving a list of keywords" do
it "should return a list of keywords" do
k = Mail::KeywordsField.new('these are keywords, so there')
k.keywords.should == ['these are keywords', 'so there']
end
it "should handle phrases" do
k = Mail::KeywordsField.new('"these, are keywords", so there')
k.keywords.should == ['these, are keywords', 'so there']
end
it "should handle comments" do
k = Mail::KeywordsField.new('"these, are keywords", so there (This is an irrelevant comment)')
k.keywords.should == ['these, are keywords', 'so there (This is an irrelevant comment)']
end
it "should handle comments" do
k = Mail::KeywordsField.new('"these, are keywords", so there (This is an irrelevant comment)')
k.keywords.should == ['these, are keywords', 'so there (This is an irrelevant comment)']
end
it "should handle comments in quotes" do
k = Mail::KeywordsField.new('"these, are keywords (another comment to be ignored)", so there (This is an irrelevant comment)')
k.keywords.should == ['these, are keywords (another comment to be ignored)', 'so there (This is an irrelevant comment)']
end
end
end