From 67a1e2258974df4b597d019739595c18fbb9a7c1 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Mon, 29 Nov 2021 15:50:28 +0100 Subject: Update to ruby/spec@7f22a0b --- .../ruby/library/stringscanner/matched_size_spec.rb | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'spec/ruby/library/stringscanner/matched_size_spec.rb') diff --git a/spec/ruby/library/stringscanner/matched_size_spec.rb b/spec/ruby/library/stringscanner/matched_size_spec.rb index a36bd3aafe..d9c338a07e 100644 --- a/spec/ruby/library/stringscanner/matched_size_spec.rb +++ b/spec/ruby/library/stringscanner/matched_size_spec.rb @@ -1,7 +1,24 @@ require_relative '../../spec_helper' -require_relative 'shared/matched_size' require 'strscan' describe "StringScanner#matched_size" do - it_behaves_like :strscan_matched_size, :matched_size + before :each do + @s = StringScanner.new("This is a test") + end + + it "returns the size of the most recent match" do + @s.check(/This/) + @s.matched_size.should == 4 + @s.matched_size.should == 4 + @s.scan(//) + @s.matched_size.should == 0 + end + + it "returns nil if there was no recent match" do + @s.matched_size.should == nil + @s.check(/\d+/) + @s.matched_size.should == nil + @s.terminate + @s.matched_size.should == nil + end end -- cgit v1.2.3