tdouce/remote_factory_girl — pull request #6 by tdouce (2014-06-30 16:17:52+00:00)
Title: Configures returning json without root when json has not root

RemoteFactoryGirl did not return a properly formatted json
representation of a factory when:

1. It was configured to not return a root key, and
2. When the json representation of the factory returned from *home* did
not contain a root key.

This commit returns a properly formatted json representation of a
factory when the json returned from *home* contains a root key and when
the the json returned from *home* does not contain a root key.

The json response returned from RemoteFactoryGirlHomeRails is a json
representation of a factory that was requested to be created in the
*client*. In some circumstances (possibly the version of FactoryGirl
used in *home* or possibly how the factory is defined), the json
representation contains a root key and in some circumstances the json
does not contain a root key.

The following is a json representation of a factory that contains a
root key:

{‘user’: {‘first_name’: ‘Sam’, ‘last_name’: ‘Iam’}}

The following is a json representation of a factory that does NOT
contain a root key:

{‘first_name’: ‘Sam’, ‘last_name’: ‘Iam’}

When RemoteFactoryGirl was configured to not return a root key and the
json representation of a factory returned from *home* did not contain a
root key then the json returned from RemoteFactoryGirl was not correct.
Given the example json above, it would incorrectly return:

`Iam`

although it was supposed to return:

{‘first_name’: ‘Sam’, ‘last_name’: ‘Iam’}