Created
June 6, 2021 15:35
-
-
Save skycocker/24ad32c63e9dad2eb7bdfd30e8c7a2e8 to your computer and use it in GitHub Desktop.
A simple rspec factory validator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rails_helper' | |
FactoryBot.factories.each do |factory| | |
describe "The #{factory.name} factory" do | |
it 'is valid' do | |
expect(build(factory.name)).to be_valid | |
end | |
describe 'traits' do | |
factory.defined_traits.each do |trait| | |
it trait.name do | |
expect(build(factory.name, trait.name)).to be_valid | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment