diff options
Diffstat (limited to 'spec/ruby/library/stringscanner/beginning_of_line_spec.rb')
| -rw-r--r-- | spec/ruby/library/stringscanner/beginning_of_line_spec.rb | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/spec/ruby/library/stringscanner/beginning_of_line_spec.rb b/spec/ruby/library/stringscanner/beginning_of_line_spec.rb index 192a83f2c9..ae97f52fe0 100644 --- a/spec/ruby/library/stringscanner/beginning_of_line_spec.rb +++ b/spec/ruby/library/stringscanner/beginning_of_line_spec.rb @@ -1,7 +1,28 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../shared/bol.rb', __FILE__) +require_relative '../../spec_helper' require 'strscan' describe "StringScanner#beginning_of_line?" do - it_behaves_like(:strscan_bol, :beginning_of_line?) + it "returns true if the scan pointer is at the beginning of the line, false otherwise" do + s = StringScanner.new("This is a test") + s.beginning_of_line?.should == true + s.scan(/This/) + s.beginning_of_line?.should == false + s.terminate + s.beginning_of_line?.should == false + + s = StringScanner.new("hello\nworld") + s.beginning_of_line?.should == true + s.scan(/\w+/) + s.beginning_of_line?.should == false + s.scan(/\n/) + s.beginning_of_line?.should == true + s.unscan + s.beginning_of_line?.should == false + end + + it "returns true if the scan pointer is at the end of the line of an empty string." do + s = StringScanner.new('') + s.terminate + s.beginning_of_line?.should == true + end end |
