diff options
Diffstat (limited to 'spec/ruby/library/stringscanner/skip_spec.rb')
| -rw-r--r-- | spec/ruby/library/stringscanner/skip_spec.rb | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/spec/ruby/library/stringscanner/skip_spec.rb b/spec/ruby/library/stringscanner/skip_spec.rb index 7426267b6e..2b955b3172 100644 --- a/spec/ruby/library/stringscanner/skip_spec.rb +++ b/spec/ruby/library/stringscanner/skip_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' require 'strscan' describe "StringScanner#skip" do @@ -15,4 +15,18 @@ describe "StringScanner#skip" do @s.skip(/\s+/).should == nil @s.skip(/\d+/).should == nil end + + describe "#[] successive call with a capture group name" do + it "returns matched substring when matching succeeded" do + @s.skip(/(?<a>This)/) + @s.should.matched? + @s[:a].should == "This" + end + + it "returns nil when matching failed" do + @s.skip(/(?<a>2008)/) + @s.should_not.matched? + @s[:a].should == nil + end + end end |
