From ed08fc1c2f32339d271e5b9b1b0906a2ab602a2d Mon Sep 17 00:00:00 2001 From: Anton Date: Tue, 6 Aug 2024 01:04:54 +0900 Subject: [PATCH] Refactor model type handling and improve result serialization Refactor code to replace "model_type" with "direction" throughout various modules for better readability and consistency. Improve the `to_hash` method in the `Datory::Result` class to exclude ignored keys and handle nested hashes correctly. Update attributes and examples to reflect these changes. --- lib/datory/attributes/attribute.rb | 8 +- .../deserialization/service_builder.rb | 4 +- lib/datory/attributes/dsl.rb | 4 +- lib/datory/attributes/model.rb | 29 +--- lib/datory/attributes/workspace.rb | 4 +- lib/datory/context/callable.rb | 12 +- lib/datory/context/workspace.rb | 4 +- lib/datory/result.rb | 17 ++- spec/examples/usual/example1/serial_spec.rb | 124 +++++++++--------- spec/examples/usual/example2/product_spec.rb | 8 +- spec/examples/usual/example3/language_spec.rb | 54 ++++---- spec/examples/usual/example4/comment_spec.rb | 8 +- 12 files changed, 137 insertions(+), 139 deletions(-) diff --git a/lib/datory/attributes/attribute.rb b/lib/datory/attributes/attribute.rb index 887c7ee..a1f613f 100644 --- a/lib/datory/attributes/attribute.rb +++ b/lib/datory/attributes/attribute.rb @@ -51,8 +51,8 @@ def input_serialization_options # rubocop:disable Metrics/AbcSize, Metrics/Metho def output_serialization_options # rubocop:disable Metrics/AbcSize hash = { - consists_of: to.consists_of == Hash ? Datory::Result : from.consists_of, - type: to.type == Datory::Result ? Hash : from.type + consists_of: from.consists_of, + type: from.type } hash[:min] = from.min if from.min.present? @@ -97,8 +97,8 @@ def input_deserialization_options # rubocop:disable Metrics/MethodLength, Metric def output_deserialization_options # rubocop:disable Metrics/AbcSize hash = { - consists_of: from.consists_of == Hash ? Datory::Result : to.consists_of, - type: from.type == Hash ? Datory::Result : to.type + consists_of: to.consists_of, + type: to.type } hash[:min] = to.min if to.min.present? diff --git a/lib/datory/attributes/deserialization/service_builder.rb b/lib/datory/attributes/deserialization/service_builder.rb index da0a3dc..be13e3f 100644 --- a/lib/datory/attributes/deserialization/service_builder.rb +++ b/lib/datory/attributes/deserialization/service_builder.rb @@ -19,7 +19,9 @@ def initialize(context, incoming_attributes, collection_of_attributes) def build! ServiceFactory.create(@context.class, @collection_of_attributes) - builder_class.call!(**@incoming_attributes) + result = builder_class.call!(**@incoming_attributes) + + @context.class.serialization.new(**result.to_hash) end private diff --git a/lib/datory/attributes/dsl.rb b/lib/datory/attributes/dsl.rb index cc336ba..d16356a 100644 --- a/lib/datory/attributes/dsl.rb +++ b/lib/datory/attributes/dsl.rb @@ -29,7 +29,7 @@ def one!(name, include:, to: nil) to: to.presence || name, from: [include, Hash], include: include, - as: [include, Datory::Result, Hash] + as: [include, Hash] ) end # NOTE: This will most likely be marked as deprecated in the future in favor of `one!` @@ -51,7 +51,7 @@ def many!(name, include:, to: nil) name, to: to.presence || name, from: Array, - consists_of: [include, Datory::Result, Hash], + consists_of: [include, Hash], include: include, as: Array ) diff --git a/lib/datory/attributes/model.rb b/lib/datory/attributes/model.rb index 70aec15..7cd6fd1 100644 --- a/lib/datory/attributes/model.rb +++ b/lib/datory/attributes/model.rb @@ -7,42 +7,21 @@ def self.build!(...) new(...).build! end - def initialize(context, model_type, attributes, collection_of_attributes) + def initialize(context, direction, attributes, collection_of_attributes) @context = context - @model_type = model_type + @direction = direction @attributes = attributes @collection_of_attributes = collection_of_attributes end def build! @collection_of_attributes.each do |attribute| - attribute_name = @model_type == :serialization ? attribute.to.name : attribute.from.name + attribute_name = @direction.serialization? ? attribute.to.name : attribute.from.name attribute_value = @attributes.fetch(attribute_name, nil) - if attribute_value.is_a?(Hash) - # TODO - else - assign_attribute_for(@context, name: attribute_name, value: attribute_value) - end + assign_attribute_for(@context, name: attribute_name, value: attribute_value) end - # @attributes.each do |attribute_name, attribute_value| - # if attribute_value.is_a?(Hash) - # # nested_attribute = @collection_of_attributes.find_by(name: attribute_name) - # # - # # nested_result = - # # if nested_attribute.present? - # # nested_attribute.to.include_class.new(**attribute_value) - # # else - # # attribute_value - # # end - # # - # # assign_attribute_for(nested_attribute.to.include_class, name: attribute_name, value: nested_result) - # else - # assign_attribute_for(@context, name: attribute_name, value: attribute_value) - # end - # end - @context end diff --git a/lib/datory/attributes/workspace.rb b/lib/datory/attributes/workspace.rb index cae3e1e..f7c9a55 100644 --- a/lib/datory/attributes/workspace.rb +++ b/lib/datory/attributes/workspace.rb @@ -24,10 +24,10 @@ def deserialize(incoming_attributes:, collection_of_attributes:) Deserialization::ServiceBuilder.build!(self, incoming_attributes, collection_of_attributes) end - def to_model(model_type:, attributes:, collection_of_attributes:) + def to_model(direction:, attributes:, collection_of_attributes:) super - Model.build!(self, model_type, attributes, collection_of_attributes) + Model.build!(self, direction, attributes, collection_of_attributes) self end diff --git a/lib/datory/context/callable.rb b/lib/datory/context/callable.rb index 6eaf2b8..6245c25 100644 --- a/lib/datory/context/callable.rb +++ b/lib/datory/context/callable.rb @@ -58,14 +58,16 @@ def new(_datory_to_model: true, **attributes) # rubocop:disable Lint/UnderscoreP return context unless _datory_to_model - model_type = :serialization + direction = :serialization if defined?(@_datory_model_type) && @_datory_model_type[context.class.name].present? - model_type = @_datory_model_type.fetch(context.class.name) + direction = @_datory_model_type.fetch(context.class.name) @_datory_model_type.delete(context.class.name) end - _to_model(context, model_type: model_type, **attributes) + direction = direction.to_s.inquiry + + _to_model(context, direction: direction, **attributes) end def describe @@ -106,10 +108,10 @@ def _deserialize(context, **attributes) ) end - def _to_model(context, model_type:, **attributes) + def _to_model(context, direction:, **attributes) context.send( :_to_model, - model_type: model_type, + direction: direction, attributes: attributes, collection_of_attributes: collection_of_attributes ) diff --git a/lib/datory/context/workspace.rb b/lib/datory/context/workspace.rb index 1b08848..ff2ed7c 100644 --- a/lib/datory/context/workspace.rb +++ b/lib/datory/context/workspace.rb @@ -33,9 +33,9 @@ def _deserialize(incoming_attributes:, collection_of_attributes:) ) end - def _to_model(model_type:, attributes:, collection_of_attributes:) + def _to_model(direction:, attributes:, collection_of_attributes:) to_model( - model_type: model_type, + direction: direction, attributes: attributes, collection_of_attributes: collection_of_attributes ) diff --git a/lib/datory/result.rb b/lib/datory/result.rb index 2b0d7c4..71943cc 100644 --- a/lib/datory/result.rb +++ b/lib/datory/result.rb @@ -1,5 +1,20 @@ # frozen_string_literal: true module Datory - class Result < Servactory::Result; end + class Result < Servactory::Result + IGNORED_KEYS = %i[success? failure?].freeze + private_constant :IGNORED_KEYS + + def to_hash(result = self) + result.methods(false).filter do |key| + !key.in?(IGNORED_KEYS) + end.to_h do |key| # rubocop:disable Style/MultilineBlockChain + value = result.public_send(key) + + value = value.except(*IGNORED_KEYS) if value.is_a?(Hash) + + [key.to_s.delete_prefix("@").to_sym, value] + end.compact + end + end end diff --git a/spec/examples/usual/example1/serial_spec.rb b/spec/examples/usual/example1/serial_spec.rb index 2cb1d93..274817c 100644 --- a/spec/examples/usual/example1/serial_spec.rb +++ b/spec/examples/usual/example1/serial_spec.rb @@ -571,8 +571,8 @@ let(:json) { serial } specify "root", :aggregate_failures do - expect(perform).to be_a(Servactory::Result) - expect(perform).to an_instance_of(Datory::Result) + expect(perform).to be_a(Usual::Example1::Serial) # rubocop:disable RSpec/DescribedClass + expect(perform).to an_instance_of(Usual::Example1::Serial) # rubocop:disable RSpec/DescribedClass expect(perform).to( have_attributes( @@ -590,8 +590,8 @@ end specify "poster", :aggregate_failures do - expect(perform.poster).to be_a(Servactory::Result) - expect(perform.poster).to an_instance_of(Datory::Result) + expect(perform.poster).to be_a(Usual::Example1::Image) + expect(perform.poster).to an_instance_of(Usual::Example1::Image) expect(perform.poster).to( have_attributes( @@ -604,8 +604,8 @@ specify "countries", :aggregate_failures do expect(perform.countries).to be_an(Array) - expect(perform.countries).to all be_a(Servactory::Result) - expect(perform.countries).to all an_instance_of(Datory::Result) + expect(perform.countries).to all be_a(Usual::Example1::Country) + expect(perform.countries).to all an_instance_of(Usual::Example1::Country) expect(perform.countries.first).to( have_attributes( @@ -616,8 +616,8 @@ end specify "genres", :aggregate_failures do - expect(perform.genres).to all be_a(Servactory::Result) - expect(perform.genres).to all an_instance_of(Datory::Result) + expect(perform.genres).to all be_a(Usual::Example1::Genre) + expect(perform.genres).to all an_instance_of(Usual::Example1::Genre) expect(perform.genres.first).to( have_attributes( @@ -642,8 +642,8 @@ end specify "seasons", :aggregate_failures do - expect(perform.seasons).to all be_a(Servactory::Result) - expect(perform.seasons).to all an_instance_of(Datory::Result) + expect(perform.seasons).to all be_a(Usual::Example1::Season) + expect(perform.seasons).to all an_instance_of(Usual::Example1::Season) expect(perform.seasons.first).to( have_attributes( @@ -656,8 +656,8 @@ end specify "ratings", :aggregate_failures do - expect(perform.ratings).to be_a(Servactory::Result) - expect(perform.ratings).to an_instance_of(Datory::Result) + expect(perform.ratings).to be_a(Usual::Example1::Ratings) + expect(perform.ratings).to an_instance_of(Usual::Example1::Ratings) expect(perform.ratings).to( have_attributes( @@ -677,8 +677,8 @@ specify "root", :aggregate_failures do expect(perform).to be_an(Array) - expect(perform).to all be_a(Servactory::Result) - expect(perform).to all an_instance_of(Datory::Result) + expect(perform).to all be_a(Usual::Example1::Serial) # rubocop:disable RSpec/DescribedClass + expect(perform).to all an_instance_of(Usual::Example1::Serial) # rubocop:disable RSpec/DescribedClass expect(perform).to( all( @@ -698,8 +698,8 @@ end specify "poster", :aggregate_failures do - expect(perform.first.poster).to be_a(Servactory::Result) - expect(perform.first.poster).to an_instance_of(Datory::Result) + expect(perform.first.poster).to be_a(Usual::Example1::Image) + expect(perform.first.poster).to an_instance_of(Usual::Example1::Image) expect(perform.first.poster).to( have_attributes( @@ -712,8 +712,8 @@ specify "countries", :aggregate_failures do expect(perform.first.countries).to be_an(Array) - expect(perform.first.countries).to all be_a(Servactory::Result) - expect(perform.first.countries).to all an_instance_of(Datory::Result) + expect(perform.first.countries).to all be_a(Usual::Example1::Country) + expect(perform.first.countries).to all an_instance_of(Usual::Example1::Country) expect(perform.first.countries.first).to( have_attributes( @@ -724,8 +724,8 @@ end specify "genres", :aggregate_failures do - expect(perform.first.genres).to all be_a(Servactory::Result) - expect(perform.first.genres).to all an_instance_of(Datory::Result) + expect(perform.first.genres).to all be_a(Usual::Example1::Genre) + expect(perform.first.genres).to all an_instance_of(Usual::Example1::Genre) expect(perform.first.genres.first).to( have_attributes( @@ -750,8 +750,8 @@ end specify "seasons", :aggregate_failures do - expect(perform.first.seasons).to all be_a(Servactory::Result) - expect(perform.first.seasons).to all an_instance_of(Datory::Result) + expect(perform.first.seasons).to all be_a(Usual::Example1::Season) + expect(perform.first.seasons).to all an_instance_of(Usual::Example1::Season) expect(perform.first.seasons.first).to( have_attributes( @@ -764,8 +764,8 @@ end specify "ratings", :aggregate_failures do - expect(perform.first.ratings).to be_a(Servactory::Result) - expect(perform.first.ratings).to an_instance_of(Datory::Result) + expect(perform.first.ratings).to be_a(Usual::Example1::Ratings) + expect(perform.first.ratings).to an_instance_of(Usual::Example1::Ratings) expect(perform.first.ratings).to( have_attributes( @@ -1101,21 +1101,21 @@ expect { perform }.to( output( <<~TABLE - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - | Usual::Example1::Serial | - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - | Attribute | From | To | As | Include | - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - | id | String | id | String | | - | status | String | status | String | | - | title | String | title | String | | - | poster | [Usual::Example1::Image, Hash] | poster | [Usual::Example1::Image, Datory::Result, Hash] | Usual::Example1::Image | - | ratings | [Usual::Example1::Ratings, Hash] | ratings | [Usual::Example1::Ratings, Datory::Result, Hash] | Usual::Example1::Ratings | - | countries | Array | countries | Array | Usual::Example1::Country | - | genres | Array | genres | Array | Usual::Example1::Genre | - | seasons | Array | seasons | Array | Usual::Example1::Season | - | premieredOn | String | premiered_on | Date | | - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | Usual::Example1::Serial | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | Attribute | From | To | As | Include | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | id | String | id | String | | + | status | String | status | String | | + | title | String | title | String | | + | poster | [Usual::Example1::Image, Hash] | poster | [Usual::Example1::Image, Hash] | Usual::Example1::Image | + | ratings | [Usual::Example1::Ratings, Hash] | ratings | [Usual::Example1::Ratings, Hash] | Usual::Example1::Ratings | + | countries | Array | countries | Array | Usual::Example1::Country | + | genres | Array | genres | Array | Usual::Example1::Genre | + | seasons | Array | seasons | Array | Usual::Example1::Season | + | premieredOn | String | premiered_on | Date | | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TABLE ).to_stdout ) @@ -1217,21 +1217,21 @@ expect { perform }.to( output( <<~TABLE - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - | Usual::Example1::Serial | - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - | Attribute | From | To | As | Include | - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - | id | String | id | String | | - | status | String | status | String | | - | title | String | title | String | | - | poster | [Usual::Example1::Image, Hash] | poster | [Usual::Example1::Image, Datory::Result, Hash] | Usual::Example1::Image | - | ratings | [Usual::Example1::Ratings, Hash] | ratings | [Usual::Example1::Ratings, Datory::Result, Hash] | Usual::Example1::Ratings | - | countries | Array | countries | Array | Usual::Example1::Country | - | genres | Array | genres | Array | Usual::Example1::Genre | - | seasons | Array | seasons | Array | Usual::Example1::Season | - | premieredOn | String | premiered_on | Date | | - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | Usual::Example1::Serial | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | Attribute | From | To | As | Include | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | id | String | id | String | | + | status | String | status | String | | + | title | String | title | String | | + | poster | [Usual::Example1::Image, Hash] | poster | [Usual::Example1::Image, Hash] | Usual::Example1::Image | + | ratings | [Usual::Example1::Ratings, Hash] | ratings | [Usual::Example1::Ratings, Hash] | Usual::Example1::Ratings | + | countries | Array | countries | Array | Usual::Example1::Country | + | genres | Array | genres | Array | Usual::Example1::Genre | + | seasons | Array | seasons | Array | Usual::Example1::Season | + | premieredOn | String | premiered_on | Date | | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TABLE ).to_stdout ) @@ -1408,7 +1408,7 @@ }, to: { name: :poster, - type: [Usual::Example1::Image, Datory::Result, Hash], + type: [Usual::Example1::Image, Hash], required: true, default: nil, min: nil, @@ -1429,7 +1429,7 @@ }, to: { name: :ratings, - type: [Usual::Example1::Ratings, Datory::Result, Hash], + type: [Usual::Example1::Ratings, Hash], required: true, default: nil, consists_of: false, @@ -1445,7 +1445,7 @@ type: Array, min: nil, max: nil, - consists_of: [Usual::Example1::Country, Datory::Result, Hash], + consists_of: [Usual::Example1::Country, Hash], format: nil }, to: { @@ -1455,7 +1455,7 @@ default: nil, min: nil, max: nil, - consists_of: [Usual::Example1::Country, Datory::Result, Hash], + consists_of: [Usual::Example1::Country, Hash], format: nil, include: Usual::Example1::Country } @@ -1466,7 +1466,7 @@ type: Array, min: nil, max: nil, - consists_of: [Usual::Example1::Genre, Datory::Result, Hash], + consists_of: [Usual::Example1::Genre, Hash], format: nil }, to: { @@ -1476,7 +1476,7 @@ default: nil, min: nil, max: nil, - consists_of: [Usual::Example1::Genre, Datory::Result, Hash], + consists_of: [Usual::Example1::Genre, Hash], format: nil, include: Usual::Example1::Genre } @@ -1487,7 +1487,7 @@ type: Array, min: nil, max: nil, - consists_of: [Usual::Example1::Season, Datory::Result, Hash], + consists_of: [Usual::Example1::Season, Hash], format: nil }, to: { @@ -1497,7 +1497,7 @@ default: nil, min: nil, max: nil, - consists_of: [Usual::Example1::Season, Datory::Result, Hash], + consists_of: [Usual::Example1::Season, Hash], format: nil, include: Usual::Example1::Season } diff --git a/spec/examples/usual/example2/product_spec.rb b/spec/examples/usual/example2/product_spec.rb index d82158f..7ff998d 100644 --- a/spec/examples/usual/example2/product_spec.rb +++ b/spec/examples/usual/example2/product_spec.rb @@ -229,8 +229,8 @@ let(:json) { product } specify "root", :aggregate_failures do - expect(perform).to be_a(Servactory::Result) - expect(perform).to an_instance_of(Datory::Result) + expect(perform).to be_a(Usual::Example2::Product) # rubocop:disable RSpec/DescribedClass + expect(perform).to an_instance_of(Usual::Example2::Product) # rubocop:disable RSpec/DescribedClass expect(perform).to( have_attributes( @@ -250,8 +250,8 @@ specify "root", :aggregate_failures do expect(perform).to be_an(Array) - expect(perform).to all be_a(Servactory::Result) - expect(perform).to all an_instance_of(Datory::Result) + expect(perform).to all be_a(Usual::Example2::Product) # rubocop:disable RSpec/DescribedClass + expect(perform).to all an_instance_of(Usual::Example2::Product) # rubocop:disable RSpec/DescribedClass expect(perform).to( all( diff --git a/spec/examples/usual/example3/language_spec.rb b/spec/examples/usual/example3/language_spec.rb index f007b00..0cd02c6 100644 --- a/spec/examples/usual/example3/language_spec.rb +++ b/spec/examples/usual/example3/language_spec.rb @@ -234,8 +234,8 @@ let(:json) { language } specify "root", :aggregate_failures do - expect(perform).to be_a(Servactory::Result) - expect(perform).to an_instance_of(Datory::Result) + expect(perform).to be_a(Usual::Example3::Language) # rubocop:disable RSpec/DescribedClass + expect(perform).to an_instance_of(Usual::Example3::Language) # rubocop:disable RSpec/DescribedClass expect(perform).to( have_attributes( @@ -252,8 +252,8 @@ specify "root", :aggregate_failures do expect(perform).to be_an(Array) - expect(perform).to all be_a(Servactory::Result) - expect(perform).to all an_instance_of(Datory::Result) + expect(perform).to all be_a(Usual::Example3::Language) # rubocop:disable RSpec/DescribedClass + expect(perform).to all an_instance_of(Usual::Example3::Language) # rubocop:disable RSpec/DescribedClass expect(perform).to( all( @@ -370,17 +370,17 @@ expect { perform }.to( output( <<~TABLE - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - | Usual::Example3::Language | - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - | Attribute | From | To | As | Include | - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - | id | String | id | String | | - | name | String | name | String | | - | currentVersion | [Usual::Example3::Version, Hash] | current | [Usual::Example3::Version, Datory::Result, Hash] | Usual::Example3::Version | - | lastEOLVersion | [Usual::Example3::Version, Hash, NilClass] | last_eol | [Usual::Example3::Version, Hash, NilClass] | Usual::Example3::Version | - | previousVersions | Array | previous | Array | Usual::Example3::Version | - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | Usual::Example3::Language | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | Attribute | From | To | As | Include | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | id | String | id | String | | + | name | String | name | String | | + | currentVersion | [Usual::Example3::Version, Hash] | current | [Usual::Example3::Version, Hash] | Usual::Example3::Version | + | lastEOLVersion | [Usual::Example3::Version, Hash, NilClass] | last_eol | [Usual::Example3::Version, Hash, NilClass] | Usual::Example3::Version | + | previousVersions | Array | previous | Array | Usual::Example3::Version | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TABLE ).to_stdout ) @@ -396,17 +396,17 @@ expect { perform }.to( output( <<~TABLE - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - | Usual::Example3::Language | - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - | Attribute | From | To | As | Include | - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - | id | String | id | String | | - | name | String | name | String | | - | currentVersion | [Usual::Example3::Version, Hash] | current | [Usual::Example3::Version, Datory::Result, Hash] | Usual::Example3::Version | - | lastEOLVersion | [Usual::Example3::Version, Hash, NilClass] | last_eol | [Usual::Example3::Version, Hash, NilClass] | Usual::Example3::Version | - | previousVersions | Array | previous | Array | Usual::Example3::Version | - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | Usual::Example3::Language | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | Attribute | From | To | As | Include | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | id | String | id | String | | + | name | String | name | String | | + | currentVersion | [Usual::Example3::Version, Hash] | current | [Usual::Example3::Version, Hash] | Usual::Example3::Version | + | lastEOLVersion | [Usual::Example3::Version, Hash, NilClass] | last_eol | [Usual::Example3::Version, Hash, NilClass] | Usual::Example3::Version | + | previousVersions | Array | previous | Array | Usual::Example3::Version | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TABLE ).to_stdout ) @@ -476,7 +476,7 @@ }, to: { name: :current, - type: [Usual::Example3::Version, Datory::Result, Hash], + type: [Usual::Example3::Version, Hash], required: true, default: nil, min: nil, diff --git a/spec/examples/usual/example4/comment_spec.rb b/spec/examples/usual/example4/comment_spec.rb index 5c5e6ef..bbe1b0c 100644 --- a/spec/examples/usual/example4/comment_spec.rb +++ b/spec/examples/usual/example4/comment_spec.rb @@ -202,8 +202,8 @@ let(:json) { comment } specify "root", :aggregate_failures do - expect(perform).to be_a(Servactory::Result) - expect(perform).to an_instance_of(Datory::Result) + expect(perform).to be_a(Usual::Example4::Comment) # rubocop:disable RSpec/DescribedClass + expect(perform).to an_instance_of(Usual::Example4::Comment) # rubocop:disable RSpec/DescribedClass expect(perform).to( have_attributes( @@ -220,8 +220,8 @@ specify "root", :aggregate_failures do expect(perform).to be_an(Array) - expect(perform).to all be_a(Servactory::Result) - expect(perform).to all an_instance_of(Datory::Result) + expect(perform).to all be_a(Usual::Example4::Comment) # rubocop:disable RSpec/DescribedClass + expect(perform).to all an_instance_of(Usual::Example4::Comment) # rubocop:disable RSpec/DescribedClass expect(perform).to( all(