aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby/library/stringscanner/check_spec.rb
blob: db98197f81ee29a3dda4629132deaab1ec7312b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
require File.expand_path('../../../spec_helper', __FILE__)
require 'strscan'

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

  it "returns the value that scan would return, without advancing the scan pointer" do
    @s.check(/This/).should == "This"
    @s.matched.should == "This"
    @s.pos.should == 0
    @s.check(/is/).should == nil
    @s.matched.should == nil
  end
end