Is there an rspec test for exact length of an attribute?
问题 I'm trying to test the length of a zip code attribute to ensure its 5 characters long. Right now I'm testing to make sure its not blank and then too short with 4 characters and too long with 6 characters. Is there a way to test it being exactly 5 characters? So far I've found nothing online or in the rspec book. 回答1: If you're testing a validation on an ActiveRecord model, I recommend trying out shoulda-matchers . It provides a bunch of useful RSpec extensions useful for Rails. You could