[rspec-users] [JRuby] simulating a java exception in a spec
ckponnappa at gmail.com
Tue Aug 23 14:43:11 EDT 2011
Please ignore my previous question - I just realised you're doing
Java::java.lang.NullPointerException.new in your second example. I'm
seeing the same behaviour and can't think of any way around it off the
top of my head.
You could try redefining Java::JavaLang::NullPointerException to be a
Ruby RuntimeError within the scope of your spec but I'm not sure how
this will work (if at all) when Java::JavaLang::NullPointerException
is raised from native code.
On 23 August 2011 22:59, Sidu Ponnappa <ckponnappa at gmail.com> wrote:
> 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?
> On 23 August 2011 03:20, Lenny Marks <lenny at aps.org> wrote:
More information about the rspec-users