Sha256: f9c9e9eba2675e24e864f735dfa4348c03169478aa5817196183034a947d1fe8

Contents?: true

Size: 1.05 KB

Versions: 50

Compression:

Stored size: 1.05 KB

Contents

require "test_helper"

require "json_schema"

describe JsonSchema::DocumentStore do
  before do
    @store = JsonSchema::DocumentStore.new
  end

  it "adds and looks up a schema" do
    schema = schema_sample("http://example.com/schema")
    @store.add_schema(schema)
    assert_equal schema, @store.lookup_schema(schema.uri)
  end

  it "can iterate through its schemas" do
    uri = "http://example.com/schema"
    schema = schema_sample(uri)
    @store.add_schema(schema)
    assert_equal [[uri, schema]], @store.to_a
  end

  it "can lookup a schema added with a document root sign" do
    uri = "http://example.com/schema"
    schema = schema_sample(uri + "#")
    @store.add_schema(schema)
    assert_equal schema, @store.lookup_schema(uri)
  end

  it "can lookup a schema with a document root sign" do
    uri = "http://example.com/schema"
    schema = schema_sample(uri)
    @store.add_schema(schema)
    assert_equal schema, @store.lookup_schema(uri + "#")
  end

  def schema_sample(uri)
    schema = JsonSchema::Schema.new
    schema.uri = uri
    schema
  end
end

Version data entries

50 entries across 50 versions & 2 rubygems

Version Path
json_schema-0.21.0 test/json_schema/document_store_test.rb
json_schema-0.20.9 test/json_schema/document_store_test.rb
dato_json_schema-0.20.9 test/json_schema/document_store_test.rb
dato_json_schema-0.20.8 test/json_schema/document_store_test.rb
json_schema-0.20.8 test/json_schema/document_store_test.rb
json_schema-0.20.7 test/json_schema/document_store_test.rb
json_schema-0.20.6 test/json_schema/document_store_test.rb
json_schema-0.20.5 test/json_schema/document_store_test.rb
json_schema-0.20.4 test/json_schema/document_store_test.rb
json_schema-0.20.3 test/json_schema/document_store_test.rb
json_schema-0.20.2 test/json_schema/document_store_test.rb
json_schema-0.20.1 test/json_schema/document_store_test.rb
json_schema-0.19.1 test/json_schema/document_store_test.rb
json_schema-0.19.0 test/json_schema/document_store_test.rb
json_schema-0.18.0 test/json_schema/document_store_test.rb
json_schema-0.17.2 test/json_schema/document_store_test.rb
json_schema-0.17.1 test/json_schema/document_store_test.rb
json_schema-0.17.0 test/json_schema/document_store_test.rb
json_schema-0.16.2 test/json_schema/document_store_test.rb
json_schema-0.16.1 test/json_schema/document_store_test.rb