blob: db55a1b1863d3cea356a3b542ee2a3034d4b8c45 (
plain)
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
require 'spec_helper'
require 'mspec/runner/tag'
describe SpecTag do
it "accepts an optional string to parse into fields" do
tag = SpecTag.new "tag(comment):description"
tag.tag.should == "tag"
tag.comment.should == "comment"
tag.description.should == "description"
end
end
describe SpecTag, "#parse" do
before :each do
@tag = SpecTag.new
end
it "accepts 'tag(comment):description'" do
@tag.parse "tag(I'm real):Some#method returns a value"
@tag.tag.should == "tag"
@tag.comment.should == "I'm real"
@tag.description.should == "Some#method returns a value"
end
it "accepts 'tag:description'" do
@tag.parse "tag:Another#method"
@tag.tag.should == "tag"
@tag.comment.should == nil
@tag.description.should == "Another#method"
end
it "accepts 'tag():description'" do
@tag.parse "tag():Another#method"
@tag.tag.should == "tag"
@tag.comment.should == nil
@tag.description.should == "Another#method"
end
it "accepts 'tag:'" do
@tag.parse "tag:"
@tag.tag.should == "tag"
@tag.comment.should == nil
@tag.description.should == ""
end
it "accepts 'tag(bug:555):Another#method'" do
@tag.parse "tag(bug:555):Another#method"
@tag.tag.should == "tag"
@tag.comment.should == "bug:555"
@tag.description.should == "Another#method"
end
it "accepts 'tag(http://someplace.com/neato):Another#method'" do
@tag.parse "tag(http://someplace.com/neato):Another#method"
@tag.tag.should == "tag"
@tag.comment.should == "http://someplace.com/neato"
@tag.description.should == "Another#method"
end
it "accepts 'tag(comment):\"Multi-line\\ntext\"'" do
@tag.parse 'tag(comment):"Multi-line\ntext"'
@tag.tag.should == "tag"
@tag.comment.should == "comment"
@tag.description.should == "Multi-line\ntext"
end
it "ignores '#anything'" do
@tag.parse "# this could be a comment"
@tag.tag.should == nil
@tag.comment.should == nil
@tag.description.should == nil
end
end
describe SpecTag, "#to_s" do
it "formats itself as 'tag(comment):description'" do
txt = "tag(comment):description"
tag = SpecTag.new txt
tag.tag.should == "tag"
tag.comment.should == "comment"
tag.description.should == "description"
tag.to_s.should == txt
end
it "formats itself as 'tag:description" do
txt = "tag:description"
tag = SpecTag.new txt
tag.tag.should == "tag"
tag.comment.should == nil
tag.description.should == "description"
tag.to_s.should == txt
end
it "formats itself as 'tag(comment):\"multi-line\\ntext\\ntag\"'" do
txt = 'tag(comment):"multi-line\ntext\ntag"'
tag = SpecTag.new txt
tag.tag.should == "tag"
tag.comment.should == "comment"
tag.description.should == "multi-line\ntext\ntag"
tag.to_s.should == txt
end
end
describe SpecTag, "#==" do
it "returns true if the tags have the same fields" do
one = SpecTag.new "tag(this):unicorn"
two = SpecTag.new "tag(this):unicorn"
one.==(two).should == true
[one].==([two]).should == true
end
end
describe SpecTag, "#unescape" do
it "replaces \\n by LF when the description is quoted" do
tag = SpecTag.new 'tag:"desc with\nnew line"'
tag.description.should == "desc with\nnew line"
end
it "does not replaces \\n by LF when the description is not quoted " do
tag = SpecTag.new 'tag:desc with\nnew line'
tag.description.should == "desc with\\nnew line"
end
end
|