tgfa-jekyll-assets 0.7.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +18 -0
  3. data/.rspec +1 -0
  4. data/.rubocop.yml +78 -0
  5. data/.travis.yml +9 -0
  6. data/.yardopts +1 -0
  7. data/Gemfile +15 -0
  8. data/Gemfile.jekyll-1.0 +2 -0
  9. data/Guardfile +8 -0
  10. data/HISTORY.md +202 -0
  11. data/LICENSE +22 -0
  12. data/README.md +569 -0
  13. data/Rakefile +9 -0
  14. data/lib/jekyll/assets_plugin/asset_path.rb +39 -0
  15. data/lib/jekyll/assets_plugin/configuration.rb +87 -0
  16. data/lib/jekyll/assets_plugin/environment.rb +62 -0
  17. data/lib/jekyll/assets_plugin/filters.rb +19 -0
  18. data/lib/jekyll/assets_plugin/patches/asset_patch.rb +68 -0
  19. data/lib/jekyll/assets_plugin/patches/bundled_asset_patch.rb +16 -0
  20. data/lib/jekyll/assets_plugin/patches/context_patch.rb +27 -0
  21. data/lib/jekyll/assets_plugin/patches/index_patch.rb +25 -0
  22. data/lib/jekyll/assets_plugin/patches/processed_asset_patch.rb +60 -0
  23. data/lib/jekyll/assets_plugin/patches/site_patch.rb +68 -0
  24. data/lib/jekyll/assets_plugin/patches.rb +1 -0
  25. data/lib/jekyll/assets_plugin/renderer.rb +47 -0
  26. data/lib/jekyll/assets_plugin/tag.rb +19 -0
  27. data/lib/jekyll/assets_plugin/version.rb +5 -0
  28. data/lib/jekyll/assets_plugin.rb +4 -0
  29. data/lib/jekyll-assets/bootstrap.rb +6 -0
  30. data/lib/jekyll-assets/bourbon.rb +4 -0
  31. data/lib/jekyll-assets/compass.rb +7 -0
  32. data/lib/jekyll-assets/font-awesome.rb +6 -0
  33. data/lib/jekyll-assets/neat.rb +4 -0
  34. data/lib/jekyll-assets.rb +2 -0
  35. data/spec/fixtures/.gitignore +2 -0
  36. data/spec/fixtures/_assets/app.css.erb +5 -0
  37. data/spec/fixtures/_assets/app.js +1 -0
  38. data/spec/fixtures/_assets/fonts/vapor.eot +0 -0
  39. data/spec/fixtures/_assets/fonts/vapor.svg +0 -0
  40. data/spec/fixtures/_assets/fonts/vapor.ttf +0 -0
  41. data/spec/fixtures/_assets/fonts/vapor.woff +0 -0
  42. data/spec/fixtures/_assets/lib/relative.css.scss +12 -0
  43. data/spec/fixtures/_assets/noise.png +0 -0
  44. data/spec/fixtures/_assets/should_be_blank.css.erb +1 -0
  45. data/spec/fixtures/_assets/should_fail.css.erb +1 -0
  46. data/spec/fixtures/_assets/vapor.css.scss +13 -0
  47. data/spec/fixtures/_assets/vapor.js +2 -0
  48. data/spec/fixtures/_assets/vendor/bourbon.css.sass +4 -0
  49. data/spec/fixtures/_assets/vendor/compass.css.sass +4 -0
  50. data/spec/fixtures/_assets/vendor/neat.css.sass +5 -0
  51. data/spec/fixtures/_assets/wowscript.js +0 -0
  52. data/spec/fixtures/_assets/wowstyle.css +0 -0
  53. data/spec/fixtures/_config.yml +2 -0
  54. data/spec/fixtures/_layouts/default.html +9 -0
  55. data/spec/fixtures/_posts/2012-10-19-hello-world.md +6 -0
  56. data/spec/fixtures/index.html +0 -0
  57. data/spec/lib/jekyll/assets_plugin/configuration_spec.rb +167 -0
  58. data/spec/lib/jekyll/assets_plugin/environment_spec.rb +22 -0
  59. data/spec/lib/jekyll/assets_plugin/filters_spec.rb +103 -0
  60. data/spec/lib/jekyll/assets_plugin/patches/site_patch_spec.rb +168 -0
  61. data/spec/lib/jekyll/assets_plugin/renderer_spec.rb +48 -0
  62. data/spec/lib/jekyll/assets_plugin/tag_spec.rb +103 -0
  63. data/spec/lib/jekyll-assets/bootstrap_spec.rb +8 -0
  64. data/spec/lib/jekyll-assets/bourbon_spec.rb +8 -0
  65. data/spec/lib/jekyll-assets/compass_spec.rb +8 -0
  66. data/spec/lib/jekyll-assets/font-awesome_spec.rb +8 -0
  67. data/spec/lib/jekyll-assets/neat_spec.rb +8 -0
  68. data/spec/spec_helper.rb +45 -0
  69. data/spec/support/fixtures_helpers.rb +7 -0
  70. data/tgfa-jekyll-assets.gemspec +41 -0
  71. metadata +322 -0
