You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a tree structure and wrote a method crawl that takes a block. For each node in the tree, it will call the block passing it the node, the node's parent, and the level. I'm trying to write a test for this method and have the following.
And I got the same failure. I tried placing a binding.pry inside the with block and verified that the node == subject && parent == nil && level == 0 statement returns true.
What am I doing wrong?
The text was updated successfully, but these errors were encountered:
When a method is invoked on a mock object, the mock object searches through its expectations from newest to oldest to find one that matches the invocation. After the invocation, the matching expectation might stop matching further invocations.
if you create an expectation and then a stub for the same method, the stub will always override the expectation and the expectation will never be met.
In your case, the stub is the newest and so matches before the expectation. And since it's a stub with no expected invocation count the matching will never be exhausted. So the expectation will never be invoked and thus is never satisfied.
I have a tree structure and wrote a method
crawl
that takes a block. For each node in the tree, it will call the block passing it the node, the node's parent, and the level. I'm trying to write a test for this method and have the following.This fails with a
expected exactly once, invoked never
message. So, I tried to rewrite using thewith
block syntax like so.And I got the same failure. I tried placing a
binding.pry
inside thewith
block and verified that thenode == subject && parent == nil && level == 0
statement returnstrue
.What am I doing wrong?
The text was updated successfully, but these errors were encountered: