Skip to content

Instantly share code, notes, and snippets.

@jsmestad
Created December 8, 2008 01:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsmestad/33296 to your computer and use it in GitHub Desktop.
Save jsmestad/33296 to your computer and use it in GitHub Desktop.
class Post
include DataMapper::Resource
property :id, Serial
property :title, String
property :content, Text
property :created_at, DateTime
property :updated_at, DateTime
validates_length :title, :min => 5
belongs_to :author, :class_name => 'User'
end
describe Post do
before(:each) do
@user = create_default_user
@valid_attributes = {
:title => "Dude where is my car",
:content => 'I think I found it but I am not quite sure.'
}
end
it 'should have validations' do
post = Post.new
post.should_not be_valid
post.title = @valid_attributes[:title]
post.content = @valid_attributes[:content]
post.author = @user
p post
post.should be_valid
end
end
1)
NoMethodError in 'Post should have validations'
undefined method `new_record?' for #<Merb::Logger:0x274659c>
/Library/Ruby/Gems/1.8/gems/dm-core-0.9.7/lib/dm-core/property.rb:450:in `lazy_load'
/Library/Ruby/Gems/1.8/gems/dm-core-0.9.7/lib/dm-core/property.rb:390:in `get'
/Library/Ruby/Gems/1.8/gems/dm-core-0.9.7/lib/dm-core/property_set.rb:82:in `get'
/Library/Ruby/Gems/1.8/gems/merb-core-1.0.3/lib/merb-core/controller/mixins/render.rb:125:in `map'
/Library/Ruby/Gems/1.8/gems/dm-core-0.9.7/lib/dm-core/property_set.rb:55:in `each'
/Library/Ruby/Gems/1.8/gems/dm-core-0.9.7/lib/dm-core/property_set.rb:55:in `each'
/Library/Ruby/Gems/1.8/gems/dm-core-0.9.7/lib/dm-core/property_set.rb:82:in `map'
/Library/Ruby/Gems/1.8/gems/dm-core-0.9.7/lib/dm-core/property_set.rb:82:in `get'
/Library/Ruby/Gems/1.8/gems/dm-core-0.9.7/lib/dm-core/associations/relationship.rb:178:in `attach_parent'
/Library/Ruby/Gems/1.8/gems/dm-core-0.9.7/lib/dm-core/associations/many_to_one.rb:55:in `replace'
/Library/Ruby/Gems/1.8/gems/dm-core-0.9.7/lib/dm-core/associations/many_to_one.rb:21:in `author='
./spec/models/post_spec.rb:18:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment