require File.expand_path(File.dirname(__FILE__) + '../../spec_helper') module Owasp module Esapi module Validator describe StringRule do let(:rule) {Owasp::Esapi::Validator::StringRule.new("test")} # We will reset teh rule before every test so previous white/blacklist entries dont affect the other # test begin executed before(:all) { @@rule = Owasp::Esapi::Validator::StringRule.new("test")} describe "Pattern rules" do it "should fail to add a nil white list rule" do lambda { rule.add_whitelist(nil)}.should raise_error(ArgumentError) end it "should fail with an invalid regex" do lambda { rule.add_whitelist("_][0}[")}.should raise_error(RegexpError) end it "should fail to add a nil black list rule" do lambda { rule.add_blacklist(nil)}.should raise_error(ArgumentError) end it "should fail with an invalid regex" do lambda { rule.add_blacklist("_][0}[")}.should raise_error(RegexpError) end it "should reject beg