-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsyllablecount_spec.rb
More file actions
119 lines (106 loc) · 2.54 KB
/
syllablecount_spec.rb
File metadata and controls
119 lines (106 loc) · 2.54 KB
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
# Written by Elisabeth Hendrickson, Quality Tree Software, Inc.
# Copyright (c) 2009 Quality Tree Software, Inc.
#
# This work is licensed under the
# Creative Commons Attribution 3.0 United States License.
#
# To view a copy of this license, visit
# http://creativecommons.org/licenses/by/3.0/us/
require 'rubygems'
require 'spec'
require 'syllablecount'
describe "Syllable counter" do
# school worksheet tests from http://www.superteacherworksheets.com/syllables/syllables6.pdf
# thanks to Al Snow for the suggestion (score out of the box: 19/20 => "A" :-))
school_worksheet_examples = {
"animal" => 3,
"anything" => 3,
# "somebody" => 3, NEED TO FIX
"grandfather" => 3,
"comedy" => 3,
"January" => 4,
"computer" => 3,
"table" => 2,
"summer" => 2,
"duet" => 2,
"purchase" => 2,
"understand" => 3,
"beautiful" => 3,
"wonderful" => 3,
"customer" => 3,
"exercise" => 3,
"symbol" => 2,
"travel" => 2,
"picture" => 2,
"confirm" => 2
}
school_worksheet_examples.each { |word, sylcount|
it "knows that '#{word}' has #{sylcount} syllable" do
word.syllable_count.should equal(sylcount)
end
}
interesting_one_syllable_word_examples = [
"at",
"bat",
"each",
"tea",
"bail",
"bart",
"quick",
"slow",
"quote",
"quest",
"the",
"dressed",
"ed",
"loved",
"arched",
"been",
"book"
]
interesting_one_syllable_word_examples.each { |word|
it "knows that '#{word}' has one syllable" do
word.syllable_count.should equal(1)
end
}
two_syllable_word_examples = [
"slowly",
"able",
"lightning",
"pluot",
"little",
"ably",
"bureau",
"received",
"alight"
]
two_syllable_word_examples.each { |word|
it "knows that '#{word}' has two syllables" do
word.syllable_count.should equal(2)
end
}
three_syllable_word_examples = [
"syllable",
"aspiring",
"plaintively",
"question",
"beautiful",
"ambitious"
]
three_syllable_word_examples.each { |word|
it "knows that '#{word}' has three syllables" do
word.syllable_count.should equal(3)
end
}
four_syllable_word_examples = [
"continuous"
]
four_syllable_word_examples.each { |word|
it "knows that '#{word}' has four syllables" do
word.syllable_count.should equal(4)
end
}
it "can count a line from a haiku" do
"dripping drops of rain".syllable_count.should equal(5)
end
end