Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save andrewkolesnikov/666360 to your computer and use it in GitHub Desktop.
Save andrewkolesnikov/666360 to your computer and use it in GitHub Desktop.
require "rubygems"
require "dm-core"
require "dm-tags"
require "dm-validations"
require "spec"
class Contact
include DataMapper::Resource
property :id, Serial
has_tags_on :tags
end
DataMapper.setup(:default, 'sqlite3::memory:')
DataMapper.auto_migrate!
describe Contact do
it 'requires a tags be saved even when tags are malformed' do
Contact.create(:tag_list => ',foo,bar').should be_valid # never executes sql queries, because validation failed, although no errors are raised.
Tag.errors.length.should == 0 #fails
Contact.first.tag_collection.should == 'foo,bar' #fails
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment