(#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
229 | 229 |
Facter.show_time "#{self.name}: #{"%.2f" % ms}ms"
|
230 | 230 |
|
231 | 231 |
unless @preserve_whitespace
|
232 | |
result.strip! if result && result.respond_to?(:strip!)
|
|
232 |
result = result.strip if result && result.respond_to?(:strip)
|
233 | 233 |
end
|
234 | 234 |
|
235 | 235 |
return nil if result == ""
|
170 | 170 |
it "should by default strip whitespace" do
|
171 | 171 |
@resolve.setcode {' value '}
|
172 | 172 |
@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'
|
173 | 180 |
end
|
174 | 181 |
|
175 | 182 |
describe "when given a string" do
|