Created
September 26, 2014 14:57
-
-
Save RyanRusnak/355f017618b73fcb55dd to your computer and use it in GitHub Desktop.
mutable_role_spec.rb
This file contains hidden or 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' | |
describe MutableRole do | |
describe 'before_destroy' do | |
context 'immutable roles' do | |
let!(:admin) { MutableRole.create(name: 'admin') } | |
let!(:moderator) { MutableRole.create(name: 'moderator') } | |
let!(:member) { MutableRole.create(name: 'member') } | |
it 'admin should be immutable' do | |
expect { admin.destroy }.not_to change { MutableRole.count } | |
end | |
it 'moderator should be immutable' do | |
expect { moderator.destroy }.not_to change { MutableRole.count } | |
end | |
it 'member should be immutable' do | |
expect { member.destroy }.not_to change { MutableRole.count } | |
end | |
end | |
context 'mutable roles' do | |
let!(:foo) { MutableRole.create(name: 'foo') } | |
it 'other roles should be mutable' do | |
expect { foo.destroy }.to change { MutableRole.count }.by(-1) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment