Created
September 19, 2012 15:41
-
-
Save ltello/3750352 to your computer and use it in GitHub Desktop.
Validate uniqueness with Rspec matchers (not shoulda)
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
describe 'Category' do | |
context '#create' do | |
before(:all) do | |
@properties = {:code => 'TST', :description => 'Test Category'} | |
@category = Category.create(@properties) | |
@same_category = Category.create(@properties) | |
end | |
context 'When right properties given' do | |
it 'the category gets persisted' do | |
@category.should be_persisted | |
end | |
it 'unless code is not unique' do | |
@same_category.should_not be_persisted | |
@same_category.should have_at_least(1).errors_on(:code) | |
end | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment