jekyll-assets 1.0.0 → 2.0.0.pre.beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +10 -10
- data/LICENSE +16 -18
- data/README.md +94 -554
- data/Rakefile +2 -8
- data/lib/jekyll/assets.rb +18 -12
- data/lib/jekyll/assets/cached.rb +12 -0
- data/lib/jekyll/assets/configuration.rb +43 -87
- data/lib/jekyll/assets/context.rb +23 -0
- data/lib/jekyll/assets/env.rb +181 -0
- data/lib/jekyll/assets/extras/es6.rb +5 -0
- data/lib/jekyll/assets/extras/font-awesome.rb +1 -0
- data/lib/jekyll/assets/extras/helpers.rb +6 -0
- data/lib/jekyll/assets/extras/prefix.rb +5 -0
- data/lib/jekyll/assets/filters.rb +9 -11
- data/lib/jekyll/assets/helpers.rb +37 -0
- data/lib/jekyll/assets/hook.rb +45 -0
- data/lib/jekyll/assets/hooks/post_read.rb +3 -0
- data/lib/jekyll/assets/hooks/post_write.rb +3 -0
- data/lib/jekyll/assets/logger.rb +25 -0
- data/lib/jekyll/assets/patches/jekyll/cleaner.rb +11 -0
- data/lib/jekyll/assets/patches/jekyll/site.rb +5 -0
- data/lib/jekyll/assets/patches/sprockets/asset.rb +13 -0
- data/lib/jekyll/assets/tag.rb +136 -9
- data/lib/jekyll/assets/tag/parser.rb +129 -0
- data/lib/jekyll/assets/tag/proxied_asset.rb +84 -0
- data/lib/jekyll/assets/tag/proxies.rb +86 -0
- data/lib/jekyll/assets/tag/proxies/magick.rb +101 -0
- data/lib/jekyll/assets/version.rb +1 -1
- metadata +59 -149
- data/.gitignore +0 -27
- data/.rspec +0 -1
- data/.rubocop.yml +0 -43
- data/.rubocop_todo.yml +0 -10
- data/.travis.yml +0 -16
- data/.yardopts +0 -1
- data/Appraisals +0 -7
- data/Guardfile +0 -7
- data/HISTORY.md +0 -297
- data/gemfiles/jekyll_2.gemfile +0 -17
- data/gemfiles/jekyll_3.gemfile +0 -17
- data/jekyll-assets.gemspec +0 -34
- data/lib/jekyll-assets.rb +0 -2
- data/lib/jekyll/assets/asset_path.rb +0 -39
- data/lib/jekyll/assets/environment.rb +0 -62
- data/lib/jekyll/assets/patches.rb +0 -1
- data/lib/jekyll/assets/patches/asset_patch.rb +0 -102
- data/lib/jekyll/assets/patches/bundled_asset_patch.rb +0 -16
- data/lib/jekyll/assets/patches/context_patch.rb +0 -31
- data/lib/jekyll/assets/patches/index_patch.rb +0 -25
- data/lib/jekyll/assets/patches/processed_asset_patch.rb +0 -59
- data/lib/jekyll/assets/patches/site_patch.rb +0 -62
- data/lib/jekyll/assets/renderer.rb +0 -122
- data/spec/fixtures/.gitignore +0 -2
- data/spec/fixtures/.jekyll-metadata +0 -0
- data/spec/fixtures/_assets/alert.js +0 -1
- data/spec/fixtures/_assets/app.css.erb +0 -5
- data/spec/fixtures/_assets/app.js +0 -1
- data/spec/fixtures/_assets/app.min.css +0 -0
- data/spec/fixtures/_assets/app.min.js +0 -0
- data/spec/fixtures/_assets/fonts/vapor.eot +0 -0
- data/spec/fixtures/_assets/fonts/vapor.svg +0 -0
- data/spec/fixtures/_assets/fonts/vapor.ttf +0 -0
- data/spec/fixtures/_assets/fonts/vapor.woff +0 -0
- data/spec/fixtures/_assets/lib/relative.css.scss +0 -12
- data/spec/fixtures/_assets/noise.png +0 -0
- data/spec/fixtures/_assets/noize.png +0 -0
- data/spec/fixtures/_assets/should_be_blank.css.erb +0 -1
- data/spec/fixtures/_assets/should_fail.css.erb +0 -1
- data/spec/fixtures/_assets/vapor.css.scss +0 -13
- data/spec/fixtures/_assets/vapor.js +0 -2
- data/spec/fixtures/_assets/vendor/with_bootstrap.css.sass +0 -1
- data/spec/fixtures/_assets/vendor/with_bourbon.css.sass +0 -4
- data/spec/fixtures/_assets/vendor/with_compass.css.sass +0 -4
- data/spec/fixtures/_assets/vendor/with_neat.css.sass +0 -5
- data/spec/fixtures/_assets/wowscript.js +0 -0
- data/spec/fixtures/_assets/wowstyle.css +0 -0
- data/spec/fixtures/_config.yml +0 -2
- data/spec/fixtures/_layouts/default.html +0 -9
- data/spec/fixtures/_posts/2012-10-19-hello-world.md +0 -6
- data/spec/fixtures/_posts/2015-02-02-duplicates.md +0 -8
- data/spec/fixtures/index.html +0 -0
- data/spec/lib/jekyll/assets/configuration_spec.rb +0 -172
- data/spec/lib/jekyll/assets/environment_spec.rb +0 -18
- data/spec/lib/jekyll/assets/filters_spec.rb +0 -112
- data/spec/lib/jekyll/assets/patches/site_patch_spec.rb +0 -176
- data/spec/lib/jekyll/assets/renderer_spec.rb +0 -286
- data/spec/lib/jekyll/assets/tag_spec.rb +0 -139
- data/spec/spec_helper.rb +0 -58
- data/spec/support/fixtures_helpers.rb +0 -7
@@ -1,112 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
RSpec.describe Jekyll::Assets::Filters do
|
4
|
-
let(:context) { { :registers => { :site => @site } } }
|
5
|
-
|
6
|
-
def render(content)
|
7
|
-
::Liquid::Template.parse(content).render({}, context)
|
8
|
-
end
|
9
|
-
|
10
|
-
def not_found_error(file)
|
11
|
-
"Liquid error: Couldn't find file '#{file}"
|
12
|
-
end
|
13
|
-
|
14
|
-
def render_tag(template, path, attrs = "")
|
15
|
-
template = Jekyll::Assets::Renderer.const_get template
|
16
|
-
format template, :path => path, :attrs => attrs
|
17
|
-
end
|
18
|
-
|
19
|
-
context "{{ '<file>' | image }}" do
|
20
|
-
def tag_re(name)
|
21
|
-
file = "/assets/#{name}-[a-f0-9]{32}\.png"
|
22
|
-
Regexp.new "^#{render_tag :IMAGE, file}$"
|
23
|
-
end
|
24
|
-
|
25
|
-
context "when <file> exists" do
|
26
|
-
subject { render("{{ 'noise.png' | image }}") }
|
27
|
-
it { is_expected.to match tag_re("noise") }
|
28
|
-
end
|
29
|
-
|
30
|
-
context "when <file> does not exists" do
|
31
|
-
subject { render("{{ 'not-found.png' | image }}") }
|
32
|
-
it { is_expected.to match not_found_error "not-found.png" }
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
context "{{ '<file>' | stylesheet }}" do
|
37
|
-
def tag_re(name)
|
38
|
-
file = "/assets/#{name}-[a-f0-9]{32}\.css"
|
39
|
-
Regexp.new "^#{render_tag :STYLESHEET, file}$"
|
40
|
-
end
|
41
|
-
|
42
|
-
context "when <file> exists" do
|
43
|
-
subject { render("{{ 'app.css' | stylesheet }}") }
|
44
|
-
it { is_expected.to match tag_re("app") }
|
45
|
-
end
|
46
|
-
|
47
|
-
context "when <file> extension is omited" do
|
48
|
-
subject { render("{{ 'app' | stylesheet }}") }
|
49
|
-
it { is_expected.to match tag_re("app") }
|
50
|
-
end
|
51
|
-
|
52
|
-
context "when <file> does not exists" do
|
53
|
-
subject { render("{{ 'not-found.css' | stylesheet }}") }
|
54
|
-
it { is_expected.to match not_found_error "not-found.css" }
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
context "{{ '<file>' | javascript }}" do
|
59
|
-
def tag_re(name)
|
60
|
-
file = "/assets/#{name}-[a-f0-9]{32}\.js"
|
61
|
-
Regexp.new "^#{render_tag :JAVASCRIPT, file}$"
|
62
|
-
end
|
63
|
-
|
64
|
-
context "when <file> exists" do
|
65
|
-
subject { render("{{ 'app.js' | javascript }}") }
|
66
|
-
it { is_expected.to match tag_re("app") }
|
67
|
-
end
|
68
|
-
|
69
|
-
context "when <file> extension omited" do
|
70
|
-
subject { render("{{ 'app' | javascript }}") }
|
71
|
-
it { is_expected.to match tag_re("app") }
|
72
|
-
end
|
73
|
-
|
74
|
-
context "when <file> does not exists" do
|
75
|
-
subject { render("{{ 'not-found.js' | javascript }}") }
|
76
|
-
it { is_expected.to match not_found_error "not-found.js" }
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
context "{{ '<file.ext>' | asset_path }}" do
|
81
|
-
context "when <file> exists" do
|
82
|
-
subject { render("{{ 'app.css' | asset_path }}") }
|
83
|
-
it { is_expected.to match(%r{^/assets/app-[a-f0-9]{32}\.css$}) }
|
84
|
-
end
|
85
|
-
|
86
|
-
context "when <file> does not exists" do
|
87
|
-
subject { render("{{ 'not-found.css' | asset_path }}") }
|
88
|
-
it { is_expected.to match not_found_error "not-found.css" }
|
89
|
-
end
|
90
|
-
|
91
|
-
context "with baseurl given as /foobar/" do
|
92
|
-
before do
|
93
|
-
context[:registers][:site].assets_config.baseurl = "/foobar/"
|
94
|
-
end
|
95
|
-
|
96
|
-
subject { render("{{ 'app.css' | asset_path }}") }
|
97
|
-
it { is_expected.to match(%r{^/foobar/app-[a-f0-9]{32}\.css$}) }
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
context "{{ '<file.ext>' | asset }}" do
|
102
|
-
context "when <file> exists" do
|
103
|
-
subject { render("{{ 'app.css' | asset }}") }
|
104
|
-
it { is_expected.to match(/body \{ background-image: url\(.+?\) \}/) }
|
105
|
-
end
|
106
|
-
|
107
|
-
context "when <file> does not exists" do
|
108
|
-
subject { render("{{ 'not-found.js' | asset }}") }
|
109
|
-
it { is_expected.to match not_found_error "not-found.js" }
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
@@ -1,176 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
# rubocop:disable LineLength
|
4
|
-
|
5
|
-
RSpec.describe Jekyll::Assets::Patches::SitePatch do
|
6
|
-
let(:site) do
|
7
|
-
Jekyll::Site.new Jekyll.configuration({
|
8
|
-
"source" => fixtures_path.to_s,
|
9
|
-
"dirname" => "foobar",
|
10
|
-
"assets" => {
|
11
|
-
"sources" => %w(foobar _assets)
|
12
|
-
}
|
13
|
-
})
|
14
|
-
end
|
15
|
-
|
16
|
-
context "#assets" do
|
17
|
-
subject { site.assets }
|
18
|
-
it { is_expected.to be_a_kind_of ::Sprockets::Environment }
|
19
|
-
|
20
|
-
context "#cache_path" do
|
21
|
-
let(:source_path) { Pathname.new site.source }
|
22
|
-
subject { site.assets.cache_path }
|
23
|
-
|
24
|
-
it { is_expected.to eq source_path.join(".jekyll-assets-cache") }
|
25
|
-
end
|
26
|
-
|
27
|
-
context "calling #asset_path within assets" do
|
28
|
-
context "when requested file not found" do
|
29
|
-
it "raises a NotFound error" do
|
30
|
-
expect { site.assets["should_fail.css"] }
|
31
|
-
.to raise_error Jekyll::Assets::Environment::AssetNotFound
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
context "when requested file found" do
|
36
|
-
it "has proper asset path" do
|
37
|
-
expect(site.assets["app.css"].to_s)
|
38
|
-
.to match(%r{url\(/assets/noise-[a-f0-9]{32}\.png\)})
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
context "when passed a blank path" do
|
43
|
-
it "is blank" do
|
44
|
-
expect(site.assets["should_be_blank.css"].to_s)
|
45
|
-
.to match(/url\(\)/)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
context "#asset_path" do
|
52
|
-
subject { site.asset_path "app.css" }
|
53
|
-
|
54
|
-
context "with none cachebust" do
|
55
|
-
before { site.assets_config.cachebust = :none }
|
56
|
-
it { is_expected.to match(%r{^/assets/app\.css$}) }
|
57
|
-
end
|
58
|
-
|
59
|
-
context "with soft cachebust" do
|
60
|
-
before { site.assets_config.cachebust = :soft }
|
61
|
-
it { is_expected.to match(%r{^/assets/app\.css\?cb=[a-f0-9]{32}$}) }
|
62
|
-
end
|
63
|
-
|
64
|
-
context "with hard cachebust" do
|
65
|
-
before { site.assets_config.cachebust = :hard }
|
66
|
-
it { is_expected.to match(%r{^/assets/app-[a-f0-9]{32}\.css$}) }
|
67
|
-
end
|
68
|
-
|
69
|
-
context "with unknown cachebust" do
|
70
|
-
before { site.assets_config.cachebust = :wtf }
|
71
|
-
it "raises error" do
|
72
|
-
expect { site.asset_path "app.css" }.to raise_error
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
context "with query part in requested filename" do
|
77
|
-
subject { site.asset_path "app.css?foo=bar" }
|
78
|
-
|
79
|
-
context "and none cachebust" do
|
80
|
-
before { site.assets_config.cachebust = :none }
|
81
|
-
it { is_expected.to match(%r{^/assets/app\.css\?foo=bar$}) }
|
82
|
-
end
|
83
|
-
|
84
|
-
context "and soft cachebust" do
|
85
|
-
before { site.assets_config.cachebust = :soft }
|
86
|
-
it { is_expected.to match %r{^/assets/app\.css\?cb=[a-f0-9]{32}&foo=bar$} }
|
87
|
-
end
|
88
|
-
|
89
|
-
context "and hard cachebust" do
|
90
|
-
before { site.assets_config.cachebust = :hard }
|
91
|
-
it { is_expected.to match(%r{^/assets/app-[a-f0-9]{32}\.css\?foo=bar$}) }
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
context "with anchor part in requested filename" do
|
96
|
-
subject { site.asset_path "app.css#foobar" }
|
97
|
-
|
98
|
-
context "and none cachebust" do
|
99
|
-
before { site.assets_config.cachebust = :none }
|
100
|
-
it { is_expected.to match(%r{^/assets/app\.css#foobar$}) }
|
101
|
-
end
|
102
|
-
|
103
|
-
context "and soft cachebust" do
|
104
|
-
before { site.assets_config.cachebust = :soft }
|
105
|
-
it { is_expected.to match(%r{^/assets/app\.css\?cb=[a-f0-9]{32}#foobar$}) }
|
106
|
-
end
|
107
|
-
|
108
|
-
context "and hard cachebust" do
|
109
|
-
before { site.assets_config.cachebust = :hard }
|
110
|
-
it { is_expected.to match(%r{^/assets/app-[a-f0-9]{32}\.css#foobar$}) }
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
context "#assets_config" do
|
116
|
-
subject { site.assets_config }
|
117
|
-
it { is_expected.to be_an_instance_of Jekyll::Assets::Configuration }
|
118
|
-
|
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"
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
it "regenerates assets upon multiple #process" do
|
126
|
-
@site.assets_config.cachebust = :none
|
127
|
-
2.times { @site.process }
|
128
|
-
expect(@dest.join "assets", "app.css").to exist
|
129
|
-
end
|
130
|
-
|
131
|
-
it "does not ignores files with duplicate contents" do
|
132
|
-
@site.assets_config.cachebust = :none
|
133
|
-
@site.process
|
134
|
-
|
135
|
-
expect(@dest.join "assets", "noise.png").to exist
|
136
|
-
expect(@dest.join "assets", "noize.png").to exist
|
137
|
-
end
|
138
|
-
|
139
|
-
context "with cache" do
|
140
|
-
before do
|
141
|
-
@site.assets_config.cache = true
|
142
|
-
@site.assets_config.cachebust = :none
|
143
|
-
end
|
144
|
-
|
145
|
-
after do
|
146
|
-
@site.assets.cache_path.rmtree if site.assets.cache_path.exist?
|
147
|
-
end
|
148
|
-
|
149
|
-
it "regenerates static assets upon multiple #process" do
|
150
|
-
2.times { @site.process }
|
151
|
-
expect(@dest.join "assets", "noise.png").to exist
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
context "#gzip" do
|
156
|
-
subject { site.assets_config }
|
157
|
-
|
158
|
-
it "generates a static assets if gzip is enabled" do
|
159
|
-
@site.assets_config.gzip = true
|
160
|
-
@site.process
|
161
|
-
|
162
|
-
expect(@dest.join "assets", "app.css.gz").to exist
|
163
|
-
end
|
164
|
-
|
165
|
-
it "does not generate a static assets if gzip is enabled" do
|
166
|
-
@site.assets_config.gzip = false
|
167
|
-
@site.process
|
168
|
-
|
169
|
-
expect(@dest.join "assets", "app.css.gz").to_not exist
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
it "is included into Jekyll::Site" do
|
174
|
-
expect(Jekyll::Site.included_modules).to include described_class
|
175
|
-
end
|
176
|
-
end
|
@@ -1,286 +0,0 @@
|
|
1
|
-
# stdlib
|
2
|
-
require "ostruct"
|
3
|
-
|
4
|
-
require "spec_helper"
|
5
|
-
|
6
|
-
RSpec.describe Jekyll::Assets::Renderer do
|
7
|
-
let(:assets_config) { Hash.new }
|
8
|
-
|
9
|
-
let(:site) do
|
10
|
-
Jekyll::Site.new Jekyll.configuration({
|
11
|
-
"source" => fixtures_path.to_s,
|
12
|
-
"destination" => @dest.to_s,
|
13
|
-
"assets" => assets_config
|
14
|
-
})
|
15
|
-
end
|
16
|
-
|
17
|
-
let(:params) { "app" }
|
18
|
-
let(:context) { OpenStruct.new(:registers => { :site => site }) }
|
19
|
-
let(:renderer) { described_class.new context, params }
|
20
|
-
|
21
|
-
describe "#path" do
|
22
|
-
subject { renderer.path }
|
23
|
-
|
24
|
-
context "with logical path only" do
|
25
|
-
context "when logical path contains no spaces" do
|
26
|
-
let(:params) { "app" }
|
27
|
-
it { is_expected.to eq "app" }
|
28
|
-
end
|
29
|
-
|
30
|
-
context "when logical path contains spaces and double quoted" do
|
31
|
-
let(:params) { '"my app"' }
|
32
|
-
it { is_expected.to eq "my app" }
|
33
|
-
end
|
34
|
-
|
35
|
-
context "when logical path contains spaces and single quoted" do
|
36
|
-
let(:params) { "'my app'" }
|
37
|
-
it { is_expected.to eq "my app" }
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
context "with logical path and params" do
|
42
|
-
context "when logical path contains no spaces" do
|
43
|
-
let(:params) { 'app foo bar="baz"' }
|
44
|
-
it { is_expected.to eq "app" }
|
45
|
-
end
|
46
|
-
|
47
|
-
context "when logical path contains spaces and double quoted" do
|
48
|
-
let(:params) { '"my app" foo bar="baz"' }
|
49
|
-
it { is_expected.to eq "my app" }
|
50
|
-
end
|
51
|
-
|
52
|
-
context "when logical path contains spaces and single quoted" do
|
53
|
-
let(:params) { %q('my app' foo bar="baz") }
|
54
|
-
it { is_expected.to eq "my app" }
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe "#attrs" do
|
60
|
-
subject { renderer.attrs }
|
61
|
-
|
62
|
-
context "with logical path only" do
|
63
|
-
context "when logical path contains no spaces" do
|
64
|
-
let(:params) { "app" }
|
65
|
-
it { is_expected.to eq "" }
|
66
|
-
end
|
67
|
-
|
68
|
-
context "when logical path contains spaces and double quoted" do
|
69
|
-
let(:params) { '"my app"' }
|
70
|
-
it { is_expected.to eq "" }
|
71
|
-
end
|
72
|
-
|
73
|
-
context "when logical path contains spaces and single quoted" do
|
74
|
-
let(:params) { "'my app'" }
|
75
|
-
it { is_expected.to eq "" }
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
context "with logical path and params" do
|
80
|
-
context "when logical path contains no spaces" do
|
81
|
-
let(:params) { 'app foo bar="baz"' }
|
82
|
-
it { is_expected.to eq ' foo bar="baz"' }
|
83
|
-
end
|
84
|
-
|
85
|
-
context "when logical path contains spaces and double quoted" do
|
86
|
-
let(:params) { '"my app" foo bar="baz"' }
|
87
|
-
it { is_expected.to eq ' foo bar="baz"' }
|
88
|
-
end
|
89
|
-
|
90
|
-
context "when logical path contains spaces and single quoted" do
|
91
|
-
let(:params) { %q('my app' foo bar="baz") }
|
92
|
-
it { is_expected.to eq ' foo bar="baz"' }
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
describe "#options" do
|
98
|
-
subject { renderer.options }
|
99
|
-
|
100
|
-
context "with no options given" do
|
101
|
-
it { is_expected.to be_an Array }
|
102
|
-
it { is_expected.to be_empty }
|
103
|
-
end
|
104
|
-
|
105
|
-
context "with options given" do
|
106
|
-
let(:params) { "app [foo,bar]" }
|
107
|
-
it { is_expected.to eq %w(foo bar) }
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
describe "#render_javascript" do
|
112
|
-
subject { renderer.render_javascript }
|
113
|
-
|
114
|
-
context "when debug mode enabled" do
|
115
|
-
let(:assets_config) { Hash[:debug, true] }
|
116
|
-
it { is_expected.to match(/^(\s*<script src="[^"]+"><\/script>\s*){3}$/) }
|
117
|
-
|
118
|
-
context "and URI given" do
|
119
|
-
let(:params) { "http://example.com/app.js" }
|
120
|
-
it { is_expected.to match(/^<script src="#{params}"><\/script>$/) }
|
121
|
-
end
|
122
|
-
|
123
|
-
context "and path contains attributes" do
|
124
|
-
let(:params) { "app data-test=true" }
|
125
|
-
it { is_expected.to include "data-test=true" }
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
context "when debug mode disabled" do
|
130
|
-
let(:assets_config) { Hash[:debug, false] }
|
131
|
-
it { is_expected.to match(/^(\s*<script src="[^"]+"><\/script>\s*){1}$/) }
|
132
|
-
|
133
|
-
context "and URI given" do
|
134
|
-
let(:params) { "http://example.com/app.js" }
|
135
|
-
it { is_expected.to match(/^<script src="#{params}"><\/script>$/) }
|
136
|
-
end
|
137
|
-
|
138
|
-
context "and path contains attributes" do
|
139
|
-
let(:params) { "app data-test=true" }
|
140
|
-
it { is_expected.to include "data-test=true" }
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
describe "#render_stylesheet" do
|
146
|
-
subject { renderer.render_stylesheet }
|
147
|
-
let(:tag_prefix) { '<link rel="stylesheet"' }
|
148
|
-
|
149
|
-
context "when debug mode enabled" do
|
150
|
-
let(:assets_config) { Hash[:debug, true] }
|
151
|
-
it { is_expected.to match(/^(\s*#{tag_prefix} [^>]+>\s*){3}$/) }
|
152
|
-
|
153
|
-
context "and URI given" do
|
154
|
-
let(:params) { "http://example.com/style.css" }
|
155
|
-
it { is_expected.to match(/^#{tag_prefix} href="#{params}">$/) }
|
156
|
-
end
|
157
|
-
|
158
|
-
context "and path contains attributes" do
|
159
|
-
let(:params) { "app data-test=true" }
|
160
|
-
it { is_expected.to include "data-test=true" }
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
context "when debug mode disabled" do
|
165
|
-
let(:assets_config) { Hash[:debug, false] }
|
166
|
-
it { is_expected.to match(/^(\s*#{tag_prefix} [^>]+>\s*){1}$/) }
|
167
|
-
|
168
|
-
context "and URI given" do
|
169
|
-
let(:params) { "http://example.com/style.css" }
|
170
|
-
it { is_expected.to match(/^#{tag_prefix} href="#{params}">$/) }
|
171
|
-
end
|
172
|
-
|
173
|
-
context "and path contains attributes" do
|
174
|
-
let(:params) { "app data-test=true" }
|
175
|
-
it { is_expected.to include "data-test=true" }
|
176
|
-
end
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
describe "#render_image" do
|
181
|
-
subject { renderer.render_image }
|
182
|
-
|
183
|
-
let(:params) { "noise.png" }
|
184
|
-
|
185
|
-
context "when debug mode enabled" do
|
186
|
-
let(:assets_config) { Hash[:debug, true] }
|
187
|
-
it { is_expected.to match(%r{^<img src="/assets/noise-[^.]+\.png">$}) }
|
188
|
-
|
189
|
-
context "and URI given" do
|
190
|
-
let(:params) { "http://example.com/style.css" }
|
191
|
-
it { is_expected.to match(/^<img src="#{params}">$/) }
|
192
|
-
end
|
193
|
-
|
194
|
-
context "and path contains attributes" do
|
195
|
-
let(:params) { "noise.png data-test=true" }
|
196
|
-
it { is_expected.to include "data-test=true" }
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|
200
|
-
context "when debug mode disabled" do
|
201
|
-
let(:assets_config) { Hash[:debug, false] }
|
202
|
-
it { is_expected.to match(%r{^<img src="/assets/noise-[^.]+\.png">$}) }
|
203
|
-
|
204
|
-
context "and URI given" do
|
205
|
-
let(:params) { "http://example.com/style.css" }
|
206
|
-
it { is_expected.to match(/^<img src="#{params}">$/) }
|
207
|
-
end
|
208
|
-
|
209
|
-
context "and path contains attributes" do
|
210
|
-
let(:params) { "noise.png data-test=true" }
|
211
|
-
it { is_expected.to include "data-test=true" }
|
212
|
-
end
|
213
|
-
end
|
214
|
-
|
215
|
-
context "with [autosize] helper option" do
|
216
|
-
let(:params) { "noise.png [autosize]" }
|
217
|
-
let(:attr_src) { 'src="/assets/noise-[^.]+\.png"' }
|
218
|
-
let(:attr_size) { 'width="100" height="100"' }
|
219
|
-
|
220
|
-
it { is_expected.to match(/^<img #{attr_src} #{attr_size}>$/) }
|
221
|
-
end
|
222
|
-
|
223
|
-
context "with [no-autosize] helper option" do
|
224
|
-
let(:params) { "noise.png [no-autosize]" }
|
225
|
-
let(:attr_src) { 'src="/assets/noise-[^.]+\.png"' }
|
226
|
-
|
227
|
-
it { is_expected.to match(/^<img #{attr_src}>$/) }
|
228
|
-
end
|
229
|
-
|
230
|
-
context "with autosize enabled in config" do
|
231
|
-
let(:assets_config) { Hash[:autosize, true] }
|
232
|
-
let(:attr_src) { 'src="/assets/noise-[^.]+\.png"' }
|
233
|
-
let(:attr_size) { 'width="100" height="100"' }
|
234
|
-
|
235
|
-
it { is_expected.to match(/^<img #{attr_src} #{attr_size}>$/) }
|
236
|
-
|
237
|
-
context "and [autosize] helper option given" do
|
238
|
-
let(:params) { "noise.png [autosize]" }
|
239
|
-
it { is_expected.to match(/^<img #{attr_src} #{attr_size}>$/) }
|
240
|
-
end
|
241
|
-
|
242
|
-
context "and [no-autosize] helper option given" do
|
243
|
-
let(:params) { "noise.png [no-autosize]" }
|
244
|
-
it { is_expected.to match(/^<img #{attr_src}>$/) }
|
245
|
-
end
|
246
|
-
end
|
247
|
-
|
248
|
-
context "with [resize:*] helper option" do
|
249
|
-
let(:params) { "noise.png [resize:10x10]" }
|
250
|
-
let(:attr_src) { 'src="/assets/noise-10x10-[^.]+\.png"' }
|
251
|
-
it { is_expected.to match(/^<img #{attr_src}>$/) }
|
252
|
-
end
|
253
|
-
|
254
|
-
context "with [resize:*] and [autosize] helpers" do
|
255
|
-
let(:params) { "noise.png [resize:10x10, autosize]" }
|
256
|
-
let(:attr_src) { 'src="/assets/noise-10x10-[^.]+\.png"' }
|
257
|
-
let(:attr_size) { 'width="10" height="10"' }
|
258
|
-
it { is_expected.to match(/^<img #{attr_src} #{attr_size}>$/) }
|
259
|
-
end
|
260
|
-
end
|
261
|
-
|
262
|
-
describe "#render_asset" do
|
263
|
-
subject { renderer.render_asset }
|
264
|
-
let(:params) { "alert.js" }
|
265
|
-
|
266
|
-
context "when debug mode enabled" do
|
267
|
-
let(:assets_config) { Hash[:debug, true] }
|
268
|
-
it { is_expected.to eq "alert('test');\n" }
|
269
|
-
|
270
|
-
context "and URI given" do
|
271
|
-
let(:params) { "http://example.com/style.css" }
|
272
|
-
it { expect { subject }.to raise_error(/#{params}/) }
|
273
|
-
end
|
274
|
-
end
|
275
|
-
|
276
|
-
context "when debug mode disabled" do
|
277
|
-
let(:assets_config) { Hash[:debug, false] }
|
278
|
-
it { is_expected.to eq "alert('test');\n" }
|
279
|
-
|
280
|
-
context "and URI given" do
|
281
|
-
let(:params) { "http://example.com/style.css" }
|
282
|
-
it { expect { subject }.to raise_error(/#{params}/) }
|
283
|
-
end
|
284
|
-
end
|
285
|
-
end
|
286
|
-
end
|