summaryrefslogtreecommitdiff
path: root/spec/models/address_spec.rb
blob: d5a3ed29ca279cdeac8a24530385653bbf73604d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe Address, type: :model do
  it { should validate_presence_of(:number) }
  it { should validate_presence_of(:street) }
  it { should validate_presence_of(:zip_code) }
  it { should validate_presence_of(:country) }
  it { should validate_presence_of(:city) }

  describe 'number' do
    it 'should be greater than or equal to 0' do
      address = build(:address, number: -1)
      expect(address.save).to be_falsey
    end
  end

  describe 'country' do
    it 'should be a valid country' do
      address = build(:address, country: 'Not a country')
      expect(address.save).to be_falsey
    end
  end
end