parcels 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (158) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +22 -0
  3. data/.rspec-local +4 -0
  4. data/.travis.yml +54 -0
  5. data/Gemfile +6 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +29 -0
  8. data/Rakefile +6 -0
  9. data/lib/parcels/dependency_parcel_list.rb +50 -0
  10. data/lib/parcels/environment.rb +60 -0
  11. data/lib/parcels/fortitude/alongside_engine.rb +37 -0
  12. data/lib/parcels/fortitude/assets.rb +212 -0
  13. data/lib/parcels/fortitude/enabling.rb +72 -0
  14. data/lib/parcels/fortitude/fortitude_engine.rb +35 -0
  15. data/lib/parcels/fortitude/fortitude_loader.rb +27 -0
  16. data/lib/parcels/fortitude/widget_engine.rb +31 -0
  17. data/lib/parcels/fortitude_alongside_parcel.rb +38 -0
  18. data/lib/parcels/fortitude_inline_parcel.rb +31 -0
  19. data/lib/parcels/fortitude_parcel.rb +102 -0
  20. data/lib/parcels/fragments/css_fragment.rb +107 -0
  21. data/lib/parcels/index.rb +16 -0
  22. data/lib/parcels/rails/rails_loader.rb +23 -0
  23. data/lib/parcels/rails/railtie.rb +16 -0
  24. data/lib/parcels/sprockets.rb +153 -0
  25. data/lib/parcels/utils/path_utils.rb +32 -0
  26. data/lib/parcels/version.rb +3 -0
  27. data/lib/parcels/widget_tree.rb +158 -0
  28. data/lib/parcels.rb +21 -0
  29. data/parcels.gemspec +48 -0
  30. data/spec/helpers/content_in_helpers.rb +21 -0
  31. data/spec/helpers/file_structure_helpers.rb +79 -0
  32. data/spec/helpers/global_helper.rb +34 -0
  33. data/spec/helpers/new_asset_helpers.rb +31 -0
  34. data/spec/helpers/new_rails_helpers.rb +31 -0
  35. data/spec/helpers/parcels_rails_helpers.rb +20 -0
  36. data/spec/helpers/per_example_helpers.rb +15 -0
  37. data/spec/helpers/sprockets_helpers.rb +23 -0
  38. data/spec/lib/spec/expected/base_expected_asset.rb +35 -0
  39. data/spec/lib/spec/expected/expected_asset.rb +135 -0
  40. data/spec/lib/spec/expected/expected_asset_set.rb +45 -0
  41. data/spec/lib/spec/expected/must_not_be_present_asset.rb +17 -0
  42. data/spec/lib/spec/fixtures/file_set.rb +80 -0
  43. data/spec/lib/spec/fixtures/widget_base.rb +13 -0
  44. data/spec/lib/spec/fixtures/widget_file.rb +108 -0
  45. data/spec/lib/spec/parsing/compiled_asset.rb +94 -0
  46. data/spec/lib/spec/parsing/compiled_asset_fragment.rb +38 -0
  47. data/spec/lib/spec/parsing/parsed_css_asset.rb +34 -0
  48. data/spec/lib/spec/parsing/precompiled_rails_asset.rb +52 -0
  49. data/spec/lib/spec/parsing/rails_asset.rb +30 -0
  50. data/spec/lib/spec/parsing/sprockets_asset.rb +40 -0
  51. data/spec/rails/basic_rails_spec.rb +102 -0
  52. data/spec/rails/compression_rails_spec.rb +11 -0
  53. data/spec/rails/development_mode_rails_spec.rb +321 -0
  54. data/spec/rails/sass_rails_spec.rb +125 -0
  55. data/spec/rails/sets_rails_spec.rb +85 -0
  56. data/spec/rails/templates/base/app/assets/stylesheets/application.css +16 -0
  57. data/spec/rails/templates/base/app/views/widgets/base.rb +4 -0
  58. data/spec/rails/templates/base/config/environments/production.rb +92 -0
  59. data/spec/rails/templates/base/lib/null_compressor.rb +5 -0
  60. data/spec/rails/templates/basic_rails_spec/app/controllers/basic_rails_spec_controller.rb +21 -0
  61. data/spec/rails/templates/basic_rails_spec/app/views/basic_rails_spec/alongside_and_inline.pcss +1 -0
  62. data/spec/rails/templates/basic_rails_spec/app/views/basic_rails_spec/alongside_and_inline.rb +9 -0
  63. data/spec/rails/templates/basic_rails_spec/app/views/basic_rails_spec/alongside_and_inline_html.html.pcss +1 -0
  64. data/spec/rails/templates/basic_rails_spec/app/views/basic_rails_spec/alongside_and_inline_html.html.rb +9 -0
  65. data/spec/rails/templates/basic_rails_spec/app/views/basic_rails_spec/alongside_erb.pcss +1 -0
  66. data/spec/rails/templates/basic_rails_spec/app/views/basic_rails_spec/alongside_erb.rb +7 -0
  67. data/spec/rails/templates/basic_rails_spec/app/views/basic_rails_spec/inline_erb.rb +9 -0
  68. data/spec/rails/templates/basic_rails_spec/app/views/basic_rails_spec/multiple_engines.pcss +1 -0
  69. data/spec/rails/templates/basic_rails_spec/app/views/basic_rails_spec/multiple_engines.rb +9 -0
  70. data/spec/rails/templates/basic_rails_spec/app/views/basic_rails_spec/no_corresponding_widget.pcss +1 -0
  71. data/spec/rails/templates/basic_rails_spec/app/views/basic_rails_spec/simple_css.rb +9 -0
  72. data/spec/rails/templates/compression_rails_spec/app/controllers/compression_rails_spec_controller.rb +5 -0
  73. data/spec/rails/templates/compression_rails_spec/app/views/compression_rails_spec/inline_and_alongside_css.pcss +1 -0
  74. data/spec/rails/templates/compression_rails_spec/app/views/compression_rails_spec/inline_and_alongside_css.rb +9 -0
  75. data/spec/rails/templates/compression_rails_spec/config/environments/production.rb +91 -0
  76. data/spec/rails/templates/development_mode_rails_spec/app/assets/stylesheets/changingone.scss +1 -0
  77. data/spec/rails/templates/development_mode_rails_spec/app/assets/stylesheets/changingtwo.scss +1 -0
  78. data/spec/rails/templates/development_mode_rails_spec/app/assets/stylesheets/import_dir/import_dir_ss_1.scss +1 -0
  79. data/spec/rails/templates/development_mode_rails_spec/app/controllers/development_mode_rails_spec_controller.rb +45 -0
  80. data/spec/rails/templates/development_mode_rails_spec/app/views/development_mode_rails_spec/adding_alongside_css.rb +5 -0
  81. data/spec/rails/templates/development_mode_rails_spec/app/views/development_mode_rails_spec/adding_inline_css.rb +7 -0
  82. data/spec/rails/templates/development_mode_rails_spec/app/views/development_mode_rails_spec/adding_widget.rb +5 -0
  83. data/spec/rails/templates/development_mode_rails_spec/app/views/development_mode_rails_spec/basic_widget_with_inline_and_alongside_parcels.pcss +3 -0
  84. data/spec/rails/templates/development_mode_rails_spec/app/views/development_mode_rails_spec/basic_widget_with_inline_and_alongside_parcels.rb +9 -0
  85. data/spec/rails/templates/development_mode_rails_spec/app/views/development_mode_rails_spec/changing_alongside_css.pcss +1 -0
  86. data/spec/rails/templates/development_mode_rails_spec/app/views/development_mode_rails_spec/changing_alongside_css.rb +5 -0
  87. data/spec/rails/templates/development_mode_rails_spec/app/views/development_mode_rails_spec/changing_import_file.pcss +2 -0
  88. data/spec/rails/templates/development_mode_rails_spec/app/views/development_mode_rails_spec/changing_import_file.rb +10 -0
  89. data/spec/rails/templates/development_mode_rails_spec/app/views/development_mode_rails_spec/changing_inline_css.rb +9 -0
  90. data/spec/rails/templates/development_mode_rails_spec/app/views/development_mode_rails_spec/changing_prefix_imported_file.pcss +1 -0
  91. data/spec/rails/templates/development_mode_rails_spec/app/views/development_mode_rails_spec/changing_prefix_imported_file.rb +7 -0
  92. data/spec/rails/templates/development_mode_rails_spec/app/views/development_mode_rails_spec/removing_alongside_css.pcss +1 -0
  93. data/spec/rails/templates/development_mode_rails_spec/app/views/development_mode_rails_spec/removing_alongside_css.rb +5 -0
  94. data/spec/rails/templates/development_mode_rails_spec/app/views/development_mode_rails_spec/removing_inline_css.rb +7 -0
  95. data/spec/rails/templates/development_mode_rails_spec/app/views/development_mode_rails_spec/removing_widget.pcss +1 -0
  96. data/spec/rails/templates/development_mode_rails_spec/app/views/development_mode_rails_spec/removing_widget.rb +9 -0
  97. data/spec/rails/templates/development_mode_rails_spec/app/views/import_base.rb +5 -0
  98. data/spec/rails/templates/development_mode_rails_spec/config/environments/development.rb +37 -0
  99. data/spec/rails/templates/development_mode_rails_spec/vendor/assets/stylesheets/one.scss +1 -0
  100. data/spec/rails/templates/development_mode_rails_spec/vendor/assets/stylesheets/two.scss +1 -0
  101. data/spec/rails/templates/sass_rails_spec/app/assets/foobar/the_import_dir_2/id2ss1.scss +1 -0
  102. data/spec/rails/templates/sass_rails_spec/app/assets/foobar/the_import_dir_2/id2ss2.scss +1 -0
  103. data/spec/rails/templates/sass_rails_spec/app/assets/foobar/twelve.scss +1 -0
  104. data/spec/rails/templates/sass_rails_spec/app/assets/foobar/two.scss +1 -0
  105. data/spec/rails/templates/sass_rails_spec/app/assets/images/quux/foo.png +0 -0
  106. data/spec/rails/templates/sass_rails_spec/app/assets/stylesheets/eleven.scss +1 -0
  107. data/spec/rails/templates/sass_rails_spec/app/assets/stylesheets/one.scss +1 -0
  108. data/spec/rails/templates/sass_rails_spec/app/assets/stylesheets/shared_import_dir/sid1ss1.scss +1 -0
  109. data/spec/rails/templates/sass_rails_spec/app/assets/stylesheets/shared_import_dir/sid1ss2.scss +1 -0
  110. data/spec/rails/templates/sass_rails_spec/app/assets/stylesheets/the_import_dir_1/id1ss1.scss +1 -0
  111. data/spec/rails/templates/sass_rails_spec/app/assets/stylesheets/the_import_dir_1/id1ss2.scss +1 -0
  112. data/spec/rails/templates/sass_rails_spec/app/controllers/sass_rails_spec_controller.rb +29 -0
  113. data/spec/rails/templates/sass_rails_spec/app/views/sass_rails_spec/added_asset_path.pcss +2 -0
  114. data/spec/rails/templates/sass_rails_spec/app/views/sass_rails_spec/added_asset_path.rb +10 -0
  115. data/spec/rails/templates/sass_rails_spec/app/views/sass_rails_spec/asset_url.pcss +2 -0
  116. data/spec/rails/templates/sass_rails_spec/app/views/sass_rails_spec/asset_url.rb +17 -0
  117. data/spec/rails/templates/sass_rails_spec/app/views/sass_rails_spec/default_sass_import.pcss +6 -0
  118. data/spec/rails/templates/sass_rails_spec/app/views/sass_rails_spec/default_sass_import.rb +14 -0
  119. data/spec/rails/templates/sass_rails_spec/app/views/sass_rails_spec/import_directory.pcss +3 -0
  120. data/spec/rails/templates/sass_rails_spec/app/views/sass_rails_spec/import_directory.rb +11 -0
  121. data/spec/rails/templates/sass_rails_spec/app/views/sass_rails_spec/import_view_relative_directory.pcss +3 -0
  122. data/spec/rails/templates/sass_rails_spec/app/views/sass_rails_spec/import_view_relative_directory.rb +11 -0
  123. data/spec/rails/templates/sass_rails_spec/app/views/sass_rails_spec/other_features.pcss +1 -0
  124. data/spec/rails/templates/sass_rails_spec/app/views/sass_rails_spec/other_features.rb +9 -0
  125. data/spec/rails/templates/sass_rails_spec/app/views/sass_rails_spec/shared_imports.rb +10 -0
  126. data/spec/rails/templates/sass_rails_spec/app/views/sass_rails_spec/vr_import_dir_1/vr1ss1.scss +1 -0
  127. data/spec/rails/templates/sass_rails_spec/app/views/sass_rails_spec/vr_import_dir_1/vr1ss2.scss +1 -0
  128. data/spec/rails/templates/sass_rails_spec/app/views/sass_rails_spec/vr_import_dir_2/vr2ss1.scss +1 -0
  129. data/spec/rails/templates/sass_rails_spec/app/views/sass_rails_spec/vr_import_dir_2/vr2ss2.scss +1 -0
  130. data/spec/rails/templates/sass_rails_spec/app/views/widgets/import_base.rb +5 -0
  131. data/spec/rails/templates/sass_rails_spec/config/application.rb +25 -0
  132. data/spec/rails/templates/sass_rails_spec/lib/more_assets/twenty.scss +1 -0
  133. data/spec/rails/templates/sass_rails_spec/vendor/assets/stylesheets/thirteen.scss +1 -0
  134. data/spec/rails/templates/sass_rails_spec/vendor/assets/stylesheets/three.scss +1 -0
  135. data/spec/rails/templates/sets_rails_spec/app/assets/stylesheets/admin.css.scss +1 -0
  136. data/spec/rails/templates/sets_rails_spec/app/assets/stylesheets/all.css.scss +1 -0
  137. data/spec/rails/templates/sets_rails_spec/app/assets/stylesheets/normal.css.scss +1 -0
  138. data/spec/rails/templates/sets_rails_spec/app/controllers/sets_rails_spec_controller.rb +3 -0
  139. data/spec/rails/templates/sets_rails_spec/app/views/admin/admin_one.pcss +1 -0
  140. data/spec/rails/templates/sets_rails_spec/app/views/admin/admin_one.rb +3 -0
  141. data/spec/rails/templates/sets_rails_spec/app/views/admin/admin_two.pcss +1 -0
  142. data/spec/rails/templates/sets_rails_spec/app/views/admin/admin_two.rb +3 -0
  143. data/spec/rails/templates/sets_rails_spec/app/views/admin/base.rb +3 -0
  144. data/spec/rails/templates/sets_rails_spec/app/views/root.rb +9 -0
  145. data/spec/rails/templates/sets_rails_spec/app/views/sets_base.rb +3 -0
  146. data/spec/rails/templates/sets_rails_spec/app/views/sets_rails_spec/normal_one.pcss +1 -0
  147. data/spec/rails/templates/sets_rails_spec/app/views/sets_rails_spec/normal_one.rb +3 -0
  148. data/spec/rails/templates/sets_rails_spec/app/views/sets_rails_spec/normal_two.pcss +1 -0
  149. data/spec/rails/templates/sets_rails_spec/app/views/sets_rails_spec/normal_two.rb +3 -0
  150. data/spec/system/alongside_file_spec.rb +193 -0
  151. data/spec/system/autogenerated_class_application_spec.rb +240 -0
  152. data/spec/system/basic_system_spec.rb +75 -0
  153. data/spec/system/dependency_sorting_spec.rb +48 -0
  154. data/spec/system/engines_spec.rb +245 -0
  155. data/spec/system/prefix_spec.rb +108 -0
  156. data/spec/system/sass_features_spec.rb +109 -0
  157. data/spec/system/sets_spec.rb +405 -0
  158. metadata +477 -0
