Tests are not only a tool to automatically check the code and its correctness, but also an excellent documentation. Every time I don't understand something in the documentation of a library, I look at the specs and quickly find an answer to my question.
In tests it is the best to use data as close to real-life as possible: "User" → "Ivan Pavlov", "ip" → "220.127.116.11", empty file → jpeg with your cat. This way we get good documentation and good examples of how to use our API.
To make the tests consistent, I prefer to use a single domain for the test data. For example, I often use:
1. Characters and quotes from The Simpsons:
user = User.new(name: "Bart Simpson", email: "firstname.lastname@example.org") expect(user.to).to eq "Bart Simpson <email@example.com>"
2. Characters and quotes from '90s action movies:
comment: "Dead or alive... you're coming with me"
3. Lyrics of Eminem's or Beyoncé's songs (please don't ask):
do_request(text: "In my shoes, just to see what it's like to be me")
P. S. Some of you might mention Faker. I don't use it as I think it's an anti-pattern. I'll elaborate on this in next post.