blob: 420233e1f39b2ada161105e530fbe4144c36d957 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
require_relative '../../spec_helper'
describe "MatchData#string" do
it "returns a copy of the match string" do
str = /(.)(.)(\d+)(\d)/.match("THX1138.").string
str.should == "THX1138."
end
it "returns a frozen copy of the match string" do
str = /(.)(.)(\d+)(\d)/.match("THX1138.").string
str.should == "THX1138."
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
'he[[o'.gsub!('[', ']')
$~.string.should == 'he[[o'
$~.string.should.frozen?
end
end
|