spec/regexp-examples_spec.rb in regexp-examples-0.2.1 vs spec/regexp-examples_spec.rb in regexp-examples-0.2.2

- old
+ new

@@ -11,10 +11,18 @@ # /a|b/.examples to include "bad" end end end + def self.examples_raise_illegal_syntax_error(*regexps) + regexps.each do |regexp| + it do + expect{regexp.examples}.to raise_error RegexpExamples::IllegalSyntaxError + end + end + end + context 'returns matching strings' do context "for basic repeaters" do examples_exist_and_match( /a/, /a*/, @@ -57,16 +65,10 @@ /(normal)/, /(?:nocapture)/, /(?<name>namedgroup)/, /(?<name>namedgroup) \k<name>/ ) - # TODO: These are not yet implemented - # (expect to raise exception) -# /(?=lookahead)/, -# /(?!neglookahead)/, -# /(?<=lookbehind)/, -# /(?<!neglookbehind)/, end context "for escaped characters" do examples_exist_and_match( /\w/, @@ -105,9 +107,18 @@ /[\w]{1}/, /((a?b*c+)) \1/, /((a?b*c+)?) \1/, /a|b|c|d/, /a+|b*|c?/ + ) + end + + context "for illegal syntax" do + examples_raise_illegal_syntax_error( + /(?=lookahead)/, + /(?!neglookahead)/, + /(?<=lookbehind)/, + /(?<!neglookbehind)/ ) end end end