Sha256: 480d2b7301e2b621336a36a3f5318bccf4dc9407d5f9b29fa544e63504cdcf8b
Contents?: true
Size: 1.26 KB
Versions: 1
Compression:
Stored size: 1.26 KB
Contents
require File.dirname(__FILE__) + '/test_helper' class RuleSetExpandingShorthandTests < Test::Unit::TestCase include CssParser def setup @cp = CssParser::Parser.new end # ==== Dimensions shorthand def test_getting_dimensions_from_shorthand # test various shorthand forms ['margin: 0px auto', 'margin: 0px auto 0px', 'margin: 0px auto 0px'].each do |shorthand| declarations = expand_declarations(shorthand) assert_equal({"margin-right" => "auto", "margin-bottom" => "0px", "margin-left" => "auto", "margin-top" => "0px"}, declarations) end # test various units ['em', 'ex', 'in', 'px', 'pt', 'pc', '%'].each do |unit| shorthand = "margin: 0% -0.123#{unit} 9px -.9pc" declarations = expand_declarations(shorthand) assert_equal({"margin-right" => "-0.123#{unit}", "margin-bottom" => "9px", "margin-left" => "-.9pc", "margin-top" => "0%"}, declarations) end end protected def expand_declarations(declarations) ruleset = RuleSet.new(nil, declarations) ruleset.expand_shorthand! collected = {} # ruleset.each_declaration do |prop, val, imp| ruleset.each_declaration do |decl| collected[decl.property.to_s] = decl.value.to_s end collected end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
css_parser_master-1.2.4 | test/test_ruleset_expand.rb |