-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
38 lines (31 loc) · 1.27 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require 'bundler'
Bundler.require
task :test, :sass_file, :bourbon_lib_file do |t, args|
sass_file = args[:sass_file]
bourbon_lib_file = args[:bourbon_lib_file]
system("sass -r #{bourbon_lib_file} #{sass_file}:test.css")
include CssParser
parser = CssParser::Parser.new
parser.load_file!('test.css')
test(parser, '.omega-default', 'margin-right', '0')
test(parser, '.omega-table', 'padding-right', '0')
test(parser, '.omega-default-left', 'margin-left', '0')
test(parser, '.omega-table-left', 'padding-left', '0')
test(parser, '.omega-nth-default:nth-child(4n)', 'margin-right', '0')
test(parser, '.omega-nth-table:nth-child(4n)', 'padding-right', '0')
test(parser, '.omega-nth-default-left:nth-child(4n)', 'margin-left', '0')
test(parser, '.omega-nth-table-left:nth-child(4n)', 'padding-left', '0')
end
def test(parser, selector, declaration, value)
puts
rules = parser.find_by_selector(selector)
rules.each do |rule|
rule_declaration, rule_value = rule.split(":")
rule_value.gsub!(/;|^ /, "")
if rule_declaration == declaration and rule_value == value
puts "passed, #{selector} has #{declaration} equal #{value}"
return
end
end
puts "expected `#{selector}` with `#{declaration}:#{value}` but failed, got only `#{rules}`"
end