Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
require File.dirname(__FILE__) + '/../test_helper' def default_comment(options = {}) { :user_id => 3829, :parent_id => 2, :body => "Hi" }.merge(options) end context "A new comment" do specify "Must have a user id" do @comment = Comment.create(default_comment({:user_id => nil})) @comment.save.should.be false end specify "Must have a parent id" do @comment = Comment.create(default_comment({:parent_id => nil})) @comment.save.should.be false end specify "Must have a body" do @comment = Comment.create(default_comment({:body => nil})) @comment.save.should.be false end specify "should be able to be created" do # this validates the relationship Comment.should.differ(:count).by(1) { Comment.create(default_comment) } end specify "should not allow when user a does not list user b as a friend" do @comment = Comment.create(default_comment({:parent_id => 3829, :user_id => 2})) @comment.save.should.be false end end context "An existing comment" do setup do @comment = Comment.find(:first, :include => [:user, :parent]) @erik = User.find_by_screen_name("kastner") end specify "should have a user" do @comment.user.should.equal @erik end end
This paste will be private.
From the Design Piracy series on my blog: