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

javascript - Create websocket without connecting -

how to do line continuation in perl debugger for entering raw multi-line text (EOT)? -

Android SDK Manager freezes after installation of OSX 10.11 El Capitan public Beta -