sass-embedded 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sass/version.rb +1 -1
- metadata +6 -33
- data/.github/workflows/build.yml +0 -44
- data/.gitignore +0 -45
- data/.rubocop.yml +0 -11
- data/Gemfile +0 -4
- data/Rakefile +0 -23
- data/ext/.gitignore +0 -3
- data/sass-embedded.gemspec +0 -38
- data/test/concurrency_test.rb +0 -34
- data/test/functions_test.rb +0 -387
- data/test/importer_test.rb +0 -155
- data/test/include_paths_test.rb +0 -81
- data/test/indented_syntax_test.rb +0 -61
- data/test/input_test.rb +0 -56
- data/test/output_test.rb +0 -136
- data/test/render_error_test.rb +0 -44
- data/test/render_test.rb +0 -19
- data/test/source_maps_test.rb +0 -182
- data/test/test_helper.rb +0 -30
data/test/importer_test.rb
DELETED
@@ -1,155 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'test_helper'
|
4
|
-
|
5
|
-
module Sass
|
6
|
-
class ImporterTest < MiniTest::Test
|
7
|
-
include TempFileTest
|
8
|
-
|
9
|
-
def setup
|
10
|
-
@embedded = Embedded.new
|
11
|
-
end
|
12
|
-
|
13
|
-
def teardown
|
14
|
-
@embedded.close
|
15
|
-
end
|
16
|
-
|
17
|
-
def render(data, importer)
|
18
|
-
@embedded.render(data: data, importer: importer).css
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_custom_importer_works
|
22
|
-
temp_file('fonts.scss', '.font { color: $var1; }')
|
23
|
-
|
24
|
-
data = <<~SCSS
|
25
|
-
@import "styles";
|
26
|
-
@import "fonts";
|
27
|
-
SCSS
|
28
|
-
|
29
|
-
output = render(data, [
|
30
|
-
lambda { |url, _prev|
|
31
|
-
{ contents: '$var1: #000; .hi { color: $var1; }' } if url =~ /styles/
|
32
|
-
}
|
33
|
-
])
|
34
|
-
|
35
|
-
assert_equal <<~CSS.chomp, output
|
36
|
-
.hi {
|
37
|
-
color: #000;
|
38
|
-
}
|
39
|
-
|
40
|
-
.font {
|
41
|
-
color: #000;
|
42
|
-
}
|
43
|
-
CSS
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_custom_importer_works_with_empty_contents
|
47
|
-
output = render("@import 'fake.scss';", [
|
48
|
-
lambda { |_url, _prev|
|
49
|
-
{ contents: '' }
|
50
|
-
}
|
51
|
-
])
|
52
|
-
|
53
|
-
assert_equal '', output
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_custom_importer_works_with_file
|
57
|
-
temp_file('test.scss', '.test { color: #000; }')
|
58
|
-
|
59
|
-
output = render("@import 'fake.scss';", [
|
60
|
-
lambda { |_url, _prev|
|
61
|
-
{ file: File.absolute_path('test.scss') }
|
62
|
-
}
|
63
|
-
])
|
64
|
-
|
65
|
-
assert_equal <<~CSS.chomp, output
|
66
|
-
.test {
|
67
|
-
color: #000;
|
68
|
-
}
|
69
|
-
CSS
|
70
|
-
end
|
71
|
-
|
72
|
-
def test_custom_importer_comes_after_local_file
|
73
|
-
temp_file('test.scss', '.test { color: #000; }')
|
74
|
-
|
75
|
-
output = render("@import 'test.scss';", [
|
76
|
-
lambda { |_url, _prev|
|
77
|
-
return { contents: '.h1 { color: #fff; }' }
|
78
|
-
}
|
79
|
-
])
|
80
|
-
|
81
|
-
assert_equal <<~CSS.chomp, output
|
82
|
-
.test {
|
83
|
-
color: #000;
|
84
|
-
}
|
85
|
-
CSS
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_custom_importer_that_does_not_resolve
|
89
|
-
assert_raises(RenderError) do
|
90
|
-
render("@import 'test.scss';", [
|
91
|
-
lambda { |_url, _prev|
|
92
|
-
}
|
93
|
-
])
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
def test_custom_importer_that_returns_error
|
98
|
-
assert_raises(RenderError) do
|
99
|
-
render("@import 'test.scss';", [
|
100
|
-
lambda { |_url, _prev|
|
101
|
-
IOError.new 'test error'
|
102
|
-
}
|
103
|
-
])
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
def test_custom_importer_that_raises_error
|
108
|
-
assert_raises(RenderError) do
|
109
|
-
render("@import 'test.scss';", [
|
110
|
-
lambda { |_url, _prev|
|
111
|
-
raise IOError, 'test error'
|
112
|
-
}
|
113
|
-
])
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
def test_parent_path_is_accessible
|
118
|
-
output = @embedded.render(data: "@import 'parent.scss';",
|
119
|
-
file: 'import-parent-filename.scss',
|
120
|
-
importer: [
|
121
|
-
lambda { |_url, prev|
|
122
|
-
{ contents: ".#{prev} { color: red; }" }
|
123
|
-
}
|
124
|
-
]).css
|
125
|
-
|
126
|
-
assert_equal <<~CSS.chomp, output
|
127
|
-
.import-parent-filename.scss {
|
128
|
-
color: red;
|
129
|
-
}
|
130
|
-
CSS
|
131
|
-
end
|
132
|
-
|
133
|
-
def test_call_embedded_importer
|
134
|
-
output = @embedded.render(data: "@import 'parent.scss';",
|
135
|
-
importer: [
|
136
|
-
lambda { |_url, _prev|
|
137
|
-
{
|
138
|
-
contents: @embedded.render(data: "@import 'parent-parent.scss'",
|
139
|
-
importer: [
|
140
|
-
lambda { |_url, _prev|
|
141
|
-
{ contents: 'h1 { color: black; }' }
|
142
|
-
}
|
143
|
-
]).css
|
144
|
-
}
|
145
|
-
}
|
146
|
-
]).css
|
147
|
-
|
148
|
-
assert_equal <<~CSS.chomp, output
|
149
|
-
h1 {
|
150
|
-
color: black;
|
151
|
-
}
|
152
|
-
CSS
|
153
|
-
end
|
154
|
-
end
|
155
|
-
end
|
data/test/include_paths_test.rb
DELETED
@@ -1,81 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'test_helper'
|
4
|
-
|
5
|
-
module Sass
|
6
|
-
class IncludePathsTest < MiniTest::Test
|
7
|
-
include TempFileTest
|
8
|
-
|
9
|
-
def setup
|
10
|
-
@embedded = Embedded.new
|
11
|
-
end
|
12
|
-
|
13
|
-
def teardown
|
14
|
-
@embedded.close
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_include_paths
|
18
|
-
temp_dir('included_1')
|
19
|
-
temp_dir('included_2')
|
20
|
-
|
21
|
-
temp_file('included_1/import_parent.scss', '$s: 30px;')
|
22
|
-
temp_file('included_2/import.scss', "@use 'import_parent' as *; $size: $s;")
|
23
|
-
temp_file('styles.scss', "@use 'import.scss' as *; .hi { width: $size; }")
|
24
|
-
|
25
|
-
css = <<~CSS.chomp
|
26
|
-
.hi {
|
27
|
-
width: 30px;
|
28
|
-
}
|
29
|
-
CSS
|
30
|
-
|
31
|
-
assert_equal css, @embedded.render(file: 'styles.scss',
|
32
|
-
include_paths: %w[
|
33
|
-
included_1 included_2
|
34
|
-
]).css
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_global_include_paths
|
38
|
-
temp_dir('included_1')
|
39
|
-
temp_dir('included_2')
|
40
|
-
|
41
|
-
temp_file('included_1/import_parent.scss', '$s: 30px;')
|
42
|
-
temp_file('included_2/import.scss', "@use 'import_parent' as *; $size: $s;")
|
43
|
-
temp_file('styles.scss', "@use 'import.scss' as *; .hi { width: $size; }")
|
44
|
-
|
45
|
-
::Sass.include_paths << 'included_1'
|
46
|
-
::Sass.include_paths << 'included_2'
|
47
|
-
|
48
|
-
css = <<~CSS.chomp
|
49
|
-
.hi {
|
50
|
-
width: 30px;
|
51
|
-
}
|
52
|
-
CSS
|
53
|
-
|
54
|
-
assert_equal css, @embedded.render(file: 'styles.scss').css
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_include_paths_from_env
|
58
|
-
expected_include_paths = %w[included_3 included_4]
|
59
|
-
|
60
|
-
::Sass.instance_eval { @include_paths = nil }
|
61
|
-
|
62
|
-
ENV['SASS_PATH'] = expected_include_paths.join(File::PATH_SEPARATOR)
|
63
|
-
|
64
|
-
assert_equal expected_include_paths, ::Sass.include_paths
|
65
|
-
|
66
|
-
::Sass.include_paths.clear
|
67
|
-
end
|
68
|
-
|
69
|
-
def test_include_paths_not_configured
|
70
|
-
temp_dir('included_5')
|
71
|
-
temp_dir('included_6')
|
72
|
-
temp_file('included_5/import_parent.scss', '$s: 30px;')
|
73
|
-
temp_file('included_6/import.scss', "@use 'import_parent' as *; $size: $s;")
|
74
|
-
temp_file('styles.scss', "@use 'import.scss' as *; .hi { width: $size; }")
|
75
|
-
|
76
|
-
assert_raises(RenderError) do
|
77
|
-
@embedded.render(file: 'styles.scss')
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'test_helper'
|
4
|
-
|
5
|
-
module Sass
|
6
|
-
class IndentedSyntaxTest < MiniTest::Test
|
7
|
-
include TempFileTest
|
8
|
-
|
9
|
-
def setup
|
10
|
-
@embedded = Embedded.new
|
11
|
-
end
|
12
|
-
|
13
|
-
def teardown
|
14
|
-
@embedded.close
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_input_data_with_indented_syntax
|
18
|
-
sass = <<~SASS
|
19
|
-
$size: 30px
|
20
|
-
.foo
|
21
|
-
width: $size
|
22
|
-
SASS
|
23
|
-
|
24
|
-
css = <<~CSS.chomp
|
25
|
-
.foo {
|
26
|
-
width: 30px;
|
27
|
-
}
|
28
|
-
CSS
|
29
|
-
|
30
|
-
assert_raises(RenderError) do
|
31
|
-
@embedded.render(data: sass)
|
32
|
-
end
|
33
|
-
|
34
|
-
assert_raises(RenderError) do
|
35
|
-
@embedded.render(data: sass, indented_syntax: false)
|
36
|
-
end
|
37
|
-
|
38
|
-
assert_equal css, @embedded.render(data: sass, indented_syntax: true).css
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_input_file_with_indented_syntax
|
42
|
-
sass = <<~SASS
|
43
|
-
$size: 30px
|
44
|
-
.foo
|
45
|
-
width: $size
|
46
|
-
SASS
|
47
|
-
|
48
|
-
css = <<~CSS.chomp
|
49
|
-
.foo {
|
50
|
-
width: 30px;
|
51
|
-
}
|
52
|
-
CSS
|
53
|
-
|
54
|
-
temp_file('style.sass', sass)
|
55
|
-
|
56
|
-
assert_equal css, @embedded.render(file: 'style.sass').css
|
57
|
-
assert_equal css, @embedded.render(file: 'style.sass', indented_syntax: true).css
|
58
|
-
assert_equal css, @embedded.render(file: 'style.sass', indented_syntax: false).css
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
data/test/input_test.rb
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'test_helper'
|
4
|
-
|
5
|
-
module Sass
|
6
|
-
class InputTest < MiniTest::Test
|
7
|
-
include TempFileTest
|
8
|
-
|
9
|
-
def setup
|
10
|
-
@embedded = Embedded.new
|
11
|
-
end
|
12
|
-
|
13
|
-
def teardown
|
14
|
-
@embedded.close
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_input_data
|
18
|
-
scss = <<~SCSS
|
19
|
-
$var: bang;
|
20
|
-
|
21
|
-
.foo {
|
22
|
-
baz: $var;
|
23
|
-
}
|
24
|
-
SCSS
|
25
|
-
|
26
|
-
css = <<~CSS.chomp
|
27
|
-
.foo {
|
28
|
-
baz: bang;
|
29
|
-
}
|
30
|
-
CSS
|
31
|
-
|
32
|
-
result = @embedded.render(data: scss)
|
33
|
-
assert_equal css, result.css
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_input_file
|
37
|
-
scss = <<~SCSS
|
38
|
-
$var: bang;
|
39
|
-
|
40
|
-
.foo {
|
41
|
-
baz: $var;
|
42
|
-
}
|
43
|
-
SCSS
|
44
|
-
|
45
|
-
css = <<~CSS.chomp
|
46
|
-
.foo {
|
47
|
-
baz: bang;
|
48
|
-
}
|
49
|
-
CSS
|
50
|
-
|
51
|
-
temp_file('style.scss', scss)
|
52
|
-
result = @embedded.render(file: 'style.scss')
|
53
|
-
assert_equal css, result.css
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
data/test/output_test.rb
DELETED
@@ -1,136 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'test_helper'
|
4
|
-
|
5
|
-
module Sass
|
6
|
-
class OutputTest < MiniTest::Test
|
7
|
-
include TempFileTest
|
8
|
-
|
9
|
-
def setup
|
10
|
-
@embedded = Embedded.new
|
11
|
-
end
|
12
|
-
|
13
|
-
def teardown
|
14
|
-
@embedded.close
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_output_output_style
|
18
|
-
data = <<~SCSS
|
19
|
-
$var: bang;
|
20
|
-
|
21
|
-
.foo {
|
22
|
-
baz: $var;
|
23
|
-
}
|
24
|
-
SCSS
|
25
|
-
|
26
|
-
assert_equal <<~CSS.chomp, @embedded.render(data: data, output_style: :expanded).css
|
27
|
-
.foo {
|
28
|
-
baz: bang;
|
29
|
-
}
|
30
|
-
CSS
|
31
|
-
|
32
|
-
assert_equal <<~CSS.chomp, @embedded.render(data: data, output_style: :compressed).css
|
33
|
-
.foo{baz:bang}
|
34
|
-
CSS
|
35
|
-
|
36
|
-
assert_raises(ArgumentError) do
|
37
|
-
@embedded.render(data: data, output_style: :nested).css
|
38
|
-
end
|
39
|
-
|
40
|
-
assert_raises(ArgumentError) do
|
41
|
-
@embedded.render(data: data, output_style: :compact).css
|
42
|
-
end
|
43
|
-
|
44
|
-
assert_raises(ArgumentError) do
|
45
|
-
@embedded.render(data: data, output_style: nil).css
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
DATA_INDENT_TEST = <<~SCSS
|
50
|
-
@media all {
|
51
|
-
.foo {
|
52
|
-
baz: bang;
|
53
|
-
}
|
54
|
-
}
|
55
|
-
SCSS
|
56
|
-
|
57
|
-
def test_output_indent_width
|
58
|
-
assert_equal <<~CSS.chomp, @embedded.render(data: DATA_INDENT_TEST, indent_width: 0).css
|
59
|
-
@media all {
|
60
|
-
.foo {
|
61
|
-
baz: bang;
|
62
|
-
}
|
63
|
-
}
|
64
|
-
CSS
|
65
|
-
|
66
|
-
assert_equal <<~CSS.chomp, @embedded.render(data: DATA_INDENT_TEST, indent_width: 1).css
|
67
|
-
@media all {
|
68
|
-
.foo {
|
69
|
-
baz: bang;
|
70
|
-
}
|
71
|
-
}
|
72
|
-
CSS
|
73
|
-
|
74
|
-
assert_equal <<~CSS.chomp, @embedded.render(data: DATA_INDENT_TEST, indent_width: 4).css
|
75
|
-
@media all {
|
76
|
-
.foo {
|
77
|
-
baz: bang;
|
78
|
-
}
|
79
|
-
}
|
80
|
-
CSS
|
81
|
-
|
82
|
-
assert_equal <<~CSS.chomp, @embedded.render(data: DATA_INDENT_TEST, indent_width: 10).css
|
83
|
-
@media all {
|
84
|
-
.foo {
|
85
|
-
baz: bang;
|
86
|
-
}
|
87
|
-
}
|
88
|
-
CSS
|
89
|
-
|
90
|
-
assert_raises(RangeError) do
|
91
|
-
@embedded.render(data: DATA_INDENT_TEST, indent_width: -1).css
|
92
|
-
end
|
93
|
-
|
94
|
-
assert_raises(RangeError) do
|
95
|
-
@embedded.render(data: DATA_INDENT_TEST, indent_width: 11).css
|
96
|
-
end
|
97
|
-
|
98
|
-
assert_raises(ArgumentError) do
|
99
|
-
@embedded.render(data: DATA_INDENT_TEST, indent_width: 3.14).css
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
def test_output_indent_type
|
104
|
-
assert_equal <<~CSS.chomp, @embedded.render(data: DATA_INDENT_TEST, indent_type: :tab).css
|
105
|
-
@media all {
|
106
|
-
\t\t.foo {
|
107
|
-
\t\t\t\tbaz: bang;
|
108
|
-
\t\t}
|
109
|
-
}
|
110
|
-
CSS
|
111
|
-
|
112
|
-
assert_equal <<~CSS.chomp, @embedded.render(data: DATA_INDENT_TEST, indent_width: 1, indent_type: 'tab').css
|
113
|
-
@media all {
|
114
|
-
\t.foo {
|
115
|
-
\t\tbaz: bang;
|
116
|
-
\t}
|
117
|
-
}
|
118
|
-
CSS
|
119
|
-
end
|
120
|
-
|
121
|
-
def test_output_linefeed
|
122
|
-
data = <<~SCSS
|
123
|
-
$var: bang;
|
124
|
-
|
125
|
-
.foo {
|
126
|
-
baz: $var;
|
127
|
-
}
|
128
|
-
SCSS
|
129
|
-
|
130
|
-
assert_equal ".foo {\n baz: bang;\n}", @embedded.render(data: data, linefeed: :lf).css
|
131
|
-
assert_equal ".foo {\n\r baz: bang;\n\r}", @embedded.render(data: data, linefeed: :lfcr).css
|
132
|
-
assert_equal ".foo {\r baz: bang;\r}", @embedded.render(data: data, linefeed: :cr).css
|
133
|
-
assert_equal ".foo {\r\n baz: bang;\r\n}", @embedded.render(data: data, linefeed: :crlf).css
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|