|
1 | 1 | require 'spec_helper' |
2 | 2 |
|
3 | 3 | class BasicsSpec < Less::Rails::Spec |
4 | | - |
| 4 | + |
5 | 5 | it 'must render variables' do |
6 | 6 | basics.must_match %r{#test-variable\{color:#4d926f\}} |
7 | 7 | end |
8 | | - |
| 8 | + |
9 | 9 | it 'must render mixins' do |
10 | 10 | basics.must_match %r{#test-mixin span\{border:1px solid black\}} |
11 | 11 | end |
12 | | - |
| 12 | + |
13 | 13 | it 'must be able to use vendored less files' do |
14 | 14 | basics.must_match %r{#test-vendored\{border-radius:10px\}} |
15 | 15 | end |
16 | | - |
| 16 | + |
17 | 17 | describe 'less import dependency hooks' do |
18 | | - |
| 18 | + |
19 | 19 | it 'must update when imported file changes' do |
20 | 20 | basics.must_match %r{#test-radiused\{border-radius:5px\}}, 'default is 5px' |
21 | 21 | safely_edit(:mixins) do |data, asset| |
22 | | - data.gsub! '5px', '10px' |
| 22 | + data.gsub! '5px', '8px' |
23 | 23 | File.open(asset.pathname,'w') { |f| f.write(data) } |
24 | | - basics.must_match %r{#test-radiused\{border-radius:10px\}}, 'mixins.less should be a sprockets context dependency' |
| 24 | + basics.must_match %r{#test-radiused\{border-radius:8px\}}, 'mixins.less should be a sprockets context dependency' |
| 25 | + |
| 26 | + data.gsub! '8px', '15px' |
| 27 | + File.open(asset.pathname,'w') { |f| f.write(data) } |
| 28 | + |
| 29 | + # Force a recompile |
| 30 | + # https://github.com/rails/sprockets/blob/master/test/shared_sass_tests.rb#L164 |
| 31 | + mtime = Time.now + 1 |
| 32 | + File.utime(mtime, mtime, asset.pathname) |
| 33 | + |
| 34 | + basics.must_match %r{#test-radiused\{border-radius:15px\}}, 'mixins.less should be a sprockets context dependency' |
25 | 35 | end |
26 | 36 | end |
27 | | - |
| 37 | + |
28 | 38 | it 'must update when an imported file of another imported file changes' do |
29 | 39 | basics.must_match %r{#test-variable-colored\{color:#424242\}}, 'default is #424242' |
30 | 40 | safely_edit(:variables) do |data, asset| |
31 | 41 | data.gsub! '424242', '666666' |
32 | 42 | File.open(asset.pathname,'w') { |f| f.write(data) } |
33 | 43 | basics.must_match %r{#test-variable-colored\{color:#666\}}, 'variables.less should be a sprockets context dependency' |
| 44 | + |
| 45 | + data.gsub! '666666', '888888' |
| 46 | + File.open(asset.pathname,'w') { |f| f.write(data) } |
| 47 | + |
| 48 | + mtime = Time.now + 1 |
| 49 | + File.utime(mtime, mtime, asset.pathname) |
| 50 | + |
| 51 | + basics.must_match %r{#test-variable-colored\{color:#888\}}, 'variables.less should be a sprockets context dependency' |
34 | 52 | end |
35 | 53 | end |
36 | 54 |
|
@@ -61,15 +79,15 @@ class BasicsSpec < Less::Rails::Spec |
61 | 79 | end |
62 | 80 |
|
63 | 81 | protected |
64 | | - |
| 82 | + |
65 | 83 | def basics |
66 | 84 | dummy_asset 'basics' |
67 | 85 | end |
68 | | - |
| 86 | + |
69 | 87 | def mixins_asset |
70 | 88 | dummy_assets['frameworks/bootstrap/mixins.less'] |
71 | 89 | end |
72 | | - |
| 90 | + |
73 | 91 | def variables_asset |
74 | 92 | dummy_assets['frameworks/bootstrap/variables.less'] |
75 | 93 | end |
|
0 commit comments