diff --git a/lib/super_diff.rb b/lib/super_diff.rb index bfada9e7..e177f38f 100644 --- a/lib/super_diff.rb +++ b/lib/super_diff.rb @@ -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 diff --git a/spec/unit/super_diff_spec.rb b/spec/unit/super_diff_spec.rb index d0cbfb17..35082f52 100644 --- a/spec/unit/super_diff_spec.rb +++ b/spec/unit/super_diff_spec.rb @@ -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