diff options
Diffstat (limited to 'spec/ruby/library/stringscanner/skip_spec.rb')
-rw-r--r-- | spec/ruby/library/stringscanner/skip_spec.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/ruby/library/stringscanner/skip_spec.rb b/spec/ruby/library/stringscanner/skip_spec.rb new file mode 100644 index 0000000000..7426267b6e --- /dev/null +++ b/spec/ruby/library/stringscanner/skip_spec.rb @@ -0,0 +1,18 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'strscan' + +describe "StringScanner#skip" do + before :each do + @s = StringScanner.new("This is a test") + end + + it "returns length of the match" do + @s.skip(/\w+/).should == 4 + @s.skip(/\s+\w+/).should == 3 + end + + it "returns nil if there's no match" do + @s.skip(/\s+/).should == nil + @s.skip(/\d+/).should == nil + end +end |