Skip to content

Commit 6033100

Browse files
committed
Fixes type #to_s
to_s shouldn't be printing the parents
1 parent 81d7b0b commit 6033100

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

lib/csscss/types.rb

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,15 @@ def <(other)
5353
end
5454

5555
def to_s
56-
base = "#{property}: #{value}"
57-
if parents
58-
"#{base} (parents: #{parents})"
59-
else
60-
base
61-
end
56+
"#{property}: #{value}"
6257
end
6358

6459
def inspect
65-
"<#{self.class} #{to_s}>"
60+
if parents
61+
"<#{self.class} #{to_s} (parents: #{parents})>"
62+
else
63+
"<#{self.class} #{to_s}>"
64+
end
6665
end
6766
end
6867

test/csscss/redundancy_analyzer_test.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,19 @@ module Csscss
171171
})
172172
end
173173

174+
it "reduces padding and margin" do
175+
css = %$
176+
.bar { padding: 4px; margin: 5px }
177+
.baz { padding-bottom: 4px}
178+
.foo { margin-right: 5px }
179+
$
180+
181+
RedundancyAnalyzer.new(css).redundancies.must_equal({
182+
[sel(".bar"), sel(".baz")] => [dec("padding-bottom", "4px")],
183+
[sel(".bar"), sel(".foo")] => [dec("margin-right", "5px")]
184+
})
185+
end
186+
174187
# TODO: someday
175188
# it "reports duplication within the same selector" do
176189
# css = %$

0 commit comments

Comments
 (0)