Rspec expect change

I wrote the following test in rspec:

expect { ... }.to change( User.where(:profile.exists => true), :count ).by(1) 

but this area is executed only once, and it always has the same array with the same size. How to force rspec to execute this area before and after running the expected code?

+4
source share
1 answer

OPs solution posted as a response

This may or may not work for someone with a similar problem. The body was not included in the original question, and it was not independently verified.

 expect { # test goes here }.to change{ User.where(:profile.exists => true).count }.by(1) 
+4
source

All Articles