Skip to content

Instantly share code, notes, and snippets.

@andyferra
Created February 15, 2010 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save andyferra/305005 to your computer and use it in GitHub Desktop.
Save andyferra/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 => 'foo@foo.com').should be_valid
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment