summaryrefslogtreecommitdiff
path: root/spec/ruby/library/stringscanner/skip_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library/stringscanner/skip_spec.rb')
-rw-r--r--spec/ruby/library/stringscanner/skip_spec.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/ruby/library/stringscanner/skip_spec.rb b/spec/ruby/library/stringscanner/skip_spec.rb
index 473361782c..2b955b3172 100644
--- a/spec/ruby/library/stringscanner/skip_spec.rb
+++ b/spec/ruby/library/stringscanner/skip_spec.rb
@@ -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