From f184ec58184ab55574a12c1c5716a8d5bfe5411e Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Sun, 3 Jul 2022 05:05:09 +0200 Subject: [PATCH] Drop json-schema-rspec and bump json-schema --- Gemfile | 2 +- Gemfile.lock | 9 +++------ spec/spec_helper.rb | 4 ---- spec/support/shared_entity_specs.rb | 8 ++++++-- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/Gemfile b/Gemfile index bab7d6b..3295778 100644 --- a/Gemfile +++ b/Gemfile @@ -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" diff --git a/Gemfile.lock b/Gemfile.lock index 670700b..4444e9e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2515a28..a2d03f2 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -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| diff --git a/spec/support/shared_entity_specs.rb b/spec/support/shared_entity_specs.rb index 2317879..b8adc66 100644 --- a/spec/support/shared_entity_specs.rb +++ b/spec/support/shared_entity_specs.rb @@ -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