5 describe
'#original' do
6 it
"reports the string it was initialised with" do
7 test_label
= "Test label"
8 l1
= Label
.new test_label
9 l1
.original
.should
== test_label
13 describe
'#processed' do
14 it
"reports the original if no processing has been done" do
15 test_label
= "Test label"
16 l1
= Label
.new test_label
17 l1
.processed
.should
== [test_label
]
18 l1
.original
.should
== test_label
23 it
"splits the original on the specified regexp" do
24 l1
= Label
.new
"Test label"
26 l1
.processed
.should
== ["Test", "label"]
27 l1
.original
.should
== "Test label"
29 l1
= Label
.new
"Test_label"
31 l1
.processed
.should
== ["Test", "label"]
33 l1
= Label
.new
"Test label_string"
35 l1
.processed
.should
== ["Test", "label", "string"]
38 it
"splits the original on camel case" do
39 l1
= Label
.new
"TestLabel"
40 l1
.split
:camel_case => true
41 l1
.processed
.should
== ["Test", "Label"]
42 l1
.original
.should
== "TestLabel"
44 l2
= Label
.new
"testLabel"
45 l2
.split
:camel_case => true
46 l2
.processed
.should
== ["test", "Label"]
47 l2
.original
.should
== "testLabel"
50 it
"doesn't split the original on camel case if asked not to" do
51 l1
= Label
.new
"TestLabel"
52 l1
.split
:camel_case => false
53 l1
.processed
.should
== ["TestLabel"]
54 l1
.original
.should
== "TestLabel"
56 l2
= Label
.new
"TestLabel"
57 l2
.split
:camel_case => nil
58 l2
.processed
.should
== ["TestLabel"]
59 l2
.original
.should
== "TestLabel"
62 it
"splits the original using a default regexp" do
63 l1
= Label
.new
"Test label_string"
65 l1
.processed
.should
== ["Test", "label", "string"]
68 it
"splits the original on camel case by default" do
69 l1
= Label
.new
"TestLabel"
71 l1
.processed
.should
== ["Test", "Label"]
72 l1
.original
.should
== "TestLabel"
75 it
"splits the original on punctuation and camel case by default" do
76 l1
= Label
.new
"TestLabel is_split, he,said"
78 l1
.processed
.should
== ["Test", "Label", "is", "split", "he", "said"]
79 l1
.original
.should
== "TestLabel is_split, he,said"
83 l1
= Label
.new
"TestLabel is_split, he,said"
86 res1
.processed
.should
== res2
.processed
87 l1
.original
.should
== "TestLabel is_split, he,said"
91 describe
"#downcase" do
92 it
"downcases all parts of the processed label" do
93 l1
= Label
.new
"Test label_string"
95 l1
.processed
.should
== ["test", "label", "string"]
100 it
"stems all parts of the processed label" do
101 l1
= Label
.new
"testing labeller string pontificated"
103 l1
.processed
.should
== ["test", "label", "string", "pontif"]
108 it
"tidies a label" do
109 l1
= Label
.new
"testingLabeller string, he_pontificated"
110 l2
= Label
.new l1
.original
112 l2
.split
.downcase
.stem
113 l1
.processed
.should
== l2
.processed