Stub out comments writer when needed

This commit is contained in:
Adrian Mugnolo and Santiago Pastorino 2013-12-16 17:10:13 -02:00 committed by Santiago Pastorino
parent ceded40aa1
commit e2b7bba626
2 changed files with 4 additions and 2 deletions

View File

@ -26,8 +26,6 @@ class Profile < Model
end
class Post < Model
attr_writer :comments
def comments
@comments ||= [Comment.new(content: 'C1'),
Comment.new(content: 'C2')]

View File

@ -53,6 +53,10 @@ module ActiveModel
@post1 = Post.new({ title: 'Title 1', body: 'Body 1', date: '1/1/2000' })
@post2 = Post.new({ title: 'Title 2', body: 'Body 2', date: '1/1/2000' })
class << @post2
attr_writer :comments
end
@post2.comments = [
Comment.new(content: 'C3'),
Comment.new(content: 'C4')