Skip to content

Instantly share code, notes, and snippets.

@kluzny
Created April 8, 2023 23:32
Show Gist options
  • Save kluzny/185f08ecb0f8956a1f99b575b7bd65e8 to your computer and use it in GitHub Desktop.
Save kluzny/185f08ecb0f8956a1f99b575b7bd65e8 to your computer and use it in GitHub Desktop.
automatically test every factory build/create
require 'rails_helper'
FactoryBot.factories.map(&:name).each do |factory_name|
describe "The #{factory_name} factory" do
it 'is valid' do
expect(build(factory_name)).to be_valid
end
it 'creates without error' do
expect { create(factory_name) }.to_not raise_error
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment