thoughtbot/factory_girl — pull request #258 by weppos (2011-12-20 18:20:30+00:00)
Title: Ensure the proper result is returned when block is passed

According to this [blog post](http://robots.thoughtbot.com/post/11437609921/factory-girl-2-2-your-new-best-friend), the following example

```ruby
let(:old_published_post) do
create(:post, created_at: 2.years.ago) do |post|
post.publish!
end
end
```

should be equivalent to

```
let(:old_published_post) do
create(:post, created_at: 2.years.ago).tap do |post|
post.publish!
end
end
```

Unfortunately, the current version doesn't care about the returned value.

In the following example, `FactoryGirl.create(:order)` returns 0 because the last expression evaluates to 0.
`:order` is set to 0 causing an unexpected behavior (or at least the behavior is different compared to `#tap` that always returns `self`).

```ruby
let(:order) {
FactoryGirl.create(:order) do |order|
order.save!
order.total_cents = 0
end
}

order
# => 0
```

This patch fixes the issue. It uses `#tap` internally, thus it's not compatible with Ruby < 1.8.7.
I'm not aware of current FactoryGirl minimum Ruby requirements. If you need to ensure compatibility with 1.8.6 let me know, I'll update the patch.