spec/regexp-examples_spec.rb in regexp-examples-0.2.4 vs spec/regexp-examples_spec.rb in regexp-examples-0.3.0

- old
+ new

@@ -19,10 +19,18 @@ expect{regexp.examples}.to raise_error RegexpExamples::IllegalSyntaxError end end end + def self.examples_raise_unsupported_syntax_error(*regexps) + regexps.each do |regexp| + it do + expect{regexp.examples}.to raise_error RegexpExamples::UnsupportedSyntaxError + end + end + end + context 'returns matching strings' do context "for basic repeaters" do examples_exist_and_match( /a/, /a*/, @@ -116,14 +124,42 @@ context "for illegal syntax" do examples_raise_illegal_syntax_error( /(?=lookahead)/, /(?!neglookahead)/, /(?<=lookbehind)/, - /(?<!neglookbehind)/ + /(?<!neglookbehind)/, + /\bword-boundary/, + /no\Bn-word-boundary/, + /\Glast-match/, + /start-of\A-string/, + /start-of^-line/, + /end-of\Z-string/, + /end-of\z-string/, + /end-of$-line/ ) end + context "ignore start/end anchors if at start/end" do + examples_exist_and_match( + /\Astart/, + /^start/, + /end$/, + /end\z/, + /end\Z/ + ) + end + + context "for unsupported syntax" do + examples_raise_unsupported_syntax_error( + /\p{L}/, + /\p{Arabic}/, + /\p{^Ll}/, + /(?<name> ... \g<name>*)/, + /[[:space:]]/ + ) + end + context "for control characters" do examples_exist_and_match( /\ca/, /\cZ/, /\c9/, @@ -145,10 +181,11 @@ end context "for unicode sequences" do examples_exist_and_match( /\u6829/, - /\uabcd/ + /\uabcd/, + /\u{42}word/ ) end end end