@@ -0,0 +1,167 @@
1
+ require "spec_helper"
2
+
3
+ describe Jekyll::AssetsPlugin::Configuration do
4
+ context "with defaults" do
5
+ let(:config) { described_class.new }
6
+
7
+ context "output assets dirname" do
8
+ subject { config.dirname }
9
+ it { should == described_class::DEFAULTS[:dirname] }
10
+ end
11
+
12
+ context "assets baseurl" do
13
+ subject { config.baseurl }
14
+ it { should == "/" + described_class::DEFAULTS[:dirname] }
15
+ end
16
+
17
+ context "sources list" do
18
+ subject { config.sources }
19
+ it { should =~ described_class::DEFAULTS[:sources] }
20
+ end
21
+
22
+ context "cachebust" do
23
+ subject { config.cachebust }
24
+ it { should == :hard }
25
+ end
26
+
27
+ context "js compressor" do
28
+ subject { config.js_compressor }
29
+ it { should be_nil }
30
+ end
31
+
32
+ context "css compressor" do
33
+ subject { config.css_compressor }
34
+ it { should be_nil }
35
+ end
36
+
37
+ context "gzip" do
38
+ subject { config.gzip }
39
+ it { should =~ %w[text/css application/javascript] }
40
+ end
41
+
42
+ context "cache_assets?" do
43
+ subject { config.cache_assets? }
44
+ it { should be_false }
45
+ end
46
+
47
+ context "cache_path" do
48
+ subject { config.cache_path }
49
+ it { should == ".jekyll-assets-cache" }
50
+ end
51
+
52
+ context "debug" do
53
+ subject { config.debug }
54
+ it { should be_false }
55
+ end
56
+
57
+ end
58
+
59
+ it "should override specified options and leave defaults for missing" do
60
+ config = described_class.new({
61
+ :sources => %w[abc],
62
+ :css_compressor => "sass"
63
+ })
64
+
65
+ expect(config.dirname).to eq "assets"
66
+ expect(config.sources).to eq %w[abc]
67
+ expect(config.js_compressor).to be_nil
68
+ expect(config.css_compressor).to be :sass
69
+ end
70
+
71
+ context "#cache" do
72
+ context "when specified as String" do
73
+ it "should override default cache path" do
74
+ config = described_class.new :cache => "/tmp/jekyll-assets"
75
+ config.cache_path.should == "/tmp/jekyll-assets"
76
+ end
77
+ end
78
+ end
79
+
80
+ context "#baseurl" do
81
+ it "should respect explicit overrides" do
82
+ described_class.new({
83
+ :dirname => "foo",
84
+ :baseurl => "/bar/"
85
+ }).baseurl.should == "/bar"
86
+ end
87
+
88
+ it "should be auto-guessed from dirname" do
89
+ described_class.new({
90
+ :dirname => "foo"
91
+ }).baseurl.should == "/foo"
92
+ end
93
+ end
94
+
95
+ context "#js_compressor" do
96
+ context "when js compressor is given as `uglify`" do
97
+ let(:config) { described_class.new(:js_compressor => "uglify") }
98
+ subject { config.js_compressor }
99
+ it { should be :uglify }
100
+ end
101
+
102
+ context "otherwise" do
103
+ let(:config) { described_class.new }
104
+ subject { config.js_compressor }
105
+ it { should be_false }
106
+ end
107
+ end
108
+
109
+ context "#css_compressor" do
110
+ context "when css compressor is given as `sass`" do
111
+ let(:config) { described_class.new(:css_compressor => "sass") }
112
+ subject { config.css_compressor }
113
+ it { should be :sass }
114
+ end
115
+
116
+ context "otherwise" do
117
+ let(:config) { described_class.new }
118
+ subject { config.css_compressor }
119
+ it { should be_false }
120
+ end
121
+ end
122
+
123
+ context "#gzip" do
124
+ context "when gzip is disabled" do
125
+ let(:config) { described_class.new(:gzip => false) }
126
+ subject { config.gzip }
127
+ it { should == [] }
128
+ end
129
+ end
130
+
131
+ context "#version" do
132
+ subject { described_class.new(:version => version).version }
133
+
134
+ context "when given as 123" do
135
+ let(:version) { 123 }
136
+ it { should eq 123 }
137
+ it { should be_a Integer }
138
+ end
139
+
140
+ context "when given as 'abc'" do
141
+ let(:version) { "abc" }
142
+ it { should eq "abc" }
143
+ it { should be_a String }
144
+ end
145
+ end
146
+
147
+ context "Deprecated options" do
148
+ subject(:config) { described_class.new options }
149
+
150
+ context "compress" do
151
+ let :options do
152
+ { :compress => { :js => "uglify", :css => "sass" } }
153
+ end
154
+
155
+ its(:js_compressor) { should be :uglify }
156
+ its(:css_compressor) { should be :sass }
157
+ end
158
+
159
+ context "cache_assets" do
160
+ let(:options) { { :cache_assets => true } }
161
+
162
+ it "should set `cache` value" do
163
+ config.cache_assets?.should be_true
164
+ end
165
+ end
166
+ end
167
+ end
@@ -0,0 +1,22 @@
1
+ require "spec_helper"
2
+
3
+ module Jekyll
4
+ module AssetsPlugin
5
+ describe Environment do
6
+ context "#asset_path of context" do
7
+ it "should properly handle query params" do
8
+ css = @site.assets["vapor.css"].to_s
9
+ css.should match(/fonts\/vapor-[a-f0-9]{32}\.eot\?#iefix/)
10
+ css.should match(/fonts\/vapor-[a-f0-9]{32}\.svg#iefix/)
11
+ end
12
+
13
+ it "should properly handle relative paths" do
14
+ css = @site.assets["lib/relative.css"].to_s
15
+ css.should =~ %r{/assets/fonts/vapor-[a-f0-9]{32}\.eot\?#iefix}
16
+ css.should =~ %r{/assets/fonts/vapor-[a-f0-9]{32}\.svg#iefix}
17
+ puts css
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,103 @@
1
+ require "spec_helper"
2
+
3
+ describe Jekyll::AssetsPlugin::Filters do
4
+ let(:context) { { :registers => { :site => @site } } }
5
+
6
+ def render(content)
7
+ ::Liquid::Template.parse(content).render({}, context)
8
+ end
9
+
10
+ context "{{ '<file>' | image }}" do
11
+ def tag_re(name)
12
+ file = "/assets/#{name}-[a-f0-9]{32}\.png"
13
+ Regexp.new "^#{Jekyll::AssetsPlugin::Renderer::IMAGE % file}$"
14
+ end
15
+
16
+ context "when <file> exists" do
17
+ subject { render("{{ 'noise.png' | image }}") }
18
+ it { should match tag_re("noise") }
19
+ end
20
+
21
+ context "when <file> does not exists" do
22
+ subject { render("{{ 'not-found.png' | image }}") }
23
+ it { should match "Liquid error: Couldn't find file 'not-found.png'" }
24
+ end
25
+ end
26
+
27
+ context "{{ '<file>' | stylesheet }}" do
28
+ def tag_re(name)
29
+ file = "/assets/#{name}-[a-f0-9]{32}\.css"
30
+ Regexp.new "^#{Jekyll::AssetsPlugin::Renderer::STYLESHEET % file}$"
31
+ end
32
+
33
+ context "when <file> exists" do
34
+ subject { render("{{ 'app.css' | stylesheet }}") }
35
+ it { should match tag_re("app") }
36
+ end
37
+
38
+ context "when <file> extension is omited" do
39
+ subject { render("{{ 'app' | stylesheet }}") }
40
+ it { should match tag_re("app") }
41
+ end
42
+
43
+ context "when <file> does not exists" do
44
+ subject { render("{{ 'not-found.css' | stylesheet }}") }
45
+ it { should match "Liquid error: Couldn't find file 'not-found.css'" }
46
+ end
47
+ end
48
+
49
+ context "{{ '<file>' | javascript }}" do
50
+ def tag_re(name)
51
+ file = "/assets/#{name}-[a-f0-9]{32}\.js"
52
+ Regexp.new "^#{Jekyll::AssetsPlugin::Renderer::JAVASCRIPT % file}$"
53
+ end
54
+
55
+ context "when <file> exists" do
56
+ subject { render("{{ 'app.js' | javascript }}") }
57
+ it { should match tag_re("app") }
58
+ end
59
+
60
+ context "when <file> extension omited" do
61
+ subject { render("{{ 'app' | javascript }}") }
62
+ it { should match tag_re("app") }
63
+ end
64
+
65
+ context "when <file> does not exists" do
66
+ subject { render("{{ 'not-found.js' | javascript }}") }
67
+ it { should match "Liquid error: Couldn't find file 'not-found.js'" }
68
+ end
69
+ end
70
+
71
+ context "{{ '<file.ext>' | asset_path }}" do
72
+ context "when <file> exists" do
73
+ subject { render("{{ 'app.css' | asset_path }}") }
74
+ it { should match(%r{^/assets/app-[a-f0-9]{32}\.css$}) }
75
+ end
76
+
77
+ context "when <file> does not exists" do
78
+ subject { render("{{ 'not-found.css' | asset_path }}") }
79
+ it { should match "Liquid error: Couldn't find file 'not-found.css'" }
80
+ end
81
+
82
+ context "with baseurl given as /foobar/" do
83
+ before do
84
+ context[:registers][:site].assets_config.baseurl = "/foobar/"
85
+ end
86
+
87
+ subject { render("{{ 'app.css' | asset_path }}") }
88
+ it { should match(%r{^/foobar/app-[a-f0-9]{32}\.css$}) }
89
+ end
90
+ end
91
+
92
+ context "{{ '<file.ext>' | asset }}" do
93
+ context "when <file> exists" do
94
+ subject { render("{{ 'app.css' | asset }}") }
95
+ it { should match(/body \{ background-image: url\(.+?\) \}/) }
96
+ end
97
+
98
+ context "when <file> does not exists" do
99
+ subject { render("{{ 'not-found.js' | asset }}") }
100
+ it { should match "Liquid error: Couldn't find file 'not-found.js'" }
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,168 @@
1
+ require "spec_helper"
2
+
3
+ describe Jekyll::AssetsPlugin::Patches::SitePatch do
4
+ let(:site) do
5
+ Jekyll::Site.new Jekyll.configuration({
6
+ "source" => fixtures_path.to_s,
7
+ "dirname" => "foobar",
8
+ "assets" => {
9
+ "sources" => %w[foobar _assets]
10
+ }
11
+ })
12
+ end
13
+
14
+ context "#assets" do
15
+ subject { site.assets }
16
+ it { should be_a_kind_of ::Sprockets::Environment }
17
+
18
+ context "#cache_path" do
19
+ let(:source_path) { Pathname.new site.source }
20
+ subject { site.assets.cache_path }
21
+
22
+ it { should eq source_path.join(".jekyll-assets-cache") }
23
+ end
24
+
25
+ context "calling #asset_path within assets" do
26
+ context "when requested file not found" do
27
+ it "raises a NotFound error" do
28
+ expect { site.assets["should_fail.css"] }
29
+ .to raise_error Jekyll::AssetsPlugin::Environment::AssetNotFound
30
+ end
31
+ end
32
+
33
+ context "when requested file found" do
34
+ it "should have proper asset path" do
35
+ expect(site.assets["app.css"].to_s)
36
+ .to match(%r{url\(/assets/noise-[a-f0-9]{32}\.png\)})
37
+ end
38
+ end
39
+
40
+ context "when passed a blank path" do
41
+ it "should be blank" do
42
+ expect(site.assets["should_be_blank.css"].to_s)
43
+ .to match(/url\(\)/)
44
+ end
45
+ end
46
+ end
47
+ end
48
+
49
+ context "#asset_path" do
50
+ subject { site.asset_path "app.css" }
51
+
52
+ context "with none cachebust" do
53
+ before { site.assets_config.cachebust = :none }
54
+ it { should match(%r{^/assets/app\.css$}) }
55
+ end
56
+
57
+ context "with soft cachebust" do
58
+ before { site.assets_config.cachebust = :soft }
59
+ it { should match(%r{^/assets/app\.css\?cb=[a-f0-9]{32}$}) }
60
+ end
61
+
62
+ context "with hard cachebust" do
63
+ before { site.assets_config.cachebust = :hard }
64
+ it { should match(%r{^/assets/app-[a-f0-9]{32}\.css$}) }
65
+ end
66
+
67
+ context "with unknown cachebust" do
68
+ before { site.assets_config.cachebust = :wtf }
69
+ it "should raise error" do
70
+ expect { site.asset_path "app.css" }.to raise_error
71
+ end
72
+ end
73
+
74
+ context "with query part in requested filename" do
75
+ subject { site.asset_path "app.css?foo=bar" }
76
+
77
+ context "and none cachebust" do
78
+ before { site.assets_config.cachebust = :none }
79
+ it { should match(%r{^/assets/app\.css\?foo=bar$}) }
80
+ end
81
+
82
+ context "and soft cachebust" do
83
+ before { site.assets_config.cachebust = :soft }
84
+ it { should match %r{^/assets/app\.css\?cb=[a-f0-9]{32}&foo=bar$} }
85
+ end
86
+
87
+ context "and hard cachebust" do
88
+ before { site.assets_config.cachebust = :hard }
89
+ it { should match(%r{^/assets/app-[a-f0-9]{32}\.css\?foo=bar$}) }
90
+ end
91
+ end
92
+
93
+ context "with anchor part in requested filename" do
94
+ subject { site.asset_path "app.css#foobar" }
95
+
96
+ context "and none cachebust" do
97
+ before { site.assets_config.cachebust = :none }
98
+ it { should match(%r{^/assets/app\.css#foobar$}) }
99
+ end
100
+
101
+ context "and soft cachebust" do
102
+ before { site.assets_config.cachebust = :soft }
103
+ it { should match(%r{^/assets/app\.css\?cb=[a-f0-9]{32}#foobar$}) }
104
+ end
105
+
106
+ context "and hard cachebust" do
107
+ before { site.assets_config.cachebust = :hard }
108
+ it { should match(%r{^/assets/app-[a-f0-9]{32}\.css#foobar$}) }
109
+ end
110
+ end
111
+ end
112
+
113
+ context "#assets_config" do
114
+ subject { site.assets_config }
115
+ it { should be_an_instance_of Jekyll::AssetsPlugin::Configuration }
116
+
117
+ it "should been populated with `assets` section of config" do
118
+ site.assets_config.dirname.should_not eq "foobar"
119
+ site.assets_config.sources.should include "foobar"
120
+ end
121
+ end
122
+
123
+ it "should regenerate assets upon multiple #process" do
124
+ @site.assets_config.cachebust = :none
125
+ 2.times { @site.process }
126
+ @dest.join("assets", "app.css").exist?.should be_true
127
+ end
128
+
129
+ context "with cache" do
130
+ def site
131
+ Jekyll::Site.new(Jekyll.configuration({
132
+ "source" => fixtures_path.to_s,
133
+ "assets" => { "cache" => true, "cachebust" => :none },
134
+ "destination" => @dest.to_s
135
+ }))
136
+ end
137
+
138
+ after do
139
+ site.assets.cache_path.rmtree if site.assets.cache_path.exist?
140
+ end
141
+
142
+ it "should regenerate static assets upon multiple #process" do
143
+ 2.times { site.process }
144
+ @dest.join("assets", "noise.png").exist?.should be_true
145
+ end
146
+ end
147
+
148
+ context "#gzip" do
149
+ subject { site.assets_config }
150
+
151
+ it "should generate a static assets if gzip is enabled" do
152
+ @site.assets_config.gzip = true
153
+ @site.process
154
+ @dest.join("assets", "app.css.gz").exist?.should be_true
155
+ end
156
+
157
+ it "should not generate a static assets if gzip is enabled" do
158
+ @site.assets_config.gzip = false
159
+ @site.process
160
+ @dest.join("assets", "app.css.gz").exist?.should be_false
161
+ end
162
+
163
+ end
164
+
165
+ it "should be included into Jekyll::Site" do
166
+ Jekyll::Site.included_modules.should include described_class
167
+ end
168
+ end
@@ -0,0 +1,48 @@
1
+ # stdlib
2
+ require "ostruct"
3
+
4
+ require "spec_helper"
5
+
6
+ describe Jekyll::AssetsPlugin::Renderer do
7
+ let(:site) do
8
+ Jekyll::Site.new Jekyll.configuration({
9
+ "source" => fixtures_path.to_s,
10
+ "destination" => @dest.to_s,
11
+ "assets" => assets_config
12
+ })
13
+ end
14
+
15
+ let(:renderer) do
16
+ context = OpenStruct.new(:registers => { :site => site })
17
+ described_class.new context, "app"
18
+ end
19
+
20
+ describe "#render_javascript" do
21
+ subject { renderer.render_javascript }
22
+
23
+ context "when debug mode enabled" do
24
+ let(:assets_config) { Hash[:debug, true] }
25
+ it { should match(/^(\s*<script src="[^"]+"><\/script>\s*){3}$/) }
26
+ end
27
+
28
+ context "when debug mode disabled" do
29
+ let(:assets_config) { Hash[:debug, false] }
30
+ it { should match(/^(\s*<script src="[^"]+"><\/script>\s*){1}$/) }
31
+ end
32
+ end
33
+
34
+ describe "#render_stylesheet" do
35
+ subject { renderer.render_stylesheet }
36
+
37
+ context "when debug mode enabled" do
38
+ let(:assets_config) { Hash[:debug, true] }
39
+ it { should match(/^(\s*<link rel="stylesheet" [^>]+>\s*){3}$/) }
40
+ end
41
+
42
+ context "when debug mode disabled" do
43
+ let(:assets_config) { Hash[:debug, false] }
44
+ it { should match(/^(\s*<link rel="stylesheet" [^>]+>\s*){1}$/) }
45
+ end
46
+ end
47
+
48
+ end
@@ -0,0 +1,103 @@
1
+ require "spec_helper"
2
+
3
+ describe Jekyll::AssetsPlugin::Tag do
4
+ let(:context) { { :registers => { :site => @site } } }
5
+
6
+ def render(content)
7
+ ::Liquid::Template.parse(content).render({}, context)
8
+ end
9
+
10
+ context "{% image <file> %}" do
11
+ def tag_re(name)
12
+ file = "/assets/#{name}-[a-f0-9]{32}\.png"
13
+ Regexp.new "^#{Jekyll::AssetsPlugin::Renderer::IMAGE % file}$"
14
+ end
15
+
16
+ context "when <file> exists" do
17
+ subject { render("{% image noise.png %}") }
18
+ it { should match tag_re("noise") }
19
+ end
20
+
21
+ context "when <file> does not exists" do
22
+ subject { render("{% image not-found.png %}") }
23
+ it { should match "Liquid error: Couldn't find file 'not-found.png'" }
24
+ end
25
+ end
26
+
27
+ context "{% stylesheet <file> %}" do
28
+ def tag_re(name)
29
+ file = "/assets/#{name}-[a-f0-9]{32}\.css"
30
+ Regexp.new "^#{Jekyll::AssetsPlugin::Renderer::STYLESHEET % file}$"
31
+ end
32
+
33
+ context "when <file> exists" do
34
+ subject { render("{% stylesheet app.css %}") }
35
+ it { should match tag_re("app") }
36
+ end
37
+
38
+ context "when <file> extension is omited" do
39
+ subject { render("{% stylesheet app %}") }
40
+ it { should match tag_re("app") }
41
+ end
42
+
43
+ context "when <file> does not exists" do
44
+ subject { render("{% stylesheet not-found.css %}") }
45
+ it { should match "Liquid error: Couldn't find file 'not-found.css'" }
46
+ end
47
+ end
48
+
49
+ context "{% javascript <file> %}" do
50
+ def tag_re(name)
51
+ file = "/assets/#{name}-[a-f0-9]{32}\.js"
52
+ Regexp.new "^#{Jekyll::AssetsPlugin::Renderer::JAVASCRIPT % file}$"
53
+ end
54
+
55
+ context "when <file> exists" do
56
+ subject { render("{% javascript app.js %}") }
57
+ it { should match tag_re("app") }
58
+ end
59
+
60
+ context "when <file> extension omited" do
61
+ subject { render("{% javascript app %}") }
62
+ it { should match tag_re("app") }
63
+ end
64
+
65
+ context "when <file> does not exists" do
66
+ subject { render("{% javascript not-found.js %}") }
67
+ it { should match "Liquid error: Couldn't find file 'not-found.js'" }
68
+ end
69
+ end
70
+
71
+ context "{% asset_path <file.ext> %}" do
72
+ context "when <file> exists" do
73
+ subject { render("{% asset_path app.css %}") }
74
+ it { should match(%r{^/assets/app-[a-f0-9]{32}\.css$}) }
75
+ end
76
+
77
+ context "when <file> does not exists" do
78
+ subject { render("{% asset_path not-found.js %}") }
79
+ it { should match "Liquid error: Couldn't find file 'not-found.js'" }
80
+ end
81
+
82
+ context "with baseurl given as /foobar/" do
83
+ before do
84
+ context[:registers][:site].assets_config.baseurl = "/foobar/"
85
+ end
86
+
87
+ subject { render("{% asset_path app.css %}") }
88
+ it { should match(%r{^/foobar/app-[a-f0-9]{32}\.css$}) }
89
+ end
90
+ end
91
+
92
+ context "{% asset <file.ext> %}" do
93
+ context "when <file> exists" do
94
+ subject { render("{% asset app.css %}") }
95
+ it { should match(/body \{ background-image: url\(.+?\) \}/) }
96
+ end
97
+
98
+ context "when <file> does not exists" do
99
+ subject { render("{% asset_path not-found.js %}") }
100
+ it { should match "Liquid error: Couldn't find file 'not-found.js'" }
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,8 @@
1
+ require "spec_helper"
2
+ require "jekyll-assets/bootstrap"
3
+
4
+ describe "Bootstrap integration" do
5
+ it "should globally append bootstrap paths into Sprockets environment" do
6
+ @site.assets["bootstrap.css"].to_s.should =~ /bootstrap\//
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require "spec_helper"
2
+ require "jekyll-assets/bourbon"
3
+
4
+ describe "Bourbon integration" do
5
+ it "should globally append bourbon paths into Sprockets environment" do
6
+ @site.assets["vendor/bourbon.css"].to_s.should =~ /linear-gradient/
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require "spec_helper"
2
+ require "jekyll-assets/compass"
3
+
4
+ describe "Compass integration" do
5
+ it "should globally append compass paths into Sprockets environment" do
6
+ @site.assets["vendor/compass.css"].to_s.should =~ /linear-gradient/
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require "spec_helper"
2
+ require "jekyll-assets/font-awesome"
3
+
4
+ describe "Font Awesome integration" do
5
+ it "should globally append font awesome paths into Sprockets environment" do
6
+ @site.assets["font-awesome.css"].to_s.should =~ /fa-github/
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require "spec_helper"
2
+ require "jekyll-assets/neat"
3
+
4
+ describe "Neat integration" do
5
+ it "should globally append neat paths into Sprockets environment" do
6
+ @site.assets["vendor/neat.css"].to_s.should =~ /max-width/
7
+ end
8
+ end