Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

More sanity checks for combinations of scopes and messages

  • Loading branch information...
commit c7c0eed45042563a4a691456ebaf270f0105300b 1 parent 2ea319b
@bcardarella authored
Showing with 23 additions and 0 deletions.
  1. +23 −0 spec/validate_uniqueness_of_spec.rb
View
23 spec/validate_uniqueness_of_spec.rb
@@ -50,6 +50,29 @@ class SingleBook
matcher.matches?(SingleBook.new).should be_false
end
end
+
+ context 'with scope and message' do
+ it 'should be true for a book validating the uniqueness with good scope and message' do
+ matcher = @should.validate_uniqueness_of(:title).scoped_to(:author_id).with_message('Test message')
+ matcher.matches?(SingleBook.new).should be_true
+ end
+
+ it 'should be false for a book validating the uniqueness with good scope and bad message' do
+ matcher = @should.validate_uniqueness_of(:title).scoped_to(:author_id).with_message('Bad message')
+ matcher.matches?(SingleBook.new).should be_false
+ end
+
+ it 'should be false for a book validating the uniqueness with bad scope and good message' do
+ matcher = @should.validate_uniqueness_of(:title).scoped_to(:reader_id).with_message('Test message')
+ matcher.matches?(SingleBook.new).should be_false
+ end
+
+ it 'should be false for a book validating the uniqueness with bad scope and bad message' do
+ matcher = @should.validate_uniqueness_of(:title).scoped_to(:reader_id).with_message('Bad message')
+ matcher.matches?(SingleBook.new).should be_false
+ end
+ end
+
end
context 'messages' do
Please sign in to comment.
Something went wrong with that request. Please try again.