spec/extensions/regexp_spec.rb in ronin-support-0.4.1 vs spec/extensions/regexp_spec.rb in ronin-support-0.5.0.rc1

- old
+ new

@@ -1,9 +1,41 @@ require 'spec_helper' require 'ronin/extensions/regexp' describe Regexp do + describe "WORD" do + let(:word) { 'dog' } + + subject { Regexp::WORD } + + it "should not match single letters" do + subject.match('A').should be_nil + end + + it "should not match numeric letters" do + subject.match("123#{word}123")[0].should == word + end + + it "should not include ending periods" do + subject.match("#{word}.")[0].should == word + end + + it "should not include leading punctuation" do + subject.match("'#{word}")[0].should == word + end + + it "should not include tailing punctuation" do + subject.match("#{word}'")[0].should == word + end + + it "should include punctuation in the middle of the word" do + name = "O'Brian" + + subject.match(name)[0].should == name + end + end + describe "OCTET" do subject { Regexp::OCTET } it "should match 0 - 255" do (0..255).all? { |n| @@ -167,9 +199,37 @@ it "should match valid email addresses" do email = 'alice@example.com' subject.match(email)[0].should == email + end + end + + describe "PHONE_NUMBER" do + subject { Regexp::PHONE_NUMBER } + + it "should match 111-2222" do + number = '111-2222' + + subject.match(number)[0].should == number + end + + it "should match 111-2222x9" do + number = '111-2222x9' + + subject.match(number)[0].should == number + end + + it "should match 800-111-2222" do + number = '800-111-2222' + + subject.match(number)[0].should == number + end + + it "should match 1-800-111-2222" do + number = '1-800-111-2222' + + subject.match(number)[0].should == number end end describe "IDENTIFIER" do subject { Regexp::IDENTIFIER }