As a lot of Rails programmers nowadays I'm moving from RSpec to Minitest. I loved to have beautiful and meaningful data in my tests generated with Faker in FactoryGirl factories. However I was surprised to see different approach in Minitest fixtures. In all examples that I've found Faker wasn't used at all. So my question is what approach should I use for fixtures in Minitest. Should I use Faker for fill in fixtures or not?
There's nothing wrong with using Faker in your fixtures, but I think the answer to your question comes down to the fundamental difference between the two. Both serve the purpose of providing data for running your tests, but factories are generators with the potential to produce models. That means that they're used to create new objects as they're needed in your tests, and in particular, they're used as a shortcut for creating new objects with valid and predictable data without having to specify every attribute.
FactoryGirl.define do
factory :user do
first_name "John"
last_name "Doe"
admin false
end
end
user = build(:user, first_name: "Joe")
On the other hand, fixtures give you real data in your application DB. These are created apart from test execution and without validation, so the tendency as applications grow is to have to manage all fixtures as a single test data set. This is a big part of the argument against fixtures, but both factories and fixtures have their strengths and weaknesses.
To answer your question directly though, the reason you haven't found more examples of fixtures using Faker might be because fixture data, being fixed, needs to be more tightly controlled than factory definitions, and some of it might also be that developers inclined to use Minitest might also be inclined to remove unnecessary dependencies from their Gemfiles. But if you want to continue to use Faker for names and addresses and such, there's no reason not to.