Codebase list facter / fa38c60
(#14469) Strip whitespace from frozen strings In 1.9.3, strip! did not remove whitespace from frozen strings. Now using strip instead, this deals with frozen strings too, by making a copy of them. Hailee Kenney 11 years ago
2 changed file(s) with 8 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
229229 Facter.show_time "#{self.name}: #{"%.2f" % ms}ms"
230230
231231 unless @preserve_whitespace
232 result.strip! if result && result.respond_to?(:strip!)
232 result = result.strip if result && result.respond_to?(:strip)
233233 end
234234
235235 return nil if result == ""
170170 it "should by default strip whitespace" do
171171 @resolve.setcode {' value '}
172172 @resolve.value.should == 'value'
173 end
174
175 it "should strip whitespace from frozen strings" do
176 result = ' val ue '
177 result.freeze
178 @resolve.setcode{result}
179 @resolve.value.should == 'val ue'
173180 end
174181
175182 describe "when given a string" do