summaryrefslogblamecommitdiffstats
path: root/spec/contact_spec.rb
blob: 980626bd31f5ded0d0c9e29208a22bef65d5243c (plain) (tree)




























                                              
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