Skip to content

Commit 8b72847

Browse files
committed
Rubocop for Ruby 3.3+
1 parent 5c4682a commit 8b72847

7 files changed

Lines changed: 15 additions & 23 deletions

File tree

lib/cataract.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ class << self
8686
#
8787
# @see Stylesheet#parse
8888
# @see Stylesheet.parse
89-
def parse_css(css, **options)
90-
Stylesheet.parse(css, **options)
89+
def parse_css(css, **)
90+
Stylesheet.parse(css, **)
9191
end
9292

9393
# Flatten CSS rules according to CSS cascade rules.

test/flatten/test_shorthand_expansion.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,17 +221,15 @@ def test_background_gradient_with_color
221221
decls = parse_and_flatten('.test { background: red linear-gradient(to right, rgba(255,255,255,0.5), transparent) }')
222222

223223
# Should have both color and gradient
224-
assert_match(/linear-gradient/, decls['background'])
225-
assert_match(/red/, decls['background'])
224+
assert_equal 'red linear-gradient(to right, rgba(255,255,255,0.5), transparent)', decls['background']
226225
end
227226

228227
def test_background_multiple_gradients
229228
# Multiple gradients (layered backgrounds)
230229
decls = parse_and_flatten('.test { background: linear-gradient(#fff, #000), radial-gradient(circle, red, blue) }')
231230

232231
# Should preserve both gradients
233-
assert_match(/linear-gradient/, decls['background'])
234-
assert_match(/radial-gradient/, decls['background'])
232+
assert_equal 'linear-gradient(#fff, #000), radial-gradient(circle, red, blue)', decls['background']
235233
end
236234

237235
# Layered backgrounds are comma-separated and reach the expander one part per

test/parse/test_import_statement.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,6 @@ def test_import_statement_as_hash_key
267267

268268
def test_import_statement_in_set
269269
# Test that ImportStatements work in Sets (requires proper hash/eql?)
270-
require 'set'
271270

272271
import1 = Cataract::ImportStatement.make(id: 0, url: 'styles.css', media: 'screen')
273272
import2 = Cataract::ImportStatement.make(id: 99, url: 'styles.css', media: 'screen', resolved: true) # Equal to import1

test/serialization/test_media_query_list_serialization.rb

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -177,16 +177,17 @@ def test_to_s_with_media_filter_preserves_list_when_applicable
177177
css = '@media screen, print { body { color: red; } } @media handheld { p { margin: 0; } }'
178178
sheet = Cataract::Stylesheet.parse(css)
179179

180-
# When filtering to :screen, should only output the screen rule
181-
# But since original was "screen, print", we might serialize as just "@media screen"
182-
# This is acceptable - we only preserve the list when ALL members are included
183180
output = sheet.to_s(media: :screen)
181+
reparsed = Cataract::Stylesheet.parse(output)
184182

185-
# Should contain screen rule but NOT handheld
186-
assert_match(/@media screen/, output)
187-
assert_match(/body \{ color: red; \}/, output)
188-
refute_match(/handheld/, output)
189-
refute_match(/p \{ margin: 0; \}/, output)
183+
# Filtering to :screen keeps the rule, and its "screen, print" list is
184+
# carried through intact rather than narrowed to just the media asked for.
185+
assert_has_selector 'body', reparsed, media: :screen
186+
assert_has_selector 'body', reparsed, media: :print
187+
assert_has_property({ color: 'red' }, reparsed.with_media(:screen).with_selector('body').first)
188+
189+
# The handheld rule is dropped entirely.
190+
assert_empty reparsed.with_selector('p').to_a
190191
end
191192

192193
def test_to_s_with_multiple_media_filter_preserves_list

test/support/color_conversion_test_helper.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ module ColorConversionTestHelper
1818
# from: :hex, to: :rgb
1919
# )
2020
# assert_equal 'rgb(255, 0, 0)', decls['background-color']
21-
def convert_and_get_declarations(css, **options)
21+
def convert_and_get_declarations(css, **)
2222
sheet = Cataract.parse_css(css)
23-
sheet.convert_colors!(**options)
23+
sheet.convert_colors!(**)
2424

2525
# Flatten all rules to get final cascaded declarations
2626
flattened = sheet.flatten

test/test_rule.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,6 @@ def test_rules_as_hash_keys
176176
end
177177

178178
def test_rules_in_set
179-
require 'set'
180-
181179
sheet1 = Cataract.parse_css('.box { margin: 10px; }')
182180
sheet2 = Cataract.parse_css('.box { margin-top: 10px; margin-right: 10px; margin-bottom: 10px; margin-left: 10px; }')
183181

@@ -367,8 +365,6 @@ def test_selector_list_id_does_not_affect_hash
367365
end
368366

369367
def test_selector_list_id_works_in_set
370-
require 'set'
371-
372368
decls = [Cataract::Declaration.new('color', 'red', false)]
373369

374370
rule1 = Cataract::Rule.make(

test/test_stylesheet.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,8 +537,6 @@ def test_stylesheets_as_hash_keys
537537
end
538538

539539
def test_stylesheets_in_set
540-
require 'set'
541-
542540
sheet1 = Cataract.parse_css('.box { margin: 10px; }')
543541
sheet2 = Cataract.parse_css('.box { margin-top: 10px; margin-right: 10px; margin-bottom: 10px; margin-left: 10px; }')
544542

0 commit comments

Comments
 (0)