Another possibility that I just missed is using the wrong before block.
I accidentally set the before block as all instead of each :
before :all do user = FactoryGirl.create(:user) sign_in user end
This caused the user to stick to the entire rspec mileage in the rspec , which caused validation errors.
Instead, before should be each so that everything is clean with rspec run:
before :each do user = FactoryGirl.create(:user) sign_in user end
If you make this mistake, you may have to manually clear the test database before everything returns to normal. The easiest way to do this is probably to truncate each of the tables (except for schema_migrations ).
source share