Skip to content

Commit

Permalink
Add attributes to Article class
Browse files Browse the repository at this point in the history
  • Loading branch information
jgaskins committed Jul 1, 2012
1 parent 8fe27a5 commit 4a8af11
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion spec/perpetuity/mapper_spec.rb
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions spec/test_classes.rb
@@ -1,16 +1,20 @@
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

class ArticleMapper < Perpetuity::Mapper
attribute :title, String
attribute :body, String
attribute :comments, Array
attribute :published_at, Time
attribute :views, Integer
end

class Comment
Expand Down

0 comments on commit 4a8af11

Please sign in to comment.