[英]__persistence__ NoMethodError
I'm mocking a java interface in rspec 我在rspec中模拟了Java接口
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 当我运行rspec时,一切正常,但是我看到一条警告,将我引导至以下位置
https://github.com/jruby/jruby/wiki/Persistence https://github.com/jruby/jruby/wiki/Persistence
When I attempt to set 当我尝试设定
ClockInterface.__persistence__ = true
I get a NoMethodError. 我收到一个NoMethodError。 I'm using jruby 1.7.4 我正在使用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. ClockInterface
是接口而不是类,并且不具有__persistent__
方法,这不同于通过代理为其添加该方法的类。
To get your test to work properly, you should instead use: 为了使测试正常工作,您应该使用:
clock = mock(ClockInterface)
clock.should_receive(:currentTime)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.