JSON Test Data Generator
The JSON test data generator takes JSON schema as input and generates test data matching the specification. You can download it from RubyGems:
gem install json_test_data
Alternatively, it can be included in your Gemfile:
gem "json_test_data", "~> 0.7.0"
To use it, first require it, then generate the test data using:
data = JsonTestData.generate!(schema)
If you would prefer to return a Ruby object instead of a JSON object, simply include the :ruby
option:
data = JsonTestData.generate!(schema, ruby: true)
The input that you put into it must be valid JSON schema. The top-level object must have a :type
key indicating the type of object to be generated ("object", "array", "string", etc.).
Contribute
The JSON Test Data Generator is in its infancy and contributions are much appreciated. Please include passing tests with all pull requests, and file an issue report indicating what you'd like to work on. I'm also happy to get issue reports that do not come with pull requests, but can't guarantee I'll actually write whatever it is you want JSON Test Data to do. I strongly encourage pull requests adding documentation!