ruby on rails - FactoryGirl build ignored when testing with Shoulda Matchers -


i've switched on shoulda matchers, can't seem validate factory builds. i've instantiated factory build in before callback, matcher doesn't seem acknowledge it. instance, intentionally set instance's name nil test returns no errors. doing wrong?

require 'rails_helper'  describe restaurant   context 'validations'     before { factorygirl.build(:restaurant, name: nil) }            should validate_presence_of(:name)     end   end end 

for scenario, don't require instance match shoulda matchers; it's going test the usage of validate_presence_of against model definition itself.

so, i'd rewrite test thus:

require 'rails_helper'  describe restaurant   { should validate_presence_of(:name) } end 

Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -