summaryrefslogtreecommitdiff
path: root/spec/ruby/core/matchdata/to_s_spec.rb
blob: aab0955ae19fab16da5ef1aebfd501e67302fa2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
require_relative '../../spec_helper'
require_relative 'fixtures/classes'

describe "MatchData#to_s" do
  it "returns the entire matched string" do
    /(.)(.)(\d+)(\d)/.match("THX1138.").to_s.should == "HX1138"
  end

  ruby_version_is "3.0" do
    it "returns an instance of String when given a String subclass" do
      str = MatchDataSpecs::MyString.new("THX1138.")
      /(.)(.)(\d+)(\d)/.match(str).to_s.should be_an_instance_of(String)
    end
  end
end