Skip to content
This repository

Use more verbose factories_spec.rb #123

Closed
aripollak opened this Issue · 2 comments

2 participants

Ari Pollak Dan Croak
Ari Pollak

Another possible addition is to include this around the context block, in case you have factories that are not for ActiveRecord models:

factory_class = factory.name.to_s.camelcase.safe_constantize
if factory_class && factory_class.ancestors.include?(ActiveRecord::Base)

or the duck-typed version (which I chose):

factory_class = factory.name.to_s.camelcase.safe_constantize
if factory_class && factory_class.method_defined?(:valid?)
Geoff Harcourt geoffharcourt referenced this issue from a commit in geoffharcourt/suspenders
Geoff Harcourt geoffharcourt Use more verbose factories_spec.rb
Code from thoughtbot factory_girl wiki for testing that factories are
producting valid models. See issue #123.
bb14cdf
Dan Croak croaky referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
Dan Croak croaky referenced this issue from a commit
Geoff Harcourt geoffharcourt Use more verbose factories spec
Use code from factory girl wiki testing factories are producting valid
models. See issue #123.
84c3451
Dan Croak
Owner
croaky commented

The subject.errors.full_messages.join(',') bit has been in master for a few months. Thanks, @aripollak.

Dan Croak croaky closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.