How to test if method is called in RSpec but do not override the return value
You can use
and_call_original
on the fluent interface to "pass through" the received message to the original method.
expect_any_instance_of(Post).to receive(:get_associated_user).and_call_original
However the use of expect_any_instance_of
might be telling you that you have a code smell and you should be testing the behavior - not the implementation.
# test what it does - not how it does it.it 'destroys the associated user' do expect { Manager.run_processes }.to change(Category.first.posts.first.users, :count).by(-1)end