Sha256: de423e1fc53a86cdd2124721fbf1b8251bc8972ceec3dedffe89c110075bfac3
Contents?: true
Size: 1.22 KB
Versions: 4
Compression:
Stored size: 1.22 KB
Contents
require 'test_helper' class TestJsonSchema < Minitest::Test def setup sample_schema_file = File.expand_path('doc/schemas/account_post_request_body.schema.json', File.dirname(__FILE__)) @schema_json = JSON.load(File.open(sample_schema_file).read) sample_array_schema_file = File.expand_path('doc/schemas/account_get_request_body.schema.json', File.dirname(__FILE__)) @array_schema_json = JSON.load(File.open(sample_array_schema_file).read) end def test_objects_method_returns_array schema = Swagui::JsonSchema.new(@schema_json, 'PostAccount') assert_equal schema.all_objects.size, 3 end def test_models_methods_return_array_of_hash schema = Swagui::JsonSchema.new(@schema_json, 'PostAccount') assert_equal schema.models.size, 3 assert_equal schema.models.map {|x| x['id']}, ["PostAccount", "PostAccount-contact", "PostAccount-entries"] assert_equal schema.models.first['properties']['entries'], {'type' => 'array', 'items' => {"$ref"=>"PostAccount-entries"}} end def test_array_schema schema = Swagui::JsonSchema.new(@array_schema_json, 'GetAccount') assert_equal schema.models.size, 2 assert_equal schema.models.map {|m| m['id']}, %w(GetAccount GetAccount-dimensions) end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
swagui-0.5.4 | test/test_json_schema.rb |
swagui-0.5.3 | test/test_json_schema.rb |
swagui-0.5.2 | test/test_json_schema.rb |
swagui-0.5.1 | test/test_json_schema.rb |