How to Test Validations in Rails Discussion
Where do you think test factories come in here? A RatingFactory could make sure that the object instance we're using for tests is valid without us having to care how it's achieved.
For validations, I sometimes like to use the shoulda-matchers gem
It's pretty cool because alot of use cases are set up already so it saves having to come up with the edge cases.
For example, in a model test (assuming Rails default not RSpec)
should validate_presence_of(:attribute)
For Rspec, you would write
it { should validate_presence_of(:attrinute) }
Obviously, it doesn't apply in some cases such as custom validate method but it's always a good start into a large codebase that might not have a massive test coverage.