diff options
Diffstat (limited to 'spec/ruby/core/regexp/last_match_spec.rb')
-rw-r--r-- | spec/ruby/core/regexp/last_match_spec.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/ruby/core/regexp/last_match_spec.rb b/spec/ruby/core/regexp/last_match_spec.rb new file mode 100644 index 0000000000..4673554f91 --- /dev/null +++ b/spec/ruby/core/regexp/last_match_spec.rb @@ -0,0 +1,14 @@ +require File.expand_path('../../../spec_helper', __FILE__) + +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 |