This error message: it ''should'' do proc { eval("a=")}.should raise_exception(/SyntaxError/) end expected Exception with message matching /SyntaxError/, got #<SyntaxError: (eval):1: syntax error, unexpected end-of-file> Is a bit confusing, since it appears from the error output that it *does* match /SyntaxError/ Might be able to word it better or along those lines. Thanks! -roger- -- Posted via http://www.ruby-forum.com/.
On Aug 23, 2011, at 1:00 PM, Roger Pack wrote:> This error message: > > > it ''should'' do > proc { eval("a=")}.should raise_exception(/SyntaxError/) > end > > > expected Exception with message matching /SyntaxError/, got > #<SyntaxError: (eval):1: syntax error, unexpected end-of-file> > > Is a bit confusing, since it appears from the error output that it > *does* match /SyntaxError/ > > Might be able to word it better or along those lines. > Thanks! > -roger-Please report this to http://github.com/rspec/rspec-expectations/issues. Cheers, David
On Aug 23, 2011, at 3:16 PM, David Chelimsky wrote:> On Aug 23, 2011, at 1:00 PM, Roger Pack wrote: > >> This error message: >> >> >> it ''should'' do >> proc { eval("a=")}.should raise_exception(/SyntaxError/) >> endshouldn''t that be raise_exception(SyntaxError) that is, the exception class, not a Regexp literal to match its name.>> >> >> expected Exception with message matching /SyntaxError/, got >> #<SyntaxError: (eval):1: syntax error, unexpected end-of-file> >> >> Is a bit confusing, since it appears from the error output that it >> *does* match /SyntaxError/ >> >> Might be able to word it better or along those lines. >> Thanks! >> -roger- > > Please report this to http://github.com/rspec/rspec-expectations/issues > . > > Cheers, > David > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-usersRob Biedenharn Rob at AgileConsultingLLC.com http://AgileConsultingLLC.com/ rab at GaslightSoftware.com http://GaslightSoftware.com/
On Aug 23, 2011, at 3:26 PM, Rob Biedenharn wrote:> On Aug 23, 2011, at 3:16 PM, David Chelimsky wrote: > >> On Aug 23, 2011, at 1:00 PM, Roger Pack wrote: >> >>> This error message: >>> >>> >>> it ''should'' do >>> proc { eval("a=")}.should raise_exception(/SyntaxError/) >>> end > > shouldn''t that be > raise_exception(SyntaxError) > that is, the exception class, not a Regexp literal to match its name.It supports any of: raise_error(ErrorClass) raise_error(ErrorClass, string) raise_error(ErrorClass, /regex/) raise_error(string) raise_error(/regex/) (or raise_exception with the same set of alternatives) Cheers, David> >>> >>> >>> expected Exception with message matching /SyntaxError/, got >>> #<SyntaxError: (eval):1: syntax error, unexpected end-of-file> >>> >>> Is a bit confusing, since it appears from the error output that it >>> *does* match /SyntaxError/ >>> >>> Might be able to word it better or along those lines. >>> Thanks! >>> -roger- >> >> Please report this to http://github.com/rspec/rspec-expectations/issues. >> >> Cheers, >> David >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > Rob Biedenharn > Rob at AgileConsultingLLC.com http://AgileConsultingLLC.com/ > rab at GaslightSoftware.com http://GaslightSoftware.com/ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users
On Aug 23, 2011, at 5:18 PM, David Chelimsky wrote:> > On Aug 23, 2011, at 3:26 PM, Rob Biedenharn wrote: > >> On Aug 23, 2011, at 3:16 PM, David Chelimsky wrote: >> >>> On Aug 23, 2011, at 1:00 PM, Roger Pack wrote: >>> >>>> This error message: >>>> >>>> >>>> it ''should'' do >>>> proc { eval("a=")}.should raise_exception(/SyntaxError/) >>>> end >> >> shouldn''t that be >> raise_exception(SyntaxError) >> that is, the exception class, not a Regexp literal to match its name. > > It supports any of: > > raise_error(ErrorClass) > raise_error(ErrorClass, string) > raise_error(ErrorClass, /regex/) > raise_error(string) > raise_error(/regex/) > > (or raise_exception with the same set of alternatives) > > Cheers, > DavidRSpec 1.3 (from apidock) raise_exception(exception=Exception, message=nil, &block) public With no args, matches if any exception is raised. With a named exception, matches only if that specific exception is raised. With a named exception and messsage specified as a String, matches only if bothmatch. With a named exception and messsage specified as a Regexp, matches only if both match. Passan optional block to perform extra verifications on the exception matched Rspec 2 (from http://relishapp.com/rspec/rspec-expectations/docs/built-in-matchers/raise-error-matcher) only shows forms with either nothing specified, or the first argument is always the Exception class. If you use one of: raise_error(string) raise_error(/regex/) against what is the string or /regex/ matched? The message associated to the Exception or the NAME of the exception.>>>> expected Exception with message matching /SyntaxError/, got >>>> #<SyntaxError: (eval):1: syntax error, unexpected end-of-file> >>>> >>>> Is a bit confusing, since it appears from the error output that it >>>> *does* match /SyntaxError/The MESSAGE does not match /SyntaxError/ but it would have matched / syntax error/. I think that''s where the OP is confused. -Rob>>>> >>>> Might be able to word it better or along those lines. >>>> Thanks! >>>> -roger- >>> >>> Please report this to http://github.com/rspec/rspec-expectations/issues >>> . >>> >>> Cheers, >>> David >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >> >> Rob Biedenharn >> Rob at AgileConsultingLLC.com http://AgileConsultingLLC.com/ >> rab at GaslightSoftware.com http://GaslightSoftware.com/ >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-usersRob Biedenharn Rob at AgileConsultingLLC.com http://AgileConsultingLLC.com/ rab at GaslightSoftware.com http://GaslightSoftware.com/
On Aug 24, 2011, at 11:48 AM, Rob Biedenharn wrote:> > On Aug 23, 2011, at 5:18 PM, David Chelimsky wrote: > >> >> On Aug 23, 2011, at 3:26 PM, Rob Biedenharn wrote: >> >>> On Aug 23, 2011, at 3:16 PM, David Chelimsky wrote: >>> >>>> On Aug 23, 2011, at 1:00 PM, Roger Pack wrote: >>>> >>>>> This error message: >>>>> >>>>> >>>>> it ''should'' do >>>>> proc { eval("a=")}.should raise_exception(/SyntaxError/) >>>>> end >>> >>> shouldn''t that be >>> raise_exception(SyntaxError) >>> that is, the exception class, not a Regexp literal to match its name. >> >> It supports any of: >> >> raise_error(ErrorClass) >> raise_error(ErrorClass, string) >> raise_error(ErrorClass, /regex/) >> raise_error(string) >> raise_error(/regex/) >> >> (or raise_exception with the same set of alternatives) >> >> Cheers, >> David > > RSpec 1.3 (from apidock) > > raise_exception(exception=Exception, message=nil, &block) public > With no args, matches if any exception is raised. With a named exception, matches only if that specific exception is raised. With a named exception and messsage specified as a String, matches only if bothmatch. With a named exception and messsage specified as a Regexp, matches only if both match. Passan optional block to perform extra verifications on the exception matched > > > Rspec 2 (from http://relishapp.com/rspec/rspec-expectations/docs/built-in-matchers/raise-error-matcher) > > only shows forms with either nothing specified, or the first argument is always the Exception class. > > If you use one of: > raise_error(string) > raise_error(/regex/) > against what is the string or /regex/ matched? The message associated to the Exception or the NAME of the exception. > >>>>> expected Exception with message matching /SyntaxError/, got >>>>> #<SyntaxError: (eval):1: syntax error, unexpected end-of-file> >>>>> >>>>> Is a bit confusing, since it appears from the error output that it >>>>> *does* match /SyntaxError/ > > The MESSAGE does not match /SyntaxError/ but it would have matched /syntax error/. > > I think that''s where the OP is confused. > > -RobI beefed up the doc: https://github.com/rspec/rspec-expectations/blob/a541a7523ef282b9bf96141f5b8a0920dda55281/features/built_in_matchers/expect_error.feature#L18-23. Relish requires pushing all the docs at once and I have no way of knowing what the last commit was that I pushed (so I can''t really push the current docs or roll back to the last release and patch them). So this won''t make it to the relish site today, but will as soon as I can get a release out. Cheers, David>>>>> Might be able to word it better or along those lines. >>>>> Thanks! >>>>> -roger- >>>> >>>> Please report this to http://github.com/rspec/rspec-expectations/issues. >>>> >>>> Cheers, >>>> David