@@ -0,0 +1,245 @@
1
+ describe "Parcels engines support", :type => :system do
2
+ context "with CSS containing ERb" do
3
+ let(:css_with_erb) { 'p { background-image: url("foo-<%= 3 * 7 %>"); }' }
4
+ let(:css_options) { nil }
5
+ let(:css_arguments) do
6
+ if css_options
7
+ [ css_with_erb, { :options => css_options } ]
8
+ else
9
+ [ css_with_erb ]
10
+ end
11
+ end
12
+ let(:class_text) { nil }
13
+
14
+ def expect_erb_not_processed
15
+ compiled_sprockets_asset('basic').should_match(file_assets do
16
+ asset 'views/my_widget.rb' do
17
+ expect_wrapped_rule :p, 'background-image: url("foo-<%= 3 * 7 %>")'
18
+ end
19
+ end)
20
+ end
21
+
22
+ def expect_erb_processed
23
+ compiled_sprockets_asset('basic').should_match(file_assets do
24
+ asset 'views/my_widget.rb' do
25
+ expect_wrapped_rule :p, 'background-image: url("foo-21")'
26
+ end
27
+ end)
28
+ end
29
+
30
+ before :each do
31
+ the_css_arguments = css_arguments
32
+ the_class_text = class_text
33
+
34
+ files {
35
+ file 'assets/basic.css', %{
36
+ //= require_parcels
37
+ }
38
+
39
+ widget 'views/my_widget' do
40
+ css *the_css_arguments
41
+
42
+ if the_class_text
43
+ class_text the_class_text
44
+ end
45
+ end
46
+ }
47
+ end
48
+
49
+ it "should not, by default, process the ERb" do
50
+ expect_erb_not_processed
51
+ end
52
+
53
+ context "when passed an option containing a string starting with a dot" do
54
+ let(:css_options) { { :engines => '.erb' } }
55
+ it "should process the ERb" do
56
+ expect_erb_processed
57
+ end
58
+ end
59
+
60
+ context "when passed an option containing a string not starting with a dot" do
61
+ let(:css_options) { { :engines => 'erb' } }
62
+ it "should process the ERb" do
63
+ expect_erb_processed
64
+ end
65
+ end
66
+
67
+ context "when passed an option containing a symbol" do
68
+ let(:css_options) { { :engines => :erb } }
69
+ it "should process the ERb" do
70
+ expect_erb_processed
71
+ end
72
+ end
73
+
74
+ context "when passed an option with an array of a string starting with a dot" do
75
+ let(:css_options) { { :engines => [ '.erb' ] } }
76
+ it "should process the ERb" do
77
+ expect_erb_processed
78
+ end
79
+ end
80
+
81
+ context "when passed an option with an array of a string not starting with a dot" do
82
+ let(:css_options) { { :engines => [ 'erb' ] } }
83
+ it "should process the ERb" do
84
+ expect_erb_processed
85
+ end
86
+ end
87
+
88
+ context "when passed an option with an array of a symbol" do
89
+ let(:css_options) { { :engines => [ '.erb' ] } }
90
+ it "should process the ERb" do
91
+ expect_erb_processed
92
+ end
93
+ end
94
+
95
+ context "when passed #css_options" do
96
+ let(:class_text) do
97
+ %{ css_options :engines => '.erb' }
98
+ end
99
+
100
+ it "should process engines as specified" do
101
+ expect_erb_processed
102
+ end
103
+
104
+ context "when also passed options directly" do
105
+ let(:css_options) { { :engines => [ ] } }
106
+
107
+ it "should let the passed options override the class-level ones" do
108
+ expect_erb_not_processed
109
+ end
110
+ end
111
+ end
112
+
113
+ end
114
+
115
+ it "should properly inherit #css_options from superclasses" do
116
+ files {
117
+ file 'assets/basic.css', %{
118
+ //= require_parcels
119
+ }
120
+
121
+ widget 'views/parent_widget' do
122
+ class_text %{ css_options :engines => '.erb'}
123
+ end
124
+
125
+ widget 'views/child_widget', :superclass => 'Views::ParentWidget' do
126
+ requires %{views/parent_widget}
127
+ css %{p { background-image: url("foo-<%= 7 * 3 %>"); }}
128
+ end
129
+ }
130
+
131
+ compiled_sprockets_asset('basic').should_match(file_assets do
132
+ asset 'views/child_widget.rb' do
133
+ expect_wrapped_rule :p, 'background-image: url("foo-21")'
134
+ end
135
+ end)
136
+ end
137
+
138
+ context "alongside files" do
139
+ it "should not process ERb, by default" do
140
+ files {
141
+ file 'assets/basic.css', %{
142
+ //= require_parcels
143
+ }
144
+
145
+ widget 'views/my_widget'
146
+ file 'views/my_widget.pcss', %{
147
+ p { background-image: url("foo-<%= 7 * 3 %>"); }
148
+ }
149
+ }
150
+
151
+ compiled_sprockets_asset('basic').should_match(file_assets do
152
+ asset 'views/my_widget.pcss' do
153
+ expect_wrapped_rule :p, 'background-image: url("foo-<%= 7 * 3 %>")'
154
+ end
155
+ end)
156
+ end
157
+
158
+ it "should use engines specified by #css_options" do
159
+ files {
160
+ file 'assets/basic.css', %{
161
+ //= require_parcels
162
+ }
163
+
164
+ widget 'views/my_widget' do
165
+ class_text %{ css_options :engines => '.erb'}
166
+ end
167
+ file 'views/my_widget.pcss', %{
168
+ p { background-image: url("foo-<%= 7 * 3 %>"); }
169
+ }
170
+ }
171
+
172
+ compiled_sprockets_asset('basic').should_match(file_assets do
173
+ asset 'views/my_widget.pcss' do
174
+ expect_wrapped_rule :p, 'background-image: url("foo-21")'
175
+ end
176
+ end)
177
+ end
178
+
179
+ it "should properly inherit #css_options from superclasses" do
180
+ files {
181
+ file 'assets/basic.css', %{
182
+ //= require_parcels
183
+ }
184
+
185
+ widget 'views/parent_widget' do
186
+ class_text %{ css_options :engines => '.erb'}
187
+ end
188
+
189
+ widget 'views/child_widget', :superclass => 'Views::ParentWidget' do
190
+ requires %{views/parent_widget}
191
+ end
192
+
193
+ file 'views/child_widget.pcss', %{
194
+ p { background-image: url("foo-<%= 7 * 3 %>"); }
195
+ }
196
+ }
197
+
198
+ compiled_sprockets_asset('basic').should_match(file_assets do
199
+ asset 'views/child_widget.pcss' do
200
+ expect_wrapped_rule :p, 'background-image: url("foo-21")'
201
+ end
202
+ end)
203
+ end
204
+ end
205
+
206
+ it "should support multiple Sprockets engines (stringification, then ERb)" do
207
+ files {
208
+ file 'assets/basic.css', %{
209
+ //= require_parcels
210
+ }
211
+
212
+ widget 'views/my_widget' do
213
+ css %{
214
+ p { background-image: url("<\\\#{'%'}= 7 * 3 %>"); }
215
+ }, :options => { :engines => '.erb.str' }
216
+ end
217
+ }
218
+
219
+ compiled_sprockets_asset('basic').should_match(file_assets do
220
+ asset 'views/my_widget.rb' do
221
+ expect_wrapped_rule :p, 'background-image: url("21")'
222
+ end
223
+ end)
224
+ end
225
+
226
+ it "should support multiple Sprockets engines (ERb, then stringification)" do
227
+ files {
228
+ file 'assets/basic.css', %{
229
+ //= require_parcels
230
+ }
231
+
232
+ widget 'views/my_widget' do
233
+ css %{
234
+ p { background-image: url("<\\\#{'%'}= 7 * 3 %>"); }
235
+ }, :options => { :engines => '.str.erb' }
236
+ end
237
+ }
238
+
239
+ compiled_sprockets_asset('basic').should_match(file_assets do
240
+ asset 'views/my_widget.rb' do
241
+ expect_wrapped_rule :p, 'background-image: url("<%= 7 * 3 %>")'
242
+ end
243
+ end)
244
+ end
245
+ end
@@ -0,0 +1,108 @@
1
+ describe "Parcels CSS prefix", :type => :system do
2
+ context "with a CSS prefix" do
3
+ before :each do
4
+ files {
5
+ file 'assets/basic.css', %{
6
+ //= require_parcels
7
+ }
8
+
9
+ widget 'views/my_widget' do
10
+ css_prefix "$mycolor1: #abcdef;\n$mycolor2: #fedcba;"
11
+
12
+ css %{
13
+ p { color: $mycolor1; }
14
+ }
15
+ end
16
+
17
+ file 'views/my_widget.pcss', %{
18
+ div { color: $mycolor2; }
19
+ }
20
+ }
21
+ end
22
+
23
+ it "should apply the prefix before inline CSS" do
24
+ compiled_sprockets_asset('basic').should_match(file_assets do
25
+ asset 'views/my_widget.rb' do
26
+ expect_wrapped_rule :p, 'color: #abcdef'
27
+ end
28
+
29
+ allow_additional_assets!
30
+ end)
31
+ end
32
+
33
+ it "should apply the prefix before alongside CSS" do
34
+ compiled_sprockets_asset('basic').should_match(file_assets do
35
+ asset 'views/my_widget.pcss' do
36
+ expect_wrapped_rule :div, 'color: #fedcba'
37
+ end
38
+
39
+ allow_additional_assets!
40
+ end)
41
+ end
42
+ end
43
+
44
+ context "with a parent CSS prefix" do
45
+ before :each do
46
+ files {
47
+ file 'assets/basic.css', %{
48
+ //= require_parcels
49
+ }
50
+
51
+ widget 'views/parent_widget' do
52
+ css_prefix "$mycolor1: #abcdef;"
53
+ end
54
+
55
+ widget 'views/child_widget', :superclass => 'Views::ParentWidget' do
56
+ requires %{views/parent_widget}
57
+ css %{
58
+ div { color: $mycolor1; }
59
+ }
60
+ end
61
+ }
62
+ end
63
+
64
+ it "should apply that prefix to the child" do
65
+ compiled_sprockets_asset('basic').should_match(file_assets do
66
+ asset 'views/child_widget.rb' do
67
+ expect_wrapped_rule :div, 'color: #abcdef'
68
+ end
69
+ end)
70
+ end
71
+ end
72
+
73
+ context "with a CSS prefix as a block, and a superclass with one, too" do
74
+ before :each do
75
+ files {
76
+ file 'assets/basic.css', %{
77
+ //= require_parcels
78
+ }
79
+
80
+ widget 'views/parent_widget' do
81
+ css_prefix_block %{do |klass|
82
+ "p::before { content: \\"parent: \#{klass.name}\\"; }"
83
+ end}
84
+ end
85
+
86
+ widget 'views/child_widget', :superclass => 'Views::ParentWidget' do
87
+ requires %{views/parent_widget}
88
+ css_prefix_block %{do |klass|
89
+ "p::after { content: \\"child: \#{klass.name}\\"; }"
90
+ end}
91
+
92
+ css %{
93
+ div { color: green; }
94
+ }
95
+ end
96
+ }
97
+ end
98
+
99
+ it "should supply the prefixes correctly" do
100
+ compiled_sprockets_asset('basic').should_match(file_assets do
101
+ asset 'views/child_widget.rb' do
102
+ expect_rule 'p::after', 'content: "child: Views::ChildWidget"'
103
+ expect_wrapped_rule :div, 'color: green'
104
+ end
105
+ end)
106
+ end
107
+ end
108
+ end
@@ -0,0 +1,109 @@
1
+ describe "Parcels SASS features support", :type => :system do
2
+ it "should allow using features like addition" do
3
+ files {
4
+ file 'assets/basic.css', %{
5
+ //= require_parcels
6
+ }
7
+
8
+ widget 'views/my_widget' do
9
+ css %{
10
+ p { color: #b9f2f7 + #ff0000; }
11
+ }
12
+ end
13
+ }
14
+
15
+ compiled_sprockets_asset('basic').should_match(file_assets do
16
+ asset 'views/my_widget.rb' do
17
+ expect_wrapped_rule :p, 'color: #fff2f7'
18
+ end
19
+ end)
20
+ end
21
+
22
+ it "should allow using variables" do
23
+ files {
24
+ file 'assets/basic.css', %{
25
+ //= require_parcels
26
+ }
27
+
28
+ widget 'views/my_widget' do
29
+ css %{
30
+ $mycolor: #feabcd;
31
+ p { color: $mycolor; }
32
+ }
33
+ end
34
+ }
35
+
36
+ compiled_sprockets_asset('basic').should_match(file_assets do
37
+ asset 'views/my_widget.rb' do
38
+ expect_wrapped_rule :p, 'color: #feabcd'
39
+ end
40
+ end)
41
+ end
42
+
43
+ it "should let you use @import, which should use the asset search path, by default" do
44
+ files {
45
+ file 'assets/basic.css', %{
46
+ //= require_parcels
47
+ }
48
+
49
+ file 'assets/one.scss', %{
50
+ $mycolor1: #feabcd;
51
+ }
52
+
53
+ file 'views/two.scss', %{
54
+ $mycolor2: #abcdef;
55
+ }
56
+
57
+ widget 'views/my_widget' do
58
+ css %{
59
+ @import "one";
60
+ @import "two";
61
+ p { color: $mycolor1; }
62
+ div { color: $mycolor2; }
63
+ }
64
+ end
65
+ }
66
+
67
+ compiled_sprockets_asset('basic').should_match(file_assets do
68
+ asset 'views/my_widget.rb' do
69
+ expect_wrapped_rule :p, 'color: #feabcd'
70
+ expect_wrapped_rule :div, 'color: #abcdef'
71
+ end
72
+ end)
73
+ end
74
+
75
+ it "should let you add to the asset search path and use that with @import" do
76
+ sprockets_env.append_path 'foobar'
77
+
78
+ files {
79
+ file 'assets/basic.css', %{
80
+ //= require_parcels
81
+ }
82
+
83
+ file 'assets/one.scss', %{
84
+ $mycolor1: #feabcd;
85
+ }
86
+
87
+ file 'foobar/two.scss', %{
88
+ $mycolor2: #abcdef;
89
+ }
90
+
91
+ widget 'views/my_widget' do
92
+ css %{
93
+ @import "one";
94
+ @import "two";
95
+ p { color: $mycolor1; }
96
+ div { color: $mycolor2; }
97
+ }
98
+ end
99
+ }
100
+
101
+ asset = compiled_sprockets_asset('basic')
102
+ asset.should_match(file_assets do
103
+ asset 'views/my_widget.rb' do
104
+ expect_wrapped_rule :p, 'color: #feabcd'
105
+ expect_wrapped_rule :div, 'color: #abcdef'
106
+ end
107
+ end)
108
+ end
109
+ end