views:

7

answers:

0

I would love to be able to test java code with rspec under jruby, but can't see how to set expectations on internal java method calls. Given the following java:

public class A {
  public String hi() {
    return hello();
  }

  public String hello() {
    return "yo";
  }
}

I would love to be able to do:

describe 'A' do
  it 'should call hello' do 
    a = some.java.package.A.new
    a.should_receive(:hello).and_return('yello')
    a.hi
  end
end

Is it possible to integrate a java mocking tool behind the scenes to do this? Has someone already done so? I don't care if I have to use different syntax to set the expectation (instead of rspec's 'should_receive'), but it should at least be concise.