I think what before block does is cleans the database and creates new instances each time before every example.
But what would I do if I were to call that block only once instead of using the before block and then use the variables throughout the file?
I tried doing this but then I had to clean my test database every time I ran the spec file. I think this is because my test database was not getting cleaned after the file ran.
I tried using database_cleaner but failed there too.
As @benorenstein suggested in your other post you normally shouldn’t be doing database cleaning manually. Have a look at DatabaseCleaner which does the job for you and integrates nicely with RSpec, Cucumber, …
Before you wrap everything in let or let! read this article not to abuse them Looking at your example code I’d also suggest you look if you could build object instead of creating them. Or even better use build_stubbed to avoid hitting the database and speed up your tests quite a bit. Looks like you pasted some code from unit test for Push model where you should test in isolation as much as possible. Maybe you should be doing some mocking and stubbing.