Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Improve inspection of Module #263

Merged
merged 2 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/super_diff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def self.date_like?(value)

def self.primitive?(value)
case value
when true, false, nil, Symbol, Numeric, Regexp, Class, String
when true, false, nil, Symbol, Numeric, Regexp, Class, Module, String
true
else
false
Expand Down
31 changes: 31 additions & 0 deletions spec/unit/super_diff_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1124,6 +1124,37 @@
end
end

context "given a module" do
context "given as_lines: false" do
it "returns the module's name" do
string =
described_class.inspect_object(SuperDiff::Test, as_lines: false)
expect(string).to eq("SuperDiff::Test")
end
end

context "given as_lines: true" do
it "returns the module's name as value" do
tiered_lines =
described_class.inspect_object(
SuperDiff::Test,
as_lines: true,
type: :delete,
indentation_level: 1
)
expect(tiered_lines).to match(
[
an_object_having_attributes(
type: :delete,
indentation_level: 1,
value: "SuperDiff::Test"
)
]
)
end
end
end

# TODO: Add when empty
context "given a custom object" do
context "containing only primitive values" do
Expand Down