# Factory uses Faker::Name.first_name under the hoode -- evaluates to something with 'frank' as a substring
# Now you have two users named frank without realizing it
let(:user) { create :user }
let(:another_user) { create :user, name: 'frank' }
it do
filter_for_frank
expect(page).to have_text 'frank'
end
This is a simple illustration of one way Faker can be problematic in specs.
The basic issue is that you can't rely on Faker data on being unique unless you call Faker::{Generator}.unique.{method}
.
If you want to make these kinds of expectations, be explicit about all the data under test and leave less responsibility to Faker:
let(:user) { create :user, name: 'alice' }
let(:another_user) { create :user, name: 'frank' }
it do
filter_for_frank
expect(page).to have_text 'frank'
end
Faker has more place in seed data than it does specs. Don't use Faker to expand your test coverage.