Sha256: 09076b4ab031d671d374ab1659035701b1f8e0dd2d26e33976a7d494e3776493

Contents?: true

Size: 873 Bytes

Versions: 3

Compression:

Stored size: 873 Bytes

Contents

require 'spec_helper'

module OpenStax
  module Api
    describe RepresentableSchemaPrinter do
      it 'must print model schemas' do
        schema = RepresentableSchemaPrinter.json(DummyUserRepresenter)
        expect(schema).to include('## Schema')
        expect(schema).to include('{#')
        expect(schema).to include(' .schema}')
        expect(schema).to include("<pre class='code'>")
        expect(schema).to include('</pre>')
        json_schema = schema.match(/<pre class='code'>([^<]*)<\/pre>/)
        expect(JSON.parse(json_schema[1])).to eq({
            "type" => "object",
            "required" => [ "username" ],
            "properties" => {
              "username" => { "type" => "string" },
              "password_hash" => { "type" => "string" }
            },
            "additionalProperties" => false
          })
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
openstax_api-2.2.0 spec/lib/openstax/api/representable_schema_printer_spec.rb
openstax_api-2.1.1 spec/lib/openstax/api/representable_schema_printer_spec.rb
openstax_api-2.1.0 spec/lib/openstax/api/representable_schema_printer_spec.rb