require 'spec_helper' describe Contact do let(:params) { create_contact_params } it "rejects empty postcodes" do params.delete('postcode') @contact = Contact.new(params) expect(@contact.valid?).to be(false) end it "rejects too short postcodes" do params['postcode'] = '123' @contact = Contact.new(params) expect(@contact.valid?).to be(false) end it "rejects too long postcodes" do params['postcode'] = '12345' @contact = Contact.new(params) expect(@contact.valid?).to be(false) end it "rejects postcodes wiht invalid chars" do params['postcode'] = '123s' @contact = Contact.new(params) expect(@contact.valid?).to be(false) end end