Skip to content

Instantly share code, notes, and snippets.

@adam12
Created November 6, 2012 21:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adam12/4027817 to your computer and use it in GitHub Desktop.
Save adam12/4027817 to your computer and use it in GitHub Desktop.
Domain
is invalid without a unique name
is invalid without master if slave?
is invalid without a name
is invalid if master not a valid IP
is invalid if type is not NATIVE MASTER or SLAVE
should have a valid factory
#slave?
should be true if type == SLAVE
Finished in 0.1246 seconds
7 examples, 0 failures
Randomized with seed 11425
require 'spec_helper'
describe Domain do
it 'should have a valid factory' do
expect(build(:domain)).to be_valid
end
it 'is invalid without a name' do
domain = build(:domain, name: nil)
expect(domain).to_not be_valid
end
it 'is invalid without a unique name' do
name = create(:domain).name
domain = build(:domain, name: name)
expect(domain).to_not be_valid
end
it 'is invalid if type is not NATIVE MASTER or SLAVE' do
expect(build(:domain, type: 'notinlist')).to_not be_valid
end
it 'is invalid without master if slave?' do
expect(build(:domain, :slave, master: nil)).to_not be_valid
end
it 'is invalid if master not a valid IP' do
expect(build(:domain, :slave, master: 'abc')).to_not be_valid
end
describe '#slave?' do
it 'should be true if type == SLAVE' do
domain = build(:domain, type: 'SLAVE')
expect(domain.slave?).to be_true
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment