Created
November 11, 2009 08:34
-
-
Save royw/231789 to your computer and use it in GitHub Desktop.
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 'spec' | |
require 'dm-core' | |
require 'dm-validations' | |
require 'dm-timestamps' | |
require 'dm-types' | |
require 'dm-aggregates' | |
DataMapper.setup(:default, 'mysql://localhost/test') | |
# DataMapper.setup(:default, 'sqlite3::memory:') | |
# DataObjects::Sqlite3.logger = DataMapper::Logger.new("test-db.log", :debug) | |
class Keyword | |
include DataMapper::Resource | |
# Property definitions | |
property :id, Serial | |
property :text, String, :length => 255 | |
timestamps :at | |
validates_with_method :unique_text | |
def unique_text | |
result = true | |
Keyword.all(:text => self.text).each do |k| | |
result = false if k.text == self.text | |
end | |
result | |
end | |
end | |
DataMapper.auto_migrate! | |
describe 'case sensitivity' do | |
it 'should be case sensitive' do | |
Keyword.count.should == 0 | |
Keyword.create(:text => 'polish') | |
Keyword.count.should == 1 | |
Keyword.create(:text => 'Polish') | |
Keyword.count.should == 2 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment