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:
```ruby
# Don't do this:
expect_any_instance_of(Project).to receive(:add_import_job)
allow_any_instance_of(Project).to receive(:add_import_job)
```
We could write:
......@@ -122,10 +124,14 @@ We could write:
expect_next_instance_of(Project) do |project|
expect(project).to receive(:add_import_job)
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
arguments, we could also pass it to `expect_next_instance_of` like:
If we also want to initialized the instance with some particular arguments, we
could also pass it like:
```ruby
# 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