Created
July 28, 2017 04:38
-
-
Save somethvictory/da64b5dbc8c2f2eec4adb33df5877b39 to your computer and use it in GitHub Desktop.
Organise your spec by grouping them under different describe context, associations, validations, callbacks, etc...
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
require 'rails_helper' | |
RSpec.describe Url, 'Associations', type: :model do | |
it { is_expected.to belong_to(:user) } | |
it { is_expected.to have_many(:logs) } | |
end | |
RSpec.describe Url, 'Validations', type: :model do | |
it { is_expected.to validate_presence_of(:original_name) } | |
it { is_expected.to validate_uniqueness_of(:original_name) } | |
it { is_expected.to allow_value('http://example.com').for(:original_name) } | |
it { is_expected.to allow_value('https://example.com').for(:original_name) } | |
it { is_expected.not_to allow_value('example.com').for(:original_name) } | |
it { is_expected.not_to allow_value('http://example').for(:original_name) } | |
it { is_expected.not_to allow_value('example').for(:original_name) } | |
it 'sets short name before save' do | |
@url = FactoryGirl.build(:url, short_name: '') | |
@url.save | |
expect(@url.short_name).not_to be nil | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment