Created
March 18, 2014 09:04
-
-
Save jsborjesson/9616273 to your computer and use it in GitHub Desktop.
Easy testing of json API:s with Factory Girl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class JsonForStrategy | |
| def initialize | |
| @strategy = FactoryGirl.strategy_by_name(:build).new | |
| end | |
| delegate :association, to: :@strategy | |
| def result(evaluation) | |
| @strategy.result(evaluation).to_json | |
| end | |
| end | |
| FactoryGirl.register_strategy(:json_for, JsonForStrategy) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Dump this in your
support/and use it like every other factory: