diff options
Diffstat (limited to 'spec/ruby/core/matchdata/string_spec.rb')
| -rw-r--r-- | spec/ruby/core/matchdata/string_spec.rb | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/spec/ruby/core/matchdata/string_spec.rb b/spec/ruby/core/matchdata/string_spec.rb index 793684d36a..50bbb5a64f 100644 --- a/spec/ruby/core/matchdata/string_spec.rb +++ b/spec/ruby/core/matchdata/string_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' describe "MatchData#string" do it "returns a copy of the match string" do @@ -9,6 +9,18 @@ describe "MatchData#string" do it "returns a frozen copy of the match string" do str = /(.)(.)(\d+)(\d)/.match("THX1138.").string str.should == "THX1138." - str.frozen?.should == true + str.should.frozen? + end + + it "returns the same frozen string for every call" do + md = /(.)(.)(\d+)(\d)/.match("THX1138.") + md.string.should.equal?(md.string) + end + + it "returns a frozen copy of the matched string for gsub!(String)" do + s = +'he[[o' + s.gsub!('[', ']') + $~.string.should == 'he[[o' + $~.string.should.frozen? end end |
