-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(inspect): add has_inspect placeholder for message
- Loading branch information
Showing
18 changed files
with
282 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
...sult/entities/result/plugins/has_j_send_status_and_attributes/entities/message/plugins.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "plugins/has_inspect" | ||
|
||
require_relative "plugins/aliases" |
7 changes: 7 additions & 0 deletions
7
...ities/result/plugins/has_j_send_status_and_attributes/entities/message/plugins/aliases.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
module ConvenientService | ||
module Plugins | ||
Message = ::ConvenientService::Service::Plugins::HasResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Message::Plugins | ||
end | ||
end |
3 changes: 3 additions & 0 deletions
3
...ns/has_j_send_status_and_attributes/entities/message/plugins/has_awesome_print_inspect.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "has_awesome_print_inspect/concern" |
46 changes: 46 additions & 0 deletions
46
..._send_status_and_attributes/entities/message/plugins/has_awesome_print_inspect/concern.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# frozen_string_literal: true | ||
|
||
module ConvenientService | ||
module Service | ||
module Plugins | ||
module HasResult | ||
module Entities | ||
class Result | ||
module Plugins | ||
module HasJSendStatusAndAttributes | ||
module Entities | ||
class Message | ||
module Plugins | ||
module HasAwesomePrintInspect | ||
module Concern | ||
include Support::Concern | ||
|
||
instance_methods do | ||
## | ||
# @return [String] | ||
# | ||
def inspect | ||
metadata = { | ||
ConvenientService: { | ||
entity: "Message", | ||
result: result.class.name, | ||
text: to_s | ||
} | ||
} | ||
|
||
metadata.ai | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
3 changes: 3 additions & 0 deletions
3
...s/result/plugins/has_j_send_status_and_attributes/entities/message/plugins/has_inspect.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "has_inspect/concern" |
38 changes: 38 additions & 0 deletions
38
.../plugins/has_j_send_status_and_attributes/entities/message/plugins/has_inspect/concern.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# frozen_string_literal: true | ||
|
||
module ConvenientService | ||
module Service | ||
module Plugins | ||
module HasResult | ||
module Entities | ||
class Result | ||
module Plugins | ||
module HasJSendStatusAndAttributes | ||
module Entities | ||
class Message | ||
module Plugins | ||
module HasInspect | ||
module Concern | ||
include Support::Concern | ||
|
||
instance_methods do | ||
## | ||
# @return [String] | ||
# | ||
def inspect | ||
"<#{self.class} text: \"#{value}\">" | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
.../result/plugins/has_j_send_status_and_attributes/entities/message/plugins/aliases_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
|
||
require "convenient_service" | ||
|
||
# rubocop:disable RSpec/DescribeClass | ||
RSpec.describe "convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/entities/message/plugins/aliases" do | ||
specify { expect(ConvenientService::Plugins::Message).to eq(ConvenientService::Service::Plugins::HasResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Message::Plugins) } | ||
end | ||
# rubocop:enable RSpec/DescribeClass |
64 changes: 64 additions & 0 deletions
64
..._status_and_attributes/entities/message/plugins/has_awesome_print_inspect/concern_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
|
||
require "convenient_service" | ||
|
||
# rubocop:disable RSpec/NestedGroups, RSpec/MultipleMemoizedHelpers | ||
RSpec.describe ConvenientService::Service::Plugins::HasResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Message::Plugins::HasAwesomePrintInspect::Concern do | ||
include ConvenientService::RSpec::Matchers::DelegateTo | ||
|
||
example_group "modules" do | ||
include ConvenientService::RSpec::Matchers::IncludeModule | ||
|
||
subject { described_class } | ||
|
||
it { is_expected.to include_module(ConvenientService::Support::Concern) } | ||
|
||
context "when included" do | ||
subject { message_class } | ||
|
||
let(:message_class) do | ||
Class.new.tap do |klass| | ||
klass.class_exec(described_class) do |mod| | ||
include mod | ||
end | ||
end | ||
end | ||
|
||
it { is_expected.to include_module(described_class::InstanceMethods) } | ||
end | ||
end | ||
|
||
example_group "instance methods" do | ||
describe "#inspect" do | ||
let(:service) do | ||
Class.new do | ||
include ConvenientService::Configs::Minimal | ||
|
||
include ConvenientService::Configs::AwesomePrintInspect | ||
|
||
def result | ||
error(message: "foo") | ||
end | ||
end | ||
end | ||
|
||
let(:message) { service.result.message } | ||
|
||
let(:keywords) { ["ConvenientService", "entity", "Message", "result", message.result.class.name, "text", "foo"] } | ||
|
||
before do | ||
## | ||
# TODO: Remove when Core implements auto committing from `inspect`. | ||
# | ||
message.class.commit_config! | ||
end | ||
|
||
it "returns `inspect` representation of message" do | ||
expect(message.inspect).to include(*keywords) | ||
end | ||
end | ||
end | ||
end | ||
# rubocop:enable RSpec/NestedGroups, RSpec/MultipleMemoizedHelpers |
60 changes: 60 additions & 0 deletions
60
...ins/has_j_send_status_and_attributes/entities/message/plugins/has_inspect/concern_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
|
||
require "convenient_service" | ||
|
||
# rubocop:disable RSpec/NestedGroups, RSpec/MultipleMemoizedHelpers | ||
RSpec.describe ConvenientService::Service::Plugins::HasResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Message::Plugins::HasInspect::Concern do | ||
include ConvenientService::RSpec::Matchers::DelegateTo | ||
|
||
example_group "modules" do | ||
include ConvenientService::RSpec::Matchers::IncludeModule | ||
|
||
subject { described_class } | ||
|
||
it { is_expected.to include_module(ConvenientService::Support::Concern) } | ||
|
||
context "when included" do | ||
subject { message_class } | ||
|
||
let(:message_class) do | ||
Class.new.tap do |klass| | ||
klass.class_exec(described_class) do |mod| | ||
include mod | ||
end | ||
end | ||
end | ||
|
||
it { is_expected.to include_module(described_class::InstanceMethods) } | ||
end | ||
end | ||
|
||
example_group "instance methods" do | ||
describe "#inspect" do | ||
let(:service) do | ||
Class.new do | ||
include ConvenientService::Configs::Minimal | ||
|
||
def result | ||
error(message: "foo") | ||
end | ||
end | ||
end | ||
|
||
let(:message) { service.result.message } | ||
|
||
before do | ||
## | ||
# TODO: Remove when Core implements auto committing from `inspect`. | ||
# | ||
message.class.commit_config! | ||
end | ||
|
||
it "returns `inspect` representation of message" do | ||
expect(message.inspect).to eq("<#{message.class} text: \"#{message}\">") | ||
end | ||
end | ||
end | ||
end | ||
# rubocop:enable RSpec/NestedGroups, RSpec/MultipleMemoizedHelpers |