Created
June 12, 2010 02:33
-
-
Save notahat/435343 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Here's some more hints at what's coming in Machinist 2. | |
Machinist::Collection.blueprint(:stuff) do | |
user | |
posts 3, :author => user | |
posts.each do |post| | |
comments 3, :post => post | |
end | |
end | |
stuff = Machinist::Collection.make(:stuff) | |
stuff.user.should be_a(User) | |
stuff.posts.should have(3).elements | |
stuff.posts.each do |post| | |
post.should be_a(Post) | |
post.author.should == stuff.user | |
end | |
stuff.comments.should have(9).elements | |
stuff.comments.each do |comment| | |
comment.should be_a(Comment) | |
end | |
stuff.comments[0..2].each do |comment| | |
comment.post.should == stuff.posts[0] | |
end | |
stuff.comments[3..5].each do |comment| | |
comment.post.should == stuff.posts[1] | |
end | |
stuff.comments[6..8].each do |comment| | |
comment.post.should == stuff.posts[2] | |
end | |
# And yes, that whole collection of stuff will be cached, so it'll only be | |
# generated once even if you call Machinist::Collection.make(:stuff) in | |
# multiple tests. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment