Skip to content

Commit f864fb5

Browse files
authored
Add String to primitive list (#262)
`String` is considered a primitive for the purposes of inspection, but was excluded from the `SuperDiff.primitive?` helper in order to support custom multiline and single-line strings in that area of the codebase. A simpler way of achieving the same result is to consider `String` to be a primitive everywhere, and give the custom string equality matchers higher precedence than the primitive equality matcher.
1 parent f17507a commit f864fb5

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

lib/super_diff.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def self.date_like?(value)
113113

114114
def self.primitive?(value)
115115
case value
116-
when true, false, nil, Symbol, Numeric, Regexp, Class
116+
when true, false, nil, Symbol, Numeric, Regexp, Class, String
117117
true
118118
else
119119
false

lib/super_diff/basic/inspection_tree_builders/primitive.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module Basic
33
module InspectionTreeBuilders
44
class Primitive < Core::AbstractInspectionTreeBuilder
55
def self.applies_to?(value)
6-
SuperDiff.primitive?(value) || value.is_a?(::String)
6+
SuperDiff.primitive?(value)
77
end
88

99
def call

lib/super_diff/equality_matchers/defaults.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
module SuperDiff
22
module EqualityMatchers
33
DEFAULTS = [
4-
Primitive,
54
Array,
65
Hash,
76
MultilineString,
87
SinglelineString,
8+
Primitive,
99
Default
1010
].freeze
1111
end

0 commit comments

Comments
 (0)