Commit cf8d8a84 authored by Arturo Herrero's avatar Arturo Herrero

Docs Gotchas: Add allow_next_instance_of example

parent 9fcc3630
...@@ -113,6 +113,8 @@ Instead of writing: ...@@ -113,6 +113,8 @@ Instead of writing:
```ruby ```ruby
# Don't do this: # Don't do this:
expect_any_instance_of(Project).to receive(:add_import_job) expect_any_instance_of(Project).to receive(:add_import_job)
allow_any_instance_of(Project).to receive(:add_import_job)
``` ```
We could write: We could write:
...@@ -122,10 +124,14 @@ We could write: ...@@ -122,10 +124,14 @@ We could write:
expect_next_instance_of(Project) do |project| expect_next_instance_of(Project) do |project|
expect(project).to receive(:add_import_job) expect(project).to receive(:add_import_job)
end end
allow_next_instance_of(Project) do |project|
allow(project).to receive(:add_import_job)
end
``` ```
If we also want to expect the instance was initialized with some particular If we also want to initialized the instance with some particular arguments, we
arguments, we could also pass it to `expect_next_instance_of` like: could also pass it like:
```ruby ```ruby
# Do this: # Do this:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment