Skip to content

Instantly share code, notes, and snippets.

@linuxonrails
Created February 19, 2013 19:35
Show Gist options
  • Save linuxonrails/4989075 to your computer and use it in GitHub Desktop.
Save linuxonrails/4989075 to your computer and use it in GitHub Desktop.
Test all factories automatically with TestUnit
# encoding: UTF-8
require 'test_helper'
class FactoryTest < ActiveSupport::TestCase
FactoryGirl.factories.map(&:name).each do |factory_name|
context "The #{factory_name} factory" do
setup do
# ...
@factory = FactoryGirl.build(factory_name)
end
should "be valid" do
assert @factory.valid?, "but is not valid: #{@factory.errors.first}"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment