vendredi 10 juillet 2015

FactoryGirl build ignored when testing with Shoulda-Matchers

I've recently switched over to Shoulda-Matchers but can't seem to validate my factory builds. I've instantiated my factory build in a before callback but the shoulda-matcher doesn't seem to even acknowledge it. For instance I intentionally set my instance's name to nil but the test returns no errors. What am I doing wrong?

require 'rails_helper'

describe Restaurant do
  context 'validations' do
    before { FactoryGirl.build(:restaurant, name: nil) }

    it do
      should validate_presence_of(:name)
    end
  end
end

Aucun commentaire:

Enregistrer un commentaire