# Specifying a binary field in test fixtures

**URL:** <https://www.ruby-forum.com/t/specifying-a-binary-field-in-test-fixtures/98477>\
**Category:** Rails\
**Created:** [December 12, 2005, 3:48pm UTC](https://www.ruby-forum.com/t/specifying-a-binary-field-in-test-fixtures/98477 "2005-12-12T15:48:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pergesu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/22d042/32.png) [@pergesu](https://www.ruby-forum.com/u/pergesu)\
**Post date:** [December 12, 2005, 3:48pm UTC](https://www.ruby-forum.com/t/specifying-a-binary-field-in-test-fixtures/98477/1 "2005-12-12T15:48:00Z")

</div>

One of my fields holds binary data (a serialized object), and I’d like  
to be able to create fixtures that have this data. I can just use erb  
to build the object, but I don’t know how to write the fixture file  
such that the object is serialized. Anyone know how to do this?

---

<div class="post-metadata">

**Author:** ![pergesu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/22d042/32.png) [@pergesu](https://www.ruby-forum.com/u/pergesu)\
**Post date:** [December 12, 2005, 3:54pm UTC](https://www.ruby-forum.com/t/specifying-a-binary-field-in-test-fixtures/98477/2 "2005-12-12T15:54:01Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

On Dec 12, 2005, at 6:46 AM, Pat M. wrote:

> One of my fields holds binary data (a serialized object), and I’d like  
> to be able to create fixtures that have this data. I can just use erb  
> to build the object, but I don’t know how to write the fixture file  
> such that the object is serialized. Anyone know how to do this?

YAML supports Base64-encoded binary values  
[Binary Data Language-Independent Type for YAML™&nbsp;Version&nbsp;1.1](http://yaml.org/type/binary.html)

jeremy  
-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.4.2 (Darwin)

iD8DBQFDnY5LAQHALep9HFYRAoA1AJ0QjxLKuxqvPBAnldlNam5jdKfy1QCcD5Rz  
vGIZ0S0QL/9bSFxSVtNPSb8=  
=4xtR  
-----END PGP SIGNATURE-----

---

<div class="post-metadata">

**Author:** ![pergesu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/22d042/32.png) [@pergesu](https://www.ruby-forum.com/u/pergesu)\
**Post date:** [December 12, 2005, 4:24pm UTC](https://www.ruby-forum.com/t/specifying-a-binary-field-in-test-fixtures/98477/3 "2005-12-12T16:24:13Z")

</div>

How do I specify this in the YAML file? And then when I’m accessing  
the object, how do I ensure that it’s an object of the type I want,  
not just a string stored in the db?

Pat
