Reputation: 20116
How to test a method that creates 10 objects User with rspec, but returns a boolean value?
And if it was only one user? There is a cleaner way to test?
Upvotes: 1
Views: 2508
Reputation: 6356
If you want to test that 10 User
records were created you could use the expect
matcher
expect { my_magic_method }.to change { User.count }.by(10)
and if you also want to test that it returns true
expect(my_magic_method).to be_true
Upvotes: 8