diff options
author | HombreLaser <sebastian-440@live.com> | 2023-03-22 19:28:58 -0600 |
---|---|---|
committer | HombreLaser <sebastian-440@live.com> | 2023-03-22 19:28:58 -0600 |
commit | 6dda37a27500c3a2e48b22b3e4e0a021a45853d2 (patch) | |
tree | 8afe49231d0831c2ec2d3a78f1c24ef481f2e82c /spec | |
parent | a92be45296f8cc3210030602bd83a8d0229206cd (diff) |
Añade specs de modelo Address
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/address_spec.rb | 22 | ||||
-rw-r--r-- | spec/models/user_account_address_spec.rb | 3 |
2 files changed, 23 insertions, 2 deletions
diff --git a/spec/models/address_spec.rb b/spec/models/address_spec.rb index 5531d0d..d5a3ed2 100644 --- a/spec/models/address_spec.rb +++ b/spec/models/address_spec.rb @@ -1,5 +1,25 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Address, type: :model do - pending "add some examples to (or delete) #{__FILE__}" + 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 diff --git a/spec/models/user_account_address_spec.rb b/spec/models/user_account_address_spec.rb index 3e358e6..b040c12 100644 --- a/spec/models/user_account_address_spec.rb +++ b/spec/models/user_account_address_spec.rb @@ -1,5 +1,6 @@ require 'rails_helper' RSpec.describe UserAccountAddress, type: :model do - pending "add some examples to (or delete) #{__FILE__}" + it { should belong_to(:address) } + it { should belong_to(:user_account) } end |