Note that there are some explanatory texts on larger screens.

plurals
  1. POFactoryGirl not giving useful validation errors
    text
    copied!<p>I'm using FactoryGirl for my fixtures and am finding that it's not really producing useful validation errors. </p> <p>I always get the message for activerecord.errors.models.messages.record_invalid.</p> <p>Not sure what further details are needed to help diagnose this. This makes it an excruciatingly slow process to track each error down.</p> <p>Example factory:</p> <pre><code>Factory.define :partner do |partner| partner.sequence(:username){ |n| "amcconnon#{n}" } partner.first_name "Bobby Joe" partner.last_name "Smiley" partner.sequence(:email){ |n| "bob{n}@partners.com" } partner.phone_number "5557 5554" partner.country_id 75 partner.password "password" partner.password_confirmation "password" end </code></pre> <p>Then Factory(:partner) => "ActiveRecord::RecordInvalid Exception: Looks like something went wrong with these changes"</p> <p>The actual problem is of course the email sequence doesn't use n properly and there is a unique validation on email. But that's for illustrative purposes.</p> <p>rails => 3.2.2 factory_girl 2.6.1</p> <p>Any other deets needed to help diagnose this?</p> <p>(Note: edited this just to add an easier to read factory)</p> <p>EDIT: </p> <p>As per bijan's comment: "What exactly am I trying to do."</p> <p>Trying to run "rspec spec". I would like when I use a factory like Factory(:partner) in this case for the error message when that fails to contain the same error I would get from Partner.new({blah...}).valid? then looked at the validation failures.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload