How to unpack a gem for local usage?

This bugged me for a while, so I decided to make a note to self for future reference.
If you try to include the gem in your bundle (e.g. for a rails app), you need to unpack the gemspec too.

The commands are:
 $ gem unpack gemname --target vendor/gems
 $ cd vendor/gems/gemname-VERSION
 $ gem unpack gemname --spec