Drop json-schema-rspec and bump json-schema

This commit is contained in:
Benjamin Neff 2022-07-03 05:05:09 +02:00
parent 851797d45f
commit f184ec5818
No known key found for this signature in database
GPG key ID: 971464C3F1A90194
4 changed files with 10 additions and 13 deletions

View file

@ -46,7 +46,7 @@ group :test do
gem "simplecov-rcov", "0.3.1", require: false
# test helpers
gem "json-schema-rspec", "0.0.4"
gem "json-schema", "~> 3.0"
gem "rspec-collection_matchers", "~> 1.2.0"
gem "rspec-json_expectations", "~> 2.1"
gem "webmock", "~> 3.0"

View file

@ -73,11 +73,8 @@ GEM
i18n (1.12.0)
concurrent-ruby (~> 1.0)
json (2.6.2)
json-schema (2.8.1)
addressable (>= 2.4)
json-schema-rspec (0.0.4)
json-schema (~> 2.5)
rspec
json-schema (3.0.0)
addressable (>= 2.8)
listen (3.7.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
@ -229,7 +226,7 @@ DEPENDENCIES
diaspora_federation-rails!
diaspora_federation-test!
fuubar (= 2.5.1)
json-schema-rspec (= 0.0.4)
json-schema (~> 3.0)
listen
nyan-cat-formatter
pronto (= 0.11.0)

View file

@ -29,7 +29,6 @@ else
end
# test helpers
require "json-schema-rspec"
require "rspec/collection_matchers"
require "rspec/json_expectations"
require "webmock/rspec"
@ -45,9 +44,6 @@ require "entities"
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each {|f| require f }
RSpec.configure do |config|
config.include JSON::SchemaMatchers
config.json_schemas[:entity_schema] = "lib/diaspora_federation/schemas/federation_entities.json"
config.example_status_persistence_file_path = "spec/rspec-persistence.txt"
config.expect_with :rspec do |expect_config|

View file

@ -1,5 +1,7 @@
# frozen_string_literal: true
require "json-schema"
def entity_hash_from(hash)
hash.transform_values {|value|
if [String, TrueClass, FalseClass, Integer, NilClass].any? {|c| value.is_a? c }
@ -121,7 +123,8 @@ shared_examples "a JSON Entity" do
describe "#to_json" do
it "#to_json output matches JSON schema" do
json = described_class.new(data).to_json
expect(json.to_json).to match_json_schema(:entity_schema)
errors = JSON::Validator.fully_validate("lib/diaspora_federation/schemas/federation_entities.json", json.to_json)
expect(errors).to be_empty
end
let(:to_json_output) { described_class.new(data).to_json.to_json }
@ -176,6 +179,7 @@ shared_examples "a relayable JSON entity" do
it "matches JSON schema with empty string signatures" do
json = described_class.new(data).to_json
json[:entity_data][:author_signature] = ""
expect(json.to_json).to match_json_schema(:entity_schema)
errors = JSON::Validator.fully_validate("lib/diaspora_federation/schemas/federation_entities.json", json.to_json)
expect(errors).to be_empty
end
end