diff options
Diffstat (limited to 'spec/ruby/library/stringscanner/scan_full_spec.rb')
-rw-r--r-- | spec/ruby/library/stringscanner/scan_full_spec.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/ruby/library/stringscanner/scan_full_spec.rb b/spec/ruby/library/stringscanner/scan_full_spec.rb index ed34d7d3f6..967313f5ca 100644 --- a/spec/ruby/library/stringscanner/scan_full_spec.rb +++ b/spec/ruby/library/stringscanner/scan_full_spec.rb @@ -27,4 +27,18 @@ describe "StringScanner#scan_full" do @s.scan_full(/This/, true, true).should == "This" @s.pos.should == 4 end + + describe "#[] successive call with a capture group name" do + it "returns matched substring when matching succeeded" do + @s.scan_full(/(?<a>This)/, false, false) + @s.should.matched? + @s[:a].should == "This" + end + + it "returns nil when matching failed" do + @s.scan_full(/(?<a>2008)/, false, false) + @s.should_not.matched? + @s[:a].should be_nil + end + end end |