1
0
Fork 0
This repository has been archived on 2023-03-27. You can view files and clone it, but cannot push or open issues or pull requests.
lpr-partynest/spec/models/contact_spec.rb
2019-08-11 05:28:16 +05:00

44 lines
1 KiB
Ruby

# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Contact do
subject { create :some_contact }
describe '#contact_list' do
it { is_expected.to belong_to(:contact_list) }
it { is_expected.to validate_presence_of :contact_list }
end
describe '#contact_network' do
it { is_expected.to belong_to(:contact_network) }
it { is_expected.to validate_presence_of :contact_network }
end
describe '#value' do
def allow_value(*)
super.for :value
end
it { is_expected.to validate_presence_of :value }
it { is_expected.not_to allow_value nil }
it { is_expected.not_to allow_value '' }
it { is_expected.not_to allow_value ' ' * rand(1..3) }
it { is_expected.to allow_value Faker::Internet.username }
context 'when it was set to blank string' do
subject { build :some_contact, value: value }
let(:value) { ' ' * rand(1..3) }
specify do
expect { subject.validate }.to \
change(subject, :value).from(value).to(nil)
end
end
end
end