jekyll-assets 0.7.9 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/HISTORY.md +4 -0
- data/README.md +1 -1
- data/jekyll-assets.gemspec +2 -0
- data/lib/jekyll-assets/compass.rb +0 -6
- data/lib/jekyll/assets_plugin/environment.rb +3 -0
- data/lib/jekyll/assets_plugin/version.rb +1 -1
- data/spec/fixtures/_assets/vendor/{bourbon.css.sass → with_bourbon.css.sass} +0 -0
- data/spec/fixtures/_assets/vendor/{compass.css.sass → with_compass.css.sass} +0 -0
- data/spec/fixtures/_assets/vendor/{neat.css.sass → with_neat.css.sass} +0 -0
- data/spec/lib/jekyll-assets/bootstrap_spec.rb +3 -3
- data/spec/lib/jekyll-assets/bourbon_spec.rb +4 -3
- data/spec/lib/jekyll-assets/compass_spec.rb +4 -3
- data/spec/lib/jekyll-assets/font-awesome_spec.rb +3 -3
- data/spec/lib/jekyll-assets/neat_spec.rb +3 -3
- data/spec/lib/jekyll/assets_plugin/configuration_spec.rb +40 -33
- data/spec/lib/jekyll/assets_plugin/environment_spec.rb +12 -16
- data/spec/lib/jekyll/assets_plugin/filters_spec.rb +18 -14
- data/spec/lib/jekyll/assets_plugin/patches/site_patch_spec.rb +33 -29
- data/spec/lib/jekyll/assets_plugin/renderer_spec.rb +5 -5
- data/spec/lib/jekyll/assets_plugin/tag_spec.rb +18 -14
- data/spec/spec_helper.rb +2 -0
- metadata +43 -11
data/.gitignore
CHANGED
data/HISTORY.md
CHANGED
data/README.md
CHANGED
data/jekyll-assets.gemspec
CHANGED
@@ -24,6 +24,8 @@ Gem::Specification.new do |spec|
|
|
24
24
|
|
25
25
|
spec.add_dependency "jekyll", ">= 1.0.0", "< 3.0.0"
|
26
26
|
spec.add_dependency "sprockets", "~> 2.10"
|
27
|
+
spec.add_dependency "sprockets-sass"
|
28
|
+
spec.add_dependency "sprockets-helpers"
|
27
29
|
spec.add_dependency "sass"
|
28
30
|
|
29
31
|
spec.add_development_dependency "bundler", "~> 1.3"
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
require "jekyll-assets/bootstrap"
|
3
3
|
|
4
|
-
describe "Bootstrap integration" do
|
5
|
-
it "
|
6
|
-
@site.assets["bootstrap.css"].to_s.
|
4
|
+
RSpec.describe "Bootstrap integration" do
|
5
|
+
it "globally appends bootstrap paths into Sprockets environment" do
|
6
|
+
expect(@site.assets["bootstrap.css"].to_s).to match(/bootstrap\//)
|
7
7
|
end
|
8
8
|
end
|
@@ -1,8 +1,9 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
require "jekyll-assets/bourbon"
|
3
3
|
|
4
|
-
describe "Bourbon integration" do
|
5
|
-
it "
|
6
|
-
@site.assets["vendor/
|
4
|
+
RSpec.describe "Bourbon integration" do
|
5
|
+
it "globally appends bourbon paths into Sprockets environment" do
|
6
|
+
expect(@site.assets["vendor/with_bourbon.css"].to_s)
|
7
|
+
.to match(/linear-gradient/)
|
7
8
|
end
|
8
9
|
end
|
@@ -1,8 +1,9 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
require "jekyll-assets/compass"
|
3
3
|
|
4
|
-
describe "Compass integration" do
|
5
|
-
it "
|
6
|
-
@site.assets["vendor/
|
4
|
+
RSpec.describe "Compass integration" do
|
5
|
+
it "globally appends compass paths into Sprockets environment" do
|
6
|
+
expect(@site.assets["vendor/with_compass.css"].to_s)
|
7
|
+
.to match(/linear-gradient/)
|
7
8
|
end
|
8
9
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
require "jekyll-assets/font-awesome"
|
3
3
|
|
4
|
-
describe "Font Awesome integration" do
|
5
|
-
it "
|
6
|
-
@site.assets["font-awesome.css"].to_s.
|
4
|
+
RSpec.describe "Font Awesome integration" do
|
5
|
+
it "globally appends font awesome paths into Sprockets environment" do
|
6
|
+
expect(@site.assets["font-awesome.css"].to_s).to match(/fa-github/)
|
7
7
|
end
|
8
8
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
require "jekyll-assets/neat"
|
3
3
|
|
4
|
-
describe "Neat integration" do
|
5
|
-
it "
|
6
|
-
@site.assets["vendor/
|
4
|
+
RSpec.describe "Neat integration" do
|
5
|
+
it "globally appends neat paths into Sprockets environment" do
|
6
|
+
expect(@site.assets["vendor/with_neat.css"].to_s).to match(/max-width/)
|
7
7
|
end
|
8
8
|
end
|
@@ -1,62 +1,62 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe Jekyll::AssetsPlugin::Configuration do
|
3
|
+
RSpec.describe Jekyll::AssetsPlugin::Configuration do
|
4
4
|
context "with defaults" do
|
5
5
|
let(:config) { described_class.new }
|
6
6
|
|
7
7
|
context "output assets dirname" do
|
8
8
|
subject { config.dirname }
|
9
|
-
it {
|
9
|
+
it { is_expected.to eq described_class::DEFAULTS[:dirname] }
|
10
10
|
end
|
11
11
|
|
12
12
|
context "assets baseurl" do
|
13
13
|
subject { config.baseurl }
|
14
|
-
it {
|
14
|
+
it { is_expected.to eq "/" + described_class::DEFAULTS[:dirname] }
|
15
15
|
end
|
16
16
|
|
17
17
|
context "sources list" do
|
18
18
|
subject { config.sources }
|
19
|
-
it {
|
19
|
+
it { is_expected.to match_array described_class::DEFAULTS[:sources] }
|
20
20
|
end
|
21
21
|
|
22
22
|
context "cachebust" do
|
23
23
|
subject { config.cachebust }
|
24
|
-
it {
|
24
|
+
it { is_expected.to be :hard }
|
25
25
|
end
|
26
26
|
|
27
27
|
context "js compressor" do
|
28
28
|
subject { config.js_compressor }
|
29
|
-
it {
|
29
|
+
it { is_expected.to be_nil }
|
30
30
|
end
|
31
31
|
|
32
32
|
context "css compressor" do
|
33
33
|
subject { config.css_compressor }
|
34
|
-
it {
|
34
|
+
it { is_expected.to be_nil }
|
35
35
|
end
|
36
36
|
|
37
37
|
context "gzip" do
|
38
38
|
subject { config.gzip }
|
39
|
-
it {
|
39
|
+
it { is_expected.to match_array %w[text/css application/javascript] }
|
40
40
|
end
|
41
41
|
|
42
42
|
context "cache_assets?" do
|
43
43
|
subject { config.cache_assets? }
|
44
|
-
it {
|
44
|
+
it { is_expected.to eq false }
|
45
45
|
end
|
46
46
|
|
47
47
|
context "cache_path" do
|
48
48
|
subject { config.cache_path }
|
49
|
-
it {
|
49
|
+
it { is_expected.to eq ".jekyll-assets-cache" }
|
50
50
|
end
|
51
51
|
|
52
52
|
context "debug" do
|
53
53
|
subject { config.debug }
|
54
|
-
it {
|
54
|
+
it { is_expected.to eq false }
|
55
55
|
end
|
56
56
|
|
57
57
|
end
|
58
58
|
|
59
|
-
it "
|
59
|
+
it "overrides specified options and leave defaults for missing" do
|
60
60
|
config = described_class.new({
|
61
61
|
:sources => %w[abc],
|
62
62
|
:css_compressor => "sass"
|
@@ -70,25 +70,25 @@ describe Jekyll::AssetsPlugin::Configuration do
|
|
70
70
|
|
71
71
|
context "#cache" do
|
72
72
|
context "when specified as String" do
|
73
|
-
it "
|
73
|
+
it "overrides default cache path" do
|
74
74
|
config = described_class.new :cache => "/tmp/jekyll-assets"
|
75
|
-
config.cache_path.
|
75
|
+
expect(config.cache_path).to eq("/tmp/jekyll-assets")
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
80
|
context "#baseurl" do
|
81
|
-
it "
|
82
|
-
described_class.new({
|
81
|
+
it "respects explicit overrides" do
|
82
|
+
expect(described_class.new({
|
83
83
|
:dirname => "foo",
|
84
84
|
:baseurl => "/bar/"
|
85
|
-
}).baseurl.
|
85
|
+
}).baseurl).to eq("/bar")
|
86
86
|
end
|
87
87
|
|
88
|
-
it "
|
89
|
-
described_class.new({
|
88
|
+
it "is auto-guessed from dirname" do
|
89
|
+
expect(described_class.new({
|
90
90
|
:dirname => "foo"
|
91
|
-
}).baseurl.
|
91
|
+
}).baseurl).to eq("/foo")
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
@@ -96,13 +96,13 @@ describe Jekyll::AssetsPlugin::Configuration do
|
|
96
96
|
context "when js compressor is given as `uglify`" do
|
97
97
|
let(:config) { described_class.new(:js_compressor => "uglify") }
|
98
98
|
subject { config.js_compressor }
|
99
|
-
it {
|
99
|
+
it { is_expected.to be :uglify }
|
100
100
|
end
|
101
101
|
|
102
102
|
context "otherwise" do
|
103
103
|
let(:config) { described_class.new }
|
104
104
|
subject { config.js_compressor }
|
105
|
-
it {
|
105
|
+
it { is_expected.to be_falsey }
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
@@ -110,13 +110,13 @@ describe Jekyll::AssetsPlugin::Configuration do
|
|
110
110
|
context "when css compressor is given as `sass`" do
|
111
111
|
let(:config) { described_class.new(:css_compressor => "sass") }
|
112
112
|
subject { config.css_compressor }
|
113
|
-
it {
|
113
|
+
it { is_expected.to be :sass }
|
114
114
|
end
|
115
115
|
|
116
116
|
context "otherwise" do
|
117
117
|
let(:config) { described_class.new }
|
118
118
|
subject { config.css_compressor }
|
119
|
-
it {
|
119
|
+
it { is_expected.to be_falsey }
|
120
120
|
end
|
121
121
|
end
|
122
122
|
|
@@ -124,7 +124,7 @@ describe Jekyll::AssetsPlugin::Configuration do
|
|
124
124
|
context "when gzip is disabled" do
|
125
125
|
let(:config) { described_class.new(:gzip => false) }
|
126
126
|
subject { config.gzip }
|
127
|
-
it {
|
127
|
+
it { is_expected.to eq [] }
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
@@ -133,14 +133,14 @@ describe Jekyll::AssetsPlugin::Configuration do
|
|
133
133
|
|
134
134
|
context "when given as 123" do
|
135
135
|
let(:version) { 123 }
|
136
|
-
it {
|
137
|
-
it {
|
136
|
+
it { is_expected.to eq 123 }
|
137
|
+
it { is_expected.to be_a Integer }
|
138
138
|
end
|
139
139
|
|
140
140
|
context "when given as 'abc'" do
|
141
141
|
let(:version) { "abc" }
|
142
|
-
it {
|
143
|
-
it {
|
142
|
+
it { is_expected.to eq "abc" }
|
143
|
+
it { is_expected.to be_a String }
|
144
144
|
end
|
145
145
|
end
|
146
146
|
|
@@ -152,15 +152,22 @@ describe Jekyll::AssetsPlugin::Configuration do
|
|
152
152
|
{ :compress => { :js => "uglify", :css => "sass" } }
|
153
153
|
end
|
154
154
|
|
155
|
-
|
156
|
-
|
155
|
+
describe "#js_compressor" do
|
156
|
+
subject { super().js_compressor }
|
157
|
+
it { is_expected.to be :uglify }
|
158
|
+
end
|
159
|
+
|
160
|
+
describe "#css_compressor" do
|
161
|
+
subject { super().css_compressor }
|
162
|
+
it { is_expected.to be :sass }
|
163
|
+
end
|
157
164
|
end
|
158
165
|
|
159
166
|
context "cache_assets" do
|
160
167
|
let(:options) { { :cache_assets => true } }
|
161
168
|
|
162
|
-
it "
|
163
|
-
config.cache_assets
|
169
|
+
it "sets `cache` value" do
|
170
|
+
expect(config.cache_assets?).to eq true
|
164
171
|
end
|
165
172
|
end
|
166
173
|
end
|
@@ -1,22 +1,18 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
css.should match(/fonts\/vapor-[a-f0-9]{32}\.svg#iefix/)
|
11
|
-
end
|
3
|
+
RSpec.describe Jekyll::AssetsPlugin::Environment do
|
4
|
+
context "#asset_path of context" do
|
5
|
+
it "properly handles query params" do
|
6
|
+
css = @site.assets["vapor.css"].to_s
|
7
|
+
expect(css).to match(/fonts\/vapor-[a-f0-9]{32}\.eot\?#iefix/)
|
8
|
+
expect(css).to match(/fonts\/vapor-[a-f0-9]{32}\.svg#iefix/)
|
9
|
+
end
|
12
10
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
19
|
-
end
|
11
|
+
it "properly handles relative paths" do
|
12
|
+
css = @site.assets["lib/relative.css"].to_s
|
13
|
+
expect(css).to match(%r{/assets/fonts/vapor-[a-f0-9]{32}\.eot\?#iefix})
|
14
|
+
expect(css).to match(%r{/assets/fonts/vapor-[a-f0-9]{32}\.svg#iefix})
|
15
|
+
puts css
|
20
16
|
end
|
21
17
|
end
|
22
18
|
end
|
@@ -1,12 +1,16 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe Jekyll::AssetsPlugin::Filters do
|
3
|
+
RSpec.describe Jekyll::AssetsPlugin::Filters do
|
4
4
|
let(:context) { { :registers => { :site => @site } } }
|
5
5
|
|
6
6
|
def render(content)
|
7
7
|
::Liquid::Template.parse(content).render({}, context)
|
8
8
|
end
|
9
9
|
|
10
|
+
def not_found_error(file)
|
11
|
+
"Liquid error: Couldn't find file '#{file}"
|
12
|
+
end
|
13
|
+
|
10
14
|
context "{{ '<file>' | image }}" do
|
11
15
|
def tag_re(name)
|
12
16
|
file = "/assets/#{name}-[a-f0-9]{32}\.png"
|
@@ -15,12 +19,12 @@ describe Jekyll::AssetsPlugin::Filters do
|
|
15
19
|
|
16
20
|
context "when <file> exists" do
|
17
21
|
subject { render("{{ 'noise.png' | image }}") }
|
18
|
-
it {
|
22
|
+
it { is_expected.to match tag_re("noise") }
|
19
23
|
end
|
20
24
|
|
21
25
|
context "when <file> does not exists" do
|
22
26
|
subject { render("{{ 'not-found.png' | image }}") }
|
23
|
-
it {
|
27
|
+
it { is_expected.to match not_found_error "not-found.png" }
|
24
28
|
end
|
25
29
|
end
|
26
30
|
|
@@ -32,17 +36,17 @@ describe Jekyll::AssetsPlugin::Filters do
|
|
32
36
|
|
33
37
|
context "when <file> exists" do
|
34
38
|
subject { render("{{ 'app.css' | stylesheet }}") }
|
35
|
-
it {
|
39
|
+
it { is_expected.to match tag_re("app") }
|
36
40
|
end
|
37
41
|
|
38
42
|
context "when <file> extension is omited" do
|
39
43
|
subject { render("{{ 'app' | stylesheet }}") }
|
40
|
-
it {
|
44
|
+
it { is_expected.to match tag_re("app") }
|
41
45
|
end
|
42
46
|
|
43
47
|
context "when <file> does not exists" do
|
44
48
|
subject { render("{{ 'not-found.css' | stylesheet }}") }
|
45
|
-
it {
|
49
|
+
it { is_expected.to match not_found_error "not-found.css" }
|
46
50
|
end
|
47
51
|
end
|
48
52
|
|
@@ -54,29 +58,29 @@ describe Jekyll::AssetsPlugin::Filters do
|
|
54
58
|
|
55
59
|
context "when <file> exists" do
|
56
60
|
subject { render("{{ 'app.js' | javascript }}") }
|
57
|
-
it {
|
61
|
+
it { is_expected.to match tag_re("app") }
|
58
62
|
end
|
59
63
|
|
60
64
|
context "when <file> extension omited" do
|
61
65
|
subject { render("{{ 'app' | javascript }}") }
|
62
|
-
it {
|
66
|
+
it { is_expected.to match tag_re("app") }
|
63
67
|
end
|
64
68
|
|
65
69
|
context "when <file> does not exists" do
|
66
70
|
subject { render("{{ 'not-found.js' | javascript }}") }
|
67
|
-
it {
|
71
|
+
it { is_expected.to match not_found_error "not-found.js" }
|
68
72
|
end
|
69
73
|
end
|
70
74
|
|
71
75
|
context "{{ '<file.ext>' | asset_path }}" do
|
72
76
|
context "when <file> exists" do
|
73
77
|
subject { render("{{ 'app.css' | asset_path }}") }
|
74
|
-
it {
|
78
|
+
it { is_expected.to match(%r{^/assets/app-[a-f0-9]{32}\.css$}) }
|
75
79
|
end
|
76
80
|
|
77
81
|
context "when <file> does not exists" do
|
78
82
|
subject { render("{{ 'not-found.css' | asset_path }}") }
|
79
|
-
it {
|
83
|
+
it { is_expected.to match not_found_error "not-found.css" }
|
80
84
|
end
|
81
85
|
|
82
86
|
context "with baseurl given as /foobar/" do
|
@@ -85,19 +89,19 @@ describe Jekyll::AssetsPlugin::Filters do
|
|
85
89
|
end
|
86
90
|
|
87
91
|
subject { render("{{ 'app.css' | asset_path }}") }
|
88
|
-
it {
|
92
|
+
it { is_expected.to match(%r{^/foobar/app-[a-f0-9]{32}\.css$}) }
|
89
93
|
end
|
90
94
|
end
|
91
95
|
|
92
96
|
context "{{ '<file.ext>' | asset }}" do
|
93
97
|
context "when <file> exists" do
|
94
98
|
subject { render("{{ 'app.css' | asset }}") }
|
95
|
-
it {
|
99
|
+
it { is_expected.to match(/body \{ background-image: url\(.+?\) \}/) }
|
96
100
|
end
|
97
101
|
|
98
102
|
context "when <file> does not exists" do
|
99
103
|
subject { render("{{ 'not-found.js' | asset }}") }
|
100
|
-
it {
|
104
|
+
it { is_expected.to match not_found_error "not-found.js" }
|
101
105
|
end
|
102
106
|
end
|
103
107
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
|
3
|
+
# rubocop:disable LineLength
|
4
|
+
|
5
|
+
RSpec.describe Jekyll::AssetsPlugin::Patches::SitePatch do
|
4
6
|
let(:site) do
|
5
7
|
Jekyll::Site.new Jekyll.configuration({
|
6
8
|
"source" => fixtures_path.to_s,
|
@@ -13,13 +15,13 @@ describe Jekyll::AssetsPlugin::Patches::SitePatch do
|
|
13
15
|
|
14
16
|
context "#assets" do
|
15
17
|
subject { site.assets }
|
16
|
-
it {
|
18
|
+
it { is_expected.to be_a_kind_of ::Sprockets::Environment }
|
17
19
|
|
18
20
|
context "#cache_path" do
|
19
21
|
let(:source_path) { Pathname.new site.source }
|
20
22
|
subject { site.assets.cache_path }
|
21
23
|
|
22
|
-
it {
|
24
|
+
it { is_expected.to eq source_path.join(".jekyll-assets-cache") }
|
23
25
|
end
|
24
26
|
|
25
27
|
context "calling #asset_path within assets" do
|
@@ -31,14 +33,14 @@ describe Jekyll::AssetsPlugin::Patches::SitePatch do
|
|
31
33
|
end
|
32
34
|
|
33
35
|
context "when requested file found" do
|
34
|
-
it "
|
36
|
+
it "has proper asset path" do
|
35
37
|
expect(site.assets["app.css"].to_s)
|
36
38
|
.to match(%r{url\(/assets/noise-[a-f0-9]{32}\.png\)})
|
37
39
|
end
|
38
40
|
end
|
39
41
|
|
40
42
|
context "when passed a blank path" do
|
41
|
-
it "
|
43
|
+
it "is blank" do
|
42
44
|
expect(site.assets["should_be_blank.css"].to_s)
|
43
45
|
.to match(/url\(\)/)
|
44
46
|
end
|
@@ -51,22 +53,22 @@ describe Jekyll::AssetsPlugin::Patches::SitePatch do
|
|
51
53
|
|
52
54
|
context "with none cachebust" do
|
53
55
|
before { site.assets_config.cachebust = :none }
|
54
|
-
it {
|
56
|
+
it { is_expected.to match(%r{^/assets/app\.css$}) }
|
55
57
|
end
|
56
58
|
|
57
59
|
context "with soft cachebust" do
|
58
60
|
before { site.assets_config.cachebust = :soft }
|
59
|
-
it {
|
61
|
+
it { is_expected.to match(%r{^/assets/app\.css\?cb=[a-f0-9]{32}$}) }
|
60
62
|
end
|
61
63
|
|
62
64
|
context "with hard cachebust" do
|
63
65
|
before { site.assets_config.cachebust = :hard }
|
64
|
-
it {
|
66
|
+
it { is_expected.to match(%r{^/assets/app-[a-f0-9]{32}\.css$}) }
|
65
67
|
end
|
66
68
|
|
67
69
|
context "with unknown cachebust" do
|
68
70
|
before { site.assets_config.cachebust = :wtf }
|
69
|
-
it "
|
71
|
+
it "raises error" do
|
70
72
|
expect { site.asset_path "app.css" }.to raise_error
|
71
73
|
end
|
72
74
|
end
|
@@ -76,17 +78,17 @@ describe Jekyll::AssetsPlugin::Patches::SitePatch do
|
|
76
78
|
|
77
79
|
context "and none cachebust" do
|
78
80
|
before { site.assets_config.cachebust = :none }
|
79
|
-
it {
|
81
|
+
it { is_expected.to match(%r{^/assets/app\.css\?foo=bar$}) }
|
80
82
|
end
|
81
83
|
|
82
84
|
context "and soft cachebust" do
|
83
85
|
before { site.assets_config.cachebust = :soft }
|
84
|
-
it {
|
86
|
+
it { is_expected.to match %r{^/assets/app\.css\?cb=[a-f0-9]{32}&foo=bar$} }
|
85
87
|
end
|
86
88
|
|
87
89
|
context "and hard cachebust" do
|
88
90
|
before { site.assets_config.cachebust = :hard }
|
89
|
-
it {
|
91
|
+
it { is_expected.to match(%r{^/assets/app-[a-f0-9]{32}\.css\?foo=bar$}) }
|
90
92
|
end
|
91
93
|
end
|
92
94
|
|
@@ -95,35 +97,35 @@ describe Jekyll::AssetsPlugin::Patches::SitePatch do
|
|
95
97
|
|
96
98
|
context "and none cachebust" do
|
97
99
|
before { site.assets_config.cachebust = :none }
|
98
|
-
it {
|
100
|
+
it { is_expected.to match(%r{^/assets/app\.css#foobar$}) }
|
99
101
|
end
|
100
102
|
|
101
103
|
context "and soft cachebust" do
|
102
104
|
before { site.assets_config.cachebust = :soft }
|
103
|
-
it {
|
105
|
+
it { is_expected.to match(%r{^/assets/app\.css\?cb=[a-f0-9]{32}#foobar$}) }
|
104
106
|
end
|
105
107
|
|
106
108
|
context "and hard cachebust" do
|
107
109
|
before { site.assets_config.cachebust = :hard }
|
108
|
-
it {
|
110
|
+
it { is_expected.to match(%r{^/assets/app-[a-f0-9]{32}\.css#foobar$}) }
|
109
111
|
end
|
110
112
|
end
|
111
113
|
end
|
112
114
|
|
113
115
|
context "#assets_config" do
|
114
116
|
subject { site.assets_config }
|
115
|
-
it {
|
117
|
+
it { is_expected.to be_an_instance_of Jekyll::AssetsPlugin::Configuration }
|
116
118
|
|
117
|
-
it "
|
118
|
-
site.assets_config.dirname.
|
119
|
-
site.assets_config.sources.
|
119
|
+
it "populated with `assets` section of config" do
|
120
|
+
expect(site.assets_config.dirname).not_to eq "foobar"
|
121
|
+
expect(site.assets_config.sources).to include "foobar"
|
120
122
|
end
|
121
123
|
end
|
122
124
|
|
123
|
-
it "
|
125
|
+
it "regenerates assets upon multiple #process" do
|
124
126
|
@site.assets_config.cachebust = :none
|
125
127
|
2.times { @site.process }
|
126
|
-
@dest.join
|
128
|
+
expect(@dest.join "assets", "app.css").to exist
|
127
129
|
end
|
128
130
|
|
129
131
|
context "with cache" do
|
@@ -139,30 +141,32 @@ describe Jekyll::AssetsPlugin::Patches::SitePatch do
|
|
139
141
|
site.assets.cache_path.rmtree if site.assets.cache_path.exist?
|
140
142
|
end
|
141
143
|
|
142
|
-
it "
|
144
|
+
it "regenerates static assets upon multiple #process" do
|
143
145
|
2.times { site.process }
|
144
|
-
@dest.join
|
146
|
+
expect(@dest.join "assets", "noise.png").to exist
|
145
147
|
end
|
146
148
|
end
|
147
149
|
|
148
150
|
context "#gzip" do
|
149
151
|
subject { site.assets_config }
|
150
152
|
|
151
|
-
it "
|
153
|
+
it "generates a static assets if gzip is enabled" do
|
152
154
|
@site.assets_config.gzip = true
|
153
155
|
@site.process
|
154
|
-
|
156
|
+
|
157
|
+
expect(@dest.join "assets", "app.css.gz").to exist
|
155
158
|
end
|
156
159
|
|
157
|
-
it "
|
160
|
+
it "does not generate a static assets if gzip is enabled" do
|
158
161
|
@site.assets_config.gzip = false
|
159
162
|
@site.process
|
160
|
-
|
163
|
+
|
164
|
+
expect(@dest.join "assets", "app.css.gz").to_not exist
|
161
165
|
end
|
162
166
|
|
163
167
|
end
|
164
168
|
|
165
|
-
it "
|
166
|
-
Jekyll::Site.included_modules.
|
169
|
+
it "is included into Jekyll::Site" do
|
170
|
+
expect(Jekyll::Site.included_modules).to include described_class
|
167
171
|
end
|
168
172
|
end
|
@@ -3,7 +3,7 @@ require "ostruct"
|
|
3
3
|
|
4
4
|
require "spec_helper"
|
5
5
|
|
6
|
-
describe Jekyll::AssetsPlugin::Renderer do
|
6
|
+
RSpec.describe Jekyll::AssetsPlugin::Renderer do
|
7
7
|
let(:site) do
|
8
8
|
Jekyll::Site.new Jekyll.configuration({
|
9
9
|
"source" => fixtures_path.to_s,
|
@@ -22,12 +22,12 @@ describe Jekyll::AssetsPlugin::Renderer do
|
|
22
22
|
|
23
23
|
context "when debug mode enabled" do
|
24
24
|
let(:assets_config) { Hash[:debug, true] }
|
25
|
-
it {
|
25
|
+
it { is_expected.to match(/^(\s*<script src="[^"]+"><\/script>\s*){3}$/) }
|
26
26
|
end
|
27
27
|
|
28
28
|
context "when debug mode disabled" do
|
29
29
|
let(:assets_config) { Hash[:debug, false] }
|
30
|
-
it {
|
30
|
+
it { is_expected.to match(/^(\s*<script src="[^"]+"><\/script>\s*){1}$/) }
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
@@ -36,12 +36,12 @@ describe Jekyll::AssetsPlugin::Renderer do
|
|
36
36
|
|
37
37
|
context "when debug mode enabled" do
|
38
38
|
let(:assets_config) { Hash[:debug, true] }
|
39
|
-
it {
|
39
|
+
it { is_expected.to match(/^(\s*<link rel="stylesheet" [^>]+>\s*){3}$/) }
|
40
40
|
end
|
41
41
|
|
42
42
|
context "when debug mode disabled" do
|
43
43
|
let(:assets_config) { Hash[:debug, false] }
|
44
|
-
it {
|
44
|
+
it { is_expected.to match(/^(\s*<link rel="stylesheet" [^>]+>\s*){1}$/) }
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -1,12 +1,16 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe Jekyll::AssetsPlugin::Tag do
|
3
|
+
RSpec.describe Jekyll::AssetsPlugin::Tag do
|
4
4
|
let(:context) { { :registers => { :site => @site } } }
|
5
5
|
|
6
6
|
def render(content)
|
7
7
|
::Liquid::Template.parse(content).render({}, context)
|
8
8
|
end
|
9
9
|
|
10
|
+
def not_found_error(file)
|
11
|
+
"Liquid error: Couldn't find file '#{file}'"
|
12
|
+
end
|
13
|
+
|
10
14
|
context "{% image <file> %}" do
|
11
15
|
def tag_re(name)
|
12
16
|
file = "/assets/#{name}-[a-f0-9]{32}\.png"
|
@@ -15,12 +19,12 @@ describe Jekyll::AssetsPlugin::Tag do
|
|
15
19
|
|
16
20
|
context "when <file> exists" do
|
17
21
|
subject { render("{% image noise.png %}") }
|
18
|
-
it {
|
22
|
+
it { is_expected.to match tag_re("noise") }
|
19
23
|
end
|
20
24
|
|
21
25
|
context "when <file> does not exists" do
|
22
26
|
subject { render("{% image not-found.png %}") }
|
23
|
-
it {
|
27
|
+
it { is_expected.to match not_found_error "not-found.png" }
|
24
28
|
end
|
25
29
|
end
|
26
30
|
|
@@ -32,17 +36,17 @@ describe Jekyll::AssetsPlugin::Tag do
|
|
32
36
|
|
33
37
|
context "when <file> exists" do
|
34
38
|
subject { render("{% stylesheet app.css %}") }
|
35
|
-
it {
|
39
|
+
it { is_expected.to match tag_re("app") }
|
36
40
|
end
|
37
41
|
|
38
42
|
context "when <file> extension is omited" do
|
39
43
|
subject { render("{% stylesheet app %}") }
|
40
|
-
it {
|
44
|
+
it { is_expected.to match tag_re("app") }
|
41
45
|
end
|
42
46
|
|
43
47
|
context "when <file> does not exists" do
|
44
48
|
subject { render("{% stylesheet not-found.css %}") }
|
45
|
-
it {
|
49
|
+
it { is_expected.to match not_found_error "not-found.css" }
|
46
50
|
end
|
47
51
|
end
|
48
52
|
|
@@ -54,29 +58,29 @@ describe Jekyll::AssetsPlugin::Tag do
|
|
54
58
|
|
55
59
|
context "when <file> exists" do
|
56
60
|
subject { render("{% javascript app.js %}") }
|
57
|
-
it {
|
61
|
+
it { is_expected.to match tag_re("app") }
|
58
62
|
end
|
59
63
|
|
60
64
|
context "when <file> extension omited" do
|
61
65
|
subject { render("{% javascript app %}") }
|
62
|
-
it {
|
66
|
+
it { is_expected.to match tag_re("app") }
|
63
67
|
end
|
64
68
|
|
65
69
|
context "when <file> does not exists" do
|
66
70
|
subject { render("{% javascript not-found.js %}") }
|
67
|
-
it {
|
71
|
+
it { is_expected.to match not_found_error "not-found.js" }
|
68
72
|
end
|
69
73
|
end
|
70
74
|
|
71
75
|
context "{% asset_path <file.ext> %}" do
|
72
76
|
context "when <file> exists" do
|
73
77
|
subject { render("{% asset_path app.css %}") }
|
74
|
-
it {
|
78
|
+
it { is_expected.to match(%r{^/assets/app-[a-f0-9]{32}\.css$}) }
|
75
79
|
end
|
76
80
|
|
77
81
|
context "when <file> does not exists" do
|
78
82
|
subject { render("{% asset_path not-found.js %}") }
|
79
|
-
it {
|
83
|
+
it { is_expected.to match not_found_error "not-found.js" }
|
80
84
|
end
|
81
85
|
|
82
86
|
context "with baseurl given as /foobar/" do
|
@@ -85,19 +89,19 @@ describe Jekyll::AssetsPlugin::Tag do
|
|
85
89
|
end
|
86
90
|
|
87
91
|
subject { render("{% asset_path app.css %}") }
|
88
|
-
it {
|
92
|
+
it { is_expected.to match(%r{^/foobar/app-[a-f0-9]{32}\.css$}) }
|
89
93
|
end
|
90
94
|
end
|
91
95
|
|
92
96
|
context "{% asset <file.ext> %}" do
|
93
97
|
context "when <file> exists" do
|
94
98
|
subject { render("{% asset app.css %}") }
|
95
|
-
it {
|
99
|
+
it { is_expected.to match(/body \{ background-image: url\(.+?\) \}/) }
|
96
100
|
end
|
97
101
|
|
98
102
|
context "when <file> does not exists" do
|
99
103
|
subject { render("{% asset_path not-found.js %}") }
|
100
|
-
it {
|
104
|
+
it { is_expected.to match not_found_error "not-found.js" }
|
101
105
|
end
|
102
106
|
end
|
103
107
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -22,6 +22,8 @@ RSpec.configure do |config|
|
|
22
22
|
config.include FixturesHelpers
|
23
23
|
config.extend FixturesHelpers
|
24
24
|
|
25
|
+
config.disable_monkey_patching!
|
26
|
+
|
25
27
|
config.before(:all) do
|
26
28
|
if Gem::Version.new("2") <= Gem::Version.new(Jekyll::VERSION)
|
27
29
|
Jekyll.logger.log_level = :warn
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-06-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: jekyll
|
@@ -49,6 +49,38 @@ dependencies:
|
|
49
49
|
- - ~>
|
50
50
|
- !ruby/object:Gem::Version
|
51
51
|
version: '2.10'
|
52
|
+
- !ruby/object:Gem::Dependency
|
53
|
+
name: sprockets-sass
|
54
|
+
requirement: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ! '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
type: :runtime
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ! '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
- !ruby/object:Gem::Dependency
|
69
|
+
name: sprockets-helpers
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
80
|
+
requirements:
|
81
|
+
- - ! '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
52
84
|
- !ruby/object:Gem::Dependency
|
53
85
|
name: sass
|
54
86
|
requirement: !ruby/object:Gem::Requirement
|
@@ -265,9 +297,9 @@ files:
|
|
265
297
|
- spec/fixtures/_assets/should_fail.css.erb
|
266
298
|
- spec/fixtures/_assets/vapor.css.scss
|
267
299
|
- spec/fixtures/_assets/vapor.js
|
268
|
-
- spec/fixtures/_assets/vendor/
|
269
|
-
- spec/fixtures/_assets/vendor/
|
270
|
-
- spec/fixtures/_assets/vendor/
|
300
|
+
- spec/fixtures/_assets/vendor/with_bourbon.css.sass
|
301
|
+
- spec/fixtures/_assets/vendor/with_compass.css.sass
|
302
|
+
- spec/fixtures/_assets/vendor/with_neat.css.sass
|
271
303
|
- spec/fixtures/_assets/wowscript.js
|
272
304
|
- spec/fixtures/_assets/wowstyle.css
|
273
305
|
- spec/fixtures/_config.yml
|
@@ -302,7 +334,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
302
334
|
version: '0'
|
303
335
|
segments:
|
304
336
|
- 0
|
305
|
-
hash:
|
337
|
+
hash: 483849259478873314
|
306
338
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
307
339
|
none: false
|
308
340
|
requirements:
|
@@ -311,13 +343,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
311
343
|
version: '0'
|
312
344
|
segments:
|
313
345
|
- 0
|
314
|
-
hash:
|
346
|
+
hash: 483849259478873314
|
315
347
|
requirements: []
|
316
348
|
rubyforge_project:
|
317
349
|
rubygems_version: 1.8.23.2
|
318
350
|
signing_key:
|
319
351
|
specification_version: 3
|
320
|
-
summary: jekyll-assets-0.
|
352
|
+
summary: jekyll-assets-0.8.0
|
321
353
|
test_files:
|
322
354
|
- spec/fixtures/.gitignore
|
323
355
|
- spec/fixtures/_assets/app.css.erb
|
@@ -332,9 +364,9 @@ test_files:
|
|
332
364
|
- spec/fixtures/_assets/should_fail.css.erb
|
333
365
|
- spec/fixtures/_assets/vapor.css.scss
|
334
366
|
- spec/fixtures/_assets/vapor.js
|
335
|
-
- spec/fixtures/_assets/vendor/
|
336
|
-
- spec/fixtures/_assets/vendor/
|
337
|
-
- spec/fixtures/_assets/vendor/
|
367
|
+
- spec/fixtures/_assets/vendor/with_bourbon.css.sass
|
368
|
+
- spec/fixtures/_assets/vendor/with_compass.css.sass
|
369
|
+
- spec/fixtures/_assets/vendor/with_neat.css.sass
|
338
370
|
- spec/fixtures/_assets/wowscript.js
|
339
371
|
- spec/fixtures/_assets/wowstyle.css
|
340
372
|
- spec/fixtures/_config.yml
|