문제

I'm mocking a java interface in rspec

clock = ClockInterface.new
clock.should_receive(:currentTime)

When I run rspec everything works fine but I see a warning which directs me to the following

https://github.com/jruby/jruby/wiki/Persistence

When I attempt to set

ClockInterface.__persistence__ = true

I get a NoMethodError. I'm using jruby 1.7.4

도움이 되었습니까?

해결책

ClockInterface is an interface rather than a class, and doesn’t have the __persistent__ method, unlike classes for which that method gets added through their proxy.

To get your test to work properly, you should instead use:

clock = mock(ClockInterface)
clock.should_receive(:currentTime)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top