This repository was archived by the owner on Nov 30, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +42
-1
lines changed
lib/rspec/core/formatters
spec/rspec/core/formatters Expand file tree Collapse file tree 2 files changed +42
-1
lines changed Original file line number Diff line number Diff line change @@ -86,7 +86,15 @@ def self.strip_trailing_zeroes(string)
86
86
# @param string [String] word to be pluralized
87
87
# @return [String] pluralized word
88
88
def self . pluralize ( count , string )
89
- "#{ count } #{ string } #{ 's' unless count . to_f == 1 } "
89
+ pluralized_string = if count . to_f == 1
90
+ string
91
+ elsif string . end_with? ( 's' ) # e.g. "process"
92
+ "#{ string } es" # e.g. "processes"
93
+ else
94
+ "#{ string } s"
95
+ end
96
+
97
+ "#{ count } #{ pluralized_string } "
90
98
end
91
99
92
100
# @api private
Original file line number Diff line number Diff line change 117
117
end
118
118
end
119
119
120
+ describe "pluralize" do
121
+ context "when word does not end in s" do
122
+ let ( :word ) { "second" }
123
+
124
+ it "pluralizes with 0" do
125
+ expect ( helper . pluralize ( 0 , "second" ) ) . to eq ( "0 seconds" )
126
+ end
127
+
128
+ it "does not pluralizes with 1" do
129
+ expect ( helper . pluralize ( 1 , "second" ) ) . to eq ( "1 second" )
130
+ end
131
+
132
+ it "pluralizes with 2" do
133
+ expect ( helper . pluralize ( 2 , "second" ) ) . to eq ( "2 seconds" )
134
+ end
135
+ end
136
+
137
+ context "when word ends in s" do
138
+ let ( :word ) { "process" }
139
+
140
+ it "pluralizes with 0" do
141
+ expect ( helper . pluralize ( 0 , "process" ) ) . to eq ( "0 processes" )
142
+ end
143
+
144
+ it "does not pluralizes with 1" do
145
+ expect ( helper . pluralize ( 1 , "process" ) ) . to eq ( "1 process" )
146
+ end
147
+
148
+ it "pluralizes with 2" do
149
+ expect ( helper . pluralize ( 2 , "process" ) ) . to eq ( "2 processes" )
150
+ end
151
+ end
152
+ end
120
153
121
154
end
You can’t perform that action at this time.
0 commit comments