Saturday 15 February 2014

ruby on rails - Rspec stubbing results in Mocha errors -


after "text" itemprop = "text">

Not quite sure what's happening here. I am going to some code from some of my other projects and already the same specs are causing errors in the new project. All errors spin to call the stub method. Here is an example test:

  do this @ monitor.should_receive "Retrieve active workers from Redis" (? Monitor_running). And_return (wrong) REDIS.should_receive (: smembers) .with ('leaderboard -workers') .and_return ([]) @ monitor.perform end   

But if I do this To change the first test line:

  @ monitor.stub (: monitor_running?) And_return (wrong)   

I end up. The following error:

  1) LeaderboardMonitor # Performance Redis Failure / Error Recover Active Activists: @ monitor.stub (: monitor_running) and_return (wrong): ExpectationError:. Unexpected turnaround: # & LT; Mock: 0x7fcc18c8bab8 & gt; .and_return (false) Satisfied expectations: - How often have been allowed, still not applicable: # & LT; Mock: 0x7fcc18c8bab8 & gt; .monitor_running (any_parameters) # ./spec/workers/leaderboards/leaderboard_monitor_spec ?. RB: 58: `Block (level 3) & lt; Top (required) & gt;   

I'm pretty sure what's happening here is an overheating issue for the Moch Stub method? How do I work around this?!?!?

I do not know what version of Mocha you are using. Have you tried something

  @ monitor.expects (: Monitor-Arning?). Return (wrong) .at_least_once    

No comments:

Post a Comment