Sha256: f0b0bcf0e2d8b1d94c5cbbd7fd86731dc39a58d9ba53ba473d8bd57abce3fd9c

Contents?: true

Size: 909 Bytes

Versions: 47

Compression:

Stored size: 909 Bytes

Contents

require 'rails_helper'

module OpenStax
  module Api
    describe RepresentableSchemaPrinter do
      it 'must print model schemas' do
        schema = RepresentableSchemaPrinter.json(UserRepresenter)
        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" },
              "name" => { "type" => "string" },
              "email" => { "type" => "string" }
            },
            "additionalProperties" => false
          })
      end
    end
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
openstax_api-8.3.1 spec/lib/openstax/api/representable_schema_printer_spec.rb
openstax_api-8.3.0 spec/lib/openstax/api/representable_schema_printer_spec.rb
openstax_api-8.2.0 spec/lib/openstax/api/representable_schema_printer_spec.rb
openstax_api-8.1.1 spec/lib/openstax/api/representable_schema_printer_spec.rb
openstax_api-8.1.0 spec/lib/openstax/api/representable_schema_printer_spec.rb
openstax_api-8.0.0 spec/lib/openstax/api/representable_schema_printer_spec.rb
openstax_api-7.1.1 spec/lib/openstax/api/representable_schema_printer_spec.rb
openstax_api-7.1.0 spec/lib/openstax/api/representable_schema_printer_spec.rb
openstax_api-7.0.1 spec/lib/openstax/api/representable_schema_printer_spec.rb
openstax_api-6.1.5 spec/lib/openstax/api/representable_schema_printer_spec.rb
openstax_api-6.1.4 spec/lib/openstax/api/representable_schema_printer_spec.rb
openstax_api-6.1.3 spec/lib/openstax/api/representable_schema_printer_spec.rb
openstax_api-6.1.2 spec/lib/openstax/api/representable_schema_printer_spec.rb
openstax_api-6.1.1 spec/lib/openstax/api/representable_schema_printer_spec.rb
openstax_api-6.1.0 spec/lib/openstax/api/representable_schema_printer_spec.rb
openstax_api-6.0.2 spec/lib/openstax/api/representable_schema_printer_spec.rb
openstax_api-6.0.1 spec/lib/openstax/api/representable_schema_printer_spec.rb
openstax_api-6.0.0 spec/lib/openstax/api/representable_schema_printer_spec.rb
openstax_api-5.5.5 spec/lib/openstax/api/representable_schema_printer_spec.rb
openstax_api-5.5.4 spec/lib/openstax/api/representable_schema_printer_spec.rb