Skip to content

Instantly share code, notes, and snippets.

@theconektd
Created February 15, 2010 21:18
Show Gist options
  • Save theconektd/305005 to your computer and use it in GitHub Desktop.
Save theconektd/305005 to your computer and use it in GitHub Desktop.
require "rubygems"
require "dm-core"
require "dm-validations"
require "spec"
class Contact
include DataMapper::Resource
property :id, Serial
property :email, String, :format => :email_address, :required => true
end
DataMapper.setup(:default, 'sqlite3::memory:')
DataMapper.auto_migrate!
describe Contact do
it 'requires a valid email address' do
Contact.create(:email => nil).should_not be_valid
Contact.create(:email => 'foo').should_not be_valid
Contact.create(:email => 'foo@foo').should_not be_valid # This should pass
Contact.create(:email => '[email protected]').should be_valid
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment