[rspec-users] [JRuby] simulating a java exception in a spec

Sidu Ponnappa ckponnappa at gmail.com
Tue Aug 23 13:29:02 EDT 2011


it 'adds validation exceptions raised by service to #errors' do
     ve = ValidationException #a java exception
     ve.stub(:localized_message).and_return('a bunch of errors')
    ....


Just clarifying, but did you mean
    ve = ValidationException.new


I tried replicating your spec but with java.lang.RuntimeException
instead of ValidationException and I got
   exception class/object expected

because raise expects an instance of the exception, not the exception
class. Am I missing something?

Best,
Sidu.
http://c42.in
http://blog.sidu.in



On 23 August 2011 03:20, Lenny Marks <lenny at aps.org> wrote:
> service.stub(:validateTaskForSave).and_raise(ve)


More information about the rspec-users mailing list