Domanda

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

È stato utile?

Soluzione

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)
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top