forked from mati0090/css_splitter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcss_splitter_test.rb
More file actions
41 lines (30 loc) · 1.33 KB
/
css_splitter_test.rb
File metadata and controls
41 lines (30 loc) · 1.33 KB
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
39
40
41
require 'test_helper'
class CssSplitterTest < ActiveSupport::TestCase
setup :clear_assets_cache
test "truth" do
assert_kind_of Module, CssSplitter
end
test "asset pipeline stylesheet splitting" do
part1 = "#test{background-color:red}" * CssSplitter::Splitter::MAX_SELECTORS_DEFAULT
part2 = "#test{background-color:green}" * CssSplitter::Splitter::MAX_SELECTORS_DEFAULT
part3 = "#test{background-color:blue}"
assert_equal "#{part1}#{part2}#{part3}\n", assets["erb_stylesheet"].to_s
assert_equal "#{part2}\n", assets["erb_stylesheet_split2"].to_s
assert_equal "#{part3}\n", assets["erb_stylesheet_split3"].to_s
end
test "asset pipeline stylesheet splitting on stylesheet combined using requires" do
red = "#test{background-color:red}" * 100
green = "#test{background-color:green}" * CssSplitter::Splitter::MAX_SELECTORS_DEFAULT
blue = "#test{background-color:blue}"
assert_equal "#{red}#{green}#{blue}\n", assets["combined"].to_s
assert_equal "#{"#test{background-color:green}" * 100}#{blue}\n", assets["combined_split2"].to_s
end
private
def clear_assets_cache
assets_cache = Rails.root.join("tmp/cache/assets")
assets_cache.rmtree if assets_cache.exist?
end
def assets
Rails.application.assets
end
end