Created
July 31, 2015 19:32
-
-
Save yakovenkodenis/899785c2c269787e59dd to your computer and use it in GitHub Desktop.
Model validations/assosiations spec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RSpec.describe Account, type: :model do | |
describe 'validations' do | |
it { should validate_presence_of :owner } | |
it { should validate_presence_of :subdomain } | |
it { should validate_uniqueness_of :subdomain } | |
it { should allow_value('denis').for(:subdomain) } | |
it { should allow_value('test').for(:subdomain) } | |
it { should_not allow_value('www').for(:subdomain) } | |
it { should_not allow_value('WWW').for(:subdomain) } | |
it { should_not allow_value('.test').for(:subdomain) } | |
it { should_not allow_value('test/').for(:subdomain) } | |
it 'should validate case insensitive uniqueness' do | |
create(:account, subdomain: 'Test') | |
expect(build(:account, subdomain: 'test')).to_not be_valid | |
end | |
end | |
describe 'associations' do | |
it { should belong_to :owner } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment