Skip to content

Instantly share code, notes, and snippets.

@dasch
Created February 12, 2012 00:07
Show Gist options
  • Save dasch/1805235 to your computer and use it in GitHub Desktop.
Save dasch/1805235 to your computer and use it in GitHub Desktop.
class Blog
attr_writer :post_maker
def new_post(options = {})
post_maker.new(options).tap do |p|
p.blog = self
end
end
private
def post_maker
@post_maker ||= Post
end
end
describe Blog do
let(:blog) { }
let(:post) { }
before do
blog.post_maker = double(:new => post)
end
# ...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment