summaryrefslogtreecommitdiff
path: root/spec/ruby/core/regexp/last_match_spec.rb
blob: ed496b7941127d616e2fe51eef5b270c73fc33a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
require_relative '../../spec_helper'

describe "Regexp.last_match" do
  it "returns MatchData instance when not passed arguments" do
    /c(.)t/ =~ 'cat'

    Regexp.last_match.should be_kind_of(MatchData)
  end

  it "returns the nth field in this MatchData when passed a Fixnum" do
    /c(.)t/ =~ 'cat'
    Regexp.last_match(1).should == 'a'
  end
end