From 4a8af11644accdb59ecdd45f2ec8d5ecfbbaf34b Mon Sep 17 00:00:00 2001 From: Jamie Gaskins Date: Sun, 1 Jul 2012 20:00:59 +0800 Subject: [PATCH] Add attributes to Article class --- spec/perpetuity/mapper_spec.rb | 2 +- spec/test_classes.rb | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/spec/perpetuity/mapper_spec.rb b/spec/perpetuity/mapper_spec.rb index 9b754e8..f5f260a 100644 --- a/spec/perpetuity/mapper_spec.rb +++ b/spec/perpetuity/mapper_spec.rb @@ -6,7 +6,7 @@ module Perpetuity describe Mapper do it 'has correct attributes' do UserMapper.attributes.should == [:name] - ArticleMapper.attributes.should == [:title, :body, :comments] + ArticleMapper.attributes.should == [:title, :body, :comments, :published_at, :views] end it 'returns an empty attribute list when no attributes have been assigned' do diff --git a/spec/test_classes.rb b/spec/test_classes.rb index 5988fe3..ef80c0f 100644 --- a/spec/test_classes.rb +++ b/spec/test_classes.rb @@ -1,9 +1,11 @@ class Article - attr_accessor :title, :body, :comments - def initialize title="Title", body="Body", author=nil + attr_accessor :title, :body, :comments, :published_at, :views + def initialize title="Title", body="Body", author=nil, published_at=Time.now, views=0 @title = title @body = body @comments = [] + @published_at = published_at + @views = views end end @@ -11,6 +13,8 @@ class ArticleMapper < Perpetuity::Mapper attribute :title, String attribute :body, String attribute :comments, Array + attribute :published_at, Time + attribute :views, Integer end class Comment