Skip to content

Commit 5ac0a59

Browse files
Lillian Zhangeregon
Lillian Zhang
authored andcommitted
Add specs for state following in place string scrub
1 parent 559c3f0 commit 5ac0a59

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

core/string/scrub_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,18 @@
105105
input.scrub! { |b| "<?>" }
106106
input.should == "a<?>"
107107
end
108+
109+
it "maintains the state of frozen strings that are already valid" do
110+
input = "a"
111+
input.freeze
112+
input.scrub!
113+
input.frozen?.should be_true
114+
end
115+
116+
it "preserves the instance variables of already valid strings" do
117+
input = "a"
118+
input.instance_variable_set(:@a, 'b')
119+
input.scrub!
120+
input.instance_variable_get(:@a).should == 'b'
121+
end
108122
end

0 commit comments

Comments
 (0)