Sha256: 6cd8551076fbbcfa6c2a91bacee12fa0491c7e4d00abdd9b93be04194172fb20

Contents?: true

Size: 513 Bytes

Versions: 3

Compression:

Stored size: 513 Bytes

Contents

require 'strscan'

describe "StringScanner#scan_until" do
  before :each do
    @s = StringScanner.new("This is a test")
  end

  it "returns the substring up to and including the end of the match" do
   @s.scan_until(/a/).should == "This is a"
   @s.pre_match.should == "This is "
   @s.post_match.should == " test"
  end

  it "returns nil if there's no match" do
    @s.scan_until(/\d/).should == nil
  end

  it "can match anchors properly" do
    @s.scan(/T/)
    @s.scan_until(/^h/).should == "h"
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rubysl-strscan-1.0.1 spec/scan_until_spec.rb
rubysl-strscan-1.0.0 spec/scan_until_spec.rb
rubysl-strscan-2.0.0 spec/scan_until_spec.rb