From 957cb1f83dcaad721996220905441800e965d9e7 Mon Sep 17 00:00:00 2001 From: Matt Taylor <3680737+matt-taylor@users.noreply.github.com> Date: Sun, 13 Mar 2022 12:36:05 -0700 Subject: [PATCH] Introspection change (#8) --- Gemfile.lock | 2 +- lib/json_schematize/introspect.rb | 3 ++- lib/json_schematize/version.rb | 2 +- spec/lib/json_schematize/generator_spec.rb | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 8a05df5..e147a3f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - json_schematize (0.4.0) + json_schematize (0.5.0) GEM remote: https://rubygems.org/ diff --git a/lib/json_schematize/introspect.rb b/lib/json_schematize/introspect.rb index 75fba63..a6a870a 100644 --- a/lib/json_schematize/introspect.rb +++ b/lib/json_schematize/introspect.rb @@ -22,6 +22,7 @@ def deep_inspect(with_raw_params: false, with_field: false) end def inspect - "#<#{self.class} - required fields: #{self.class.required_fields.map(&:name)}; optional fields: #{self.class.optional_fields.map(&:name)}>" + stringify = to_h.map { |k, v| "#{k}:#{v}" }.join(", ") + "#<#{self.class} - required fields: #{self.class.required_fields.map(&:name)}; #{stringify}>" end end diff --git a/lib/json_schematize/version.rb b/lib/json_schematize/version.rb index 45080fa..d36b38b 100644 --- a/lib/json_schematize/version.rb +++ b/lib/json_schematize/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module JsonSchematize - VERSION = "0.5.0" + VERSION = "0.5.1" end diff --git a/spec/lib/json_schematize/generator_spec.rb b/spec/lib/json_schematize/generator_spec.rb index f5e9ecd..485da8c 100644 --- a/spec/lib/json_schematize/generator_spec.rb +++ b/spec/lib/json_schematize/generator_spec.rb @@ -220,7 +220,7 @@ class IntrospectKlassInspect < described_class end IntrospectKlassInspect end - let(:expected) { "#<#{klass} - required fields: #{params.keys}; optional fields: []>" } + let(:expected) { "#<#{klass} - required fields: #{params.keys}; #{instance.to_h.map { |k, v| "#{k}:#{v}" }.join(", ")}>" } it { is_expected.to eq(expected) } end end