middleman-sprockets 4.0.0.rc.1 → 4.0.0.rc.2

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.
Files changed (169) hide show
  1. checksums.yaml +4 -4
  2. data/.editorconfig +13 -0
  3. data/.gitignore +2 -0
  4. data/.rubocop.yml +57 -0
  5. data/.simplecov +1 -1
  6. data/.travis.yml +26 -15
  7. data/CHANGELOG.md +15 -0
  8. data/Gemfile +25 -21
  9. data/README.md +60 -6
  10. data/Rakefile +31 -11
  11. data/docs/upgrade-3-to-4.md +118 -0
  12. data/features/asset_gems.feature +63 -0
  13. data/features/basic_usage.feature +97 -0
  14. data/features/bower.feature +90 -30
  15. data/features/linked_assets.feature +123 -0
  16. data/features/middleman_helpers.feature +154 -0
  17. data/features/step_definitions/builder_steps.rb +8 -0
  18. data/features/step_definitions/server_steps.rb +20 -0
  19. data/features/support/env.rb +0 -1
  20. data/features/{asset_hash.feature → test_cases/asset_hash.feature} +28 -22
  21. data/features/test_cases/exception_response.feature +31 -0
  22. data/features/test_cases/excluded_file_extensions.feature +39 -0
  23. data/features/test_cases/file_not_found.feature +31 -0
  24. data/features/test_cases/ignore_directive_is_respected.feature +90 -0
  25. data/features/test_cases/imported_asset_extensions.feature +77 -0
  26. data/features/test_cases/jst.feature +36 -0
  27. data/features/test_cases/long_filenames.feature +40 -0
  28. data/features/test_cases/path_helpers.feature +106 -0
  29. data/features/test_cases/processible_outside_asset_dir.feature +49 -0
  30. data/features/test_cases/sass_globs.feature +76 -0
  31. data/features/test_cases/sass_partials.feature +49 -0
  32. data/features/test_cases/sassc.feature +27 -0
  33. data/features/test_cases/use_from_templates.feature +21 -0
  34. data/features/test_cases/using_assets_gem_assets.feature +88 -0
  35. data/fixtures/asset-hash-app/config.rb +2 -0
  36. data/fixtures/asset-hash-app/source/stylesheets/jquery-mobile.css.scss +1 -0
  37. data/fixtures/asset-hash-host-app/config.rb +4 -4
  38. data/fixtures/base-app/config.rb +1 -0
  39. data/fixtures/{bower-multiple-assets-app/source/index.html → base-app/source/index.html.erb} +0 -0
  40. data/fixtures/gems/assets_gem/assets_gem.gemspec +16 -0
  41. data/fixtures/gems/assets_gem/lib/assets_gem.rb +7 -0
  42. data/fixtures/gems/assets_gem/vendor/assets/css/_imports/_import.scss +1 -0
  43. data/fixtures/{sprockets-imported-assets-match-multiple-paths-app/vendor/assets/css/test.css → gems/assets_gem/vendor/assets/css/test.scss} +1 -1
  44. data/fixtures/gems/assets_gem/vendor/assets/fonts/font.ttf +0 -0
  45. data/fixtures/gems/assets_gem/vendor/assets/images/logo.png +0 -0
  46. data/fixtures/gems/assets_gem/vendor/assets/javascripts/_imports/import.js +1 -0
  47. data/gemfiles/middleman-4.0.gemfile +7 -0
  48. data/gemfiles/middleman-4.1.gemfile +7 -0
  49. data/gemfiles/middleman-head.gemfile +7 -0
  50. data/gemfiles/sprockets-4.0.gemfile +6 -0
  51. data/lib/middleman-sprockets.rb +5 -5
  52. data/lib/middleman-sprockets/extension.rb +174 -215
  53. data/lib/middleman-sprockets/interface.rb +64 -0
  54. data/lib/middleman-sprockets/resource.rb +97 -0
  55. data/lib/middleman-sprockets/version.rb +1 -1
  56. data/middleman-sprockets.gemspec +16 -15
  57. data/tasks/matrix.rake +46 -0
  58. metadata +77 -237
  59. data/features/jst.feature +0 -14
  60. data/features/long_filenames.feature +0 -17
  61. data/features/sass_globs.feature +0 -9
  62. data/features/sass_partials.feature +0 -36
  63. data/features/sprockets.feature +0 -108
  64. data/features/sprockets_gems.feature +0 -48
  65. data/fixtures/asset-paths-app/config.rb +0 -1
  66. data/fixtures/asset-paths-app/derp/javascripts/vendored_js.js +0 -1
  67. data/fixtures/asset-paths-app/source/javascripts/vendored_include.js +0 -1
  68. data/fixtures/bower-app/bower.json +0 -7
  69. data/fixtures/bower-app/bower_components/underscore/bower.json +0 -8
  70. data/fixtures/bower-app/bower_components/underscore/underscore.js +0 -1343
  71. data/fixtures/bower-app/config.rb +0 -1
  72. data/fixtures/bower-app/source/javascripts/application.js +0 -1
  73. data/fixtures/bower-app/source/javascripts/import.js +0 -1
  74. data/fixtures/bower-individual-outputdir-app/bower.json +0 -7
  75. data/fixtures/bower-individual-outputdir-app/bower_components/underscore/bower.json +0 -8
  76. data/fixtures/bower-individual-outputdir-app/bower_components/underscore/underscore.js +0 -1343
  77. data/fixtures/bower-individual-outputdir-app/config.rb +0 -2
  78. data/fixtures/bower-individual-outputdir-app/source/javascripts/application.js +0 -4
  79. data/fixtures/bower-individual-outputdir-app/vendor/assets/components/lightbox2/.bower.json +0 -34
  80. data/fixtures/bower-individual-outputdir-app/vendor/assets/components/lightbox2/bower.json +0 -26
  81. data/fixtures/bower-individual-outputdir-app/vendor/assets/components/lightbox2/img/close.png +0 -0
  82. data/fixtures/bower-individual-outputdir-app/vendor/assets/components/lightbox2/js/lightbox.js +0 -2
  83. data/fixtures/bower-individual-outputdir-app/vendor/assets/components/lightbox2/package.json +0 -37
  84. data/fixtures/bower-json-app/config.rb +0 -1
  85. data/fixtures/bower-json-app/source/javascripts/application.js.coffee +0 -1
  86. data/fixtures/bower-json-app/source/javascripts/bower.json +0 -5
  87. data/fixtures/bower-multiple-assets-app/.bowerrc +0 -4
  88. data/fixtures/bower-multiple-assets-app/bower.json +0 -7
  89. data/fixtures/bower-multiple-assets-app/config.rb +0 -1
  90. data/fixtures/bower-multiple-assets-app/source/javascripts/core.js +0 -2
  91. data/fixtures/bower-multiple-assets-app/vendor/assets/components/lightbox2/.bower.json +0 -34
  92. data/fixtures/bower-multiple-assets-app/vendor/assets/components/lightbox2/bower.json +0 -26
  93. data/fixtures/bower-multiple-assets-app/vendor/assets/components/lightbox2/img/close.png +0 -0
  94. data/fixtures/bower-multiple-assets-app/vendor/assets/components/lightbox2/img/open.png +0 -0
  95. data/fixtures/bower-multiple-assets-app/vendor/assets/components/lightbox2/js/lightbox.js +0 -2
  96. data/fixtures/bower-multiple-assets-app/vendor/assets/components/lightbox2/package.json +0 -37
  97. data/fixtures/glob-app/config.rb +0 -0
  98. data/fixtures/glob-app/source/stylesheets/main.css.scss +0 -1
  99. data/fixtures/glob-app/source/stylesheets/module1/_i-am-mod.scss +0 -3
  100. data/fixtures/glob-app/source/stylesheets/module2/_derp.sass +0 -2
  101. data/fixtures/glob-app/source/stylesheets/shared/3rd-party/bootstrap.sass +0 -2
  102. data/fixtures/glob-app/source/stylesheets/shared/shared.scss +0 -3
  103. data/fixtures/jquery-mobile-app/config.rb +0 -0
  104. data/fixtures/jquery-mobile-app/source/javascripts/app.js +0 -1
  105. data/fixtures/jquery-mobile-app/source/stylesheets/base.css.scss +0 -2
  106. data/fixtures/long-filenames-app/config.rb +0 -0
  107. data/fixtures/long-filenames-app/source/images/00000000-0000-0000-0000-000000.svg +0 -3
  108. data/fixtures/long-filenames-app/source/images/00000000-0000-0000-0000-0000001.svg +0 -3
  109. data/fixtures/preview-app/config.rb +0 -0
  110. data/fixtures/preview-app/source/content.html.erb +0 -1
  111. data/fixtures/preview-app/source/layout.erb +0 -1
  112. data/fixtures/preview-app/source/stylesheets/_partial.sass +0 -2
  113. data/fixtures/preview-app/source/stylesheets/_partial2.css.sass +0 -2
  114. data/fixtures/preview-app/source/stylesheets/main.css.sass +0 -4
  115. data/fixtures/preview-app/source/stylesheets/main2.css.sass +0 -4
  116. data/fixtures/preview-app/source/stylesheets/plain.css.sass +0 -2
  117. data/fixtures/sprockets-app/config.rb +0 -2
  118. data/fixtures/sprockets-app/source/index.html.erb +0 -6
  119. data/fixtures/sprockets-app/source/library/css/bootstrap_include.css.scss +0 -1
  120. data/fixtures/sprockets-app/source/library/css/plain.css +0 -5
  121. data/fixtures/sprockets-app/source/library/css/sprockets_base1.css.scss +0 -1
  122. data/fixtures/sprockets-app/source/library/css/sprockets_base2.css.scss +0 -1
  123. data/fixtures/sprockets-app/source/library/css/sprockets_sub.css.scss +0 -1
  124. data/fixtures/sprockets-app/source/library/js/jquery_include.js +0 -1
  125. data/fixtures/sprockets-app/source/library/js/plain.js +0 -6
  126. data/fixtures/sprockets-app/source/library/js/sprockets_base.js +0 -5
  127. data/fixtures/sprockets-app/source/library/js/sprockets_sub.js +0 -3
  128. data/fixtures/sprockets-app/source/library/js/vendored_include.js +0 -1
  129. data/fixtures/sprockets-app/vendor/assets/javascripts/coffee.js.coffee +0 -2
  130. data/fixtures/sprockets-app/vendor/assets/javascripts/vendored_js.js +0 -1
  131. data/fixtures/sprockets-app/vendor/assets/stylesheets/vendored.css.scss +0 -4
  132. data/fixtures/sprockets-app2/config.rb +0 -0
  133. data/fixtures/sprockets-app2/data/test.yml +0 -4
  134. data/fixtures/sprockets-app2/data/test2.json +0 -4
  135. data/fixtures/sprockets-app2/source/javascripts/_templates/test.jst.ejs +0 -1
  136. data/fixtures/sprockets-app2/source/javascripts/_templates/test2.jst.eco +0 -1
  137. data/fixtures/sprockets-app2/source/javascripts/asset_path.js.erb +0 -3
  138. data/fixtures/sprockets-app2/source/javascripts/multiple_engines.js.coffee.erb +0 -1
  139. data/fixtures/sprockets-app2/source/javascripts/sprockets_base.js +0 -5
  140. data/fixtures/sprockets-app2/source/javascripts/sprockets_sub.js +0 -3
  141. data/fixtures/sprockets-app2/source/javascripts/templates.js +0 -1
  142. data/fixtures/sprockets-app2/source/stylesheets/sprockets_base1.css.scss +0 -1
  143. data/fixtures/sprockets-app2/source/stylesheets/sprockets_base2.css.scss +0 -1
  144. data/fixtures/sprockets-app2/source/stylesheets/sprockets_sub.css.scss +0 -1
  145. data/fixtures/sprockets-images-app/config.rb +0 -1
  146. data/fixtures/sprockets-images-app/source/index.html.erb +0 -10
  147. data/fixtures/sprockets-images-app/source/library/images/cat.jpg +0 -0
  148. data/fixtures/sprockets-images-app/vendor/assets/images/cat-2.jpg +0 -0
  149. data/fixtures/sprockets-imported-asset-path-conflicts-app/config.rb +0 -4
  150. data/fixtures/sprockets-imported-asset-path-conflicts-app/resources/assets/stylesheets/test.css +0 -3
  151. data/fixtures/sprockets-imported-assets-match-multiple-paths-app/config.rb +0 -4
  152. data/fixtures/sprockets-multiple-extensions-app/bower.json +0 -8
  153. data/fixtures/sprockets-multiple-extensions-app/config.rb +0 -1
  154. data/fixtures/sprockets-multiple-extensions-app/source/fonts/fontawesome-webfont-source.svg.gz +0 -0
  155. data/fixtures/sprockets-multiple-extensions-app/source/images/drawing-source.svg +0 -76
  156. data/fixtures/sprockets-multiple-extensions-app/source/stylesheets/app.css.scss +0 -3
  157. data/fixtures/sprockets-multiple-extensions-app/vendor/assets/components/font-awesome/fonts/fontawesome-webfont-bower.svg.gz +0 -0
  158. data/fixtures/sprockets-multiple-extensions-app/vendor/assets/components/jquery/jquery.asdf.asdf.js.min.asdf +0 -4
  159. data/fixtures/sprockets-multiple-extensions-app/vendor/assets/components/jquery/jquery.min.js +0 -4
  160. data/fixtures/sprockets-svg-font-app/bower.json +0 -8
  161. data/fixtures/sprockets-svg-font-app/config.rb +0 -1
  162. data/fixtures/sprockets-svg-font-app/source/fonts/fontawesome-webfont-source.svg +0 -504
  163. data/fixtures/sprockets-svg-font-app/source/fonts/fontawesome-webfont-source.svg.gz +0 -0
  164. data/fixtures/sprockets-svg-font-app/source/images/drawing-source.svg +0 -76
  165. data/fixtures/sprockets-svg-font-app/source/stylesheets/app.css.scss +0 -4
  166. data/fixtures/sprockets-svg-font-app/vendor/assets/components/blub/images/drawing-bower.svg +0 -76
  167. data/fixtures/sprockets-svg-font-app/vendor/assets/components/font-awesome/fonts/fontawesome-webfont-bower.svg +0 -504
  168. data/fixtures/sprockets-svg-font-app/vendor/assets/components/font-awesome/fonts/fontawesome-webfont-bower.svg.gz +0 -0
  169. data/fixtures/sprockets-svg-font-app/vendor/assets/components/font-awesome/fonts/fontawesome-webfont-bower.ttf.gz +0 -0
@@ -0,0 +1,8 @@
1
+ Given /^a built app$/ do
2
+ step %Q{I run `middleman build --verbose`}
3
+ end
4
+
5
+ Given /^a successfully built app$/ do
6
+ step %Q{a built app}
7
+ step %Q{was successfully built}
8
+ end
@@ -1,3 +1,23 @@
1
1
  Given /^wait a second$/ do
2
2
  sleep(1)
3
3
  end
4
+
5
+ Given /^binding.pry/ do
6
+ binding.pry
7
+ end
8
+
9
+ Given /^the file "([^\"]*)" content is changed to\:$/ do |name, content|
10
+ step %Q{a file named "#{name}" with:}, content
11
+ sleep 1
12
+ system "touch #{File.join(ENV['MM_ROOT'], name)}"
13
+ end
14
+
15
+ Then /^sprockets paths should include "([^\"]*)"$/ do |path|
16
+ sprockets = @server_inst.extensions[:sprockets].environment
17
+ expect( sprockets.paths ).to include File.join(ENV['MM_ROOT'], path)
18
+ end
19
+
20
+ Then /^sprockets paths should include gem path "([^\"]*)"/ do |path|
21
+ sprockets = @server_inst.extensions[:sprockets].environment
22
+ expect( sprockets.paths ).to include File.join(PROJECT_ROOT_PATH, 'fixtures', 'gems', path)
23
+ end
@@ -15,4 +15,3 @@ require "middleman-core"
15
15
  require "middleman-core/step_definitions"
16
16
  require File.join(PROJECT_ROOT_PATH, 'lib', 'middleman-sprockets')
17
17
  require "erubis"
18
-
@@ -1,4 +1,6 @@
1
1
  Feature: Assets get a file hash appended to their URL and references to them are updated
2
+
3
+ @asset_hash
2
4
  Scenario: Hashed-asset files are produced, and HTML, CSS, and JavaScript gets rewritten to reference the new files
3
5
  Given a successfully built app at "asset-hash-app"
4
6
  When I cd to "build"
@@ -18,7 +20,7 @@ Feature: Assets get a file hash appended to their URL and references to them are
18
20
  | images/100px.gif |
19
21
  | javascripts/application.js |
20
22
  | stylesheets/site.css |
21
-
23
+
22
24
  And the file "javascripts/application-df677242.js" should contain "img.src = '/images/100px-5fd6fb90.jpg'"
23
25
  And the file "stylesheets/site-2f4798cc.css" should contain 'background-image: url(../images/100px-5fd6fb90.jpg)'
24
26
  And the file "index.html" should contain 'href="stylesheets/site-2f4798cc.css"'
@@ -30,43 +32,46 @@ Feature: Assets get a file hash appended to their URL and references to them are
30
32
  And the file "other/index.html" should contain 'href="../stylesheets/site-2f4798cc.css"'
31
33
  And the file "other/index.html" should contain 'src="../javascripts/application-df677242.js"'
32
34
  And the file "other/index.html" should contain 'src="../images/100px-5fd6fb90.jpg"'
33
-
35
+
36
+ @asset_hash
34
37
  Scenario: Hashed assets work in preview server
35
38
  Given the Server is running at "asset-hash-app"
36
39
  When I go to "/"
37
- Then I should see 'href="stylesheets/site-b7f4d02f.css"'
38
- Then I should see 'href="stylesheets/jquery-mobile-05f64032.css"'
40
+ Then I should see 'href="stylesheets/site-2f4798cc.css"'
41
+ Then I should see 'href="stylesheets/jquery-mobile-08069726.css"'
39
42
  And I should see 'src="javascripts/application-df677242.js"'
40
43
  And I should see 'src="images/100px-5fd6fb90.jpg"'
41
44
  When I go to "/subdir/"
42
- Then I should see 'href="../stylesheets/site-b7f4d02f.css"'
45
+ Then I should see 'href="../stylesheets/site-2f4798cc.css"'
43
46
  And I should see 'src="../javascripts/application-df677242.js"'
44
47
  And I should see 'src="../images/100px-5fd6fb90.jpg"'
45
48
  When I go to "/other/"
46
- Then I should see 'href="../stylesheets/site-b7f4d02f.css"'
49
+ Then I should see 'href="../stylesheets/site-2f4798cc.css"'
47
50
  And I should see 'src="../javascripts/application-df677242.js"'
48
51
  And I should see 'src="../images/100px-5fd6fb90.jpg"'
49
52
  When I go to "/javascripts/application-df677242.js"
50
53
  Then I should see "img.src = '/images/100px-5fd6fb90.jpg'"
51
- When I go to "/stylesheets/site-b7f4d02f.css"
52
- Then I should see 'background-image: url("../images/100px-5fd6fb90.jpg")'
53
- When I go to "/stylesheets/jquery-mobile-05f64032.css"
54
- Then I should see 'background-image: url("../images/jquery-mobile/icons-18-white-1681b2cc.png")'
54
+ When I go to "/stylesheets/site-2f4798cc.css"
55
+ Then I should see 'background-image: url(../images/100px-5fd6fb90.jpg)'
56
+ When I go to "/stylesheets/jquery-mobile-08069726.css"
57
+ Then I should see 'background-image: url(../assets/jquery-mobile/icons-png/action-white-06d3eb76.png)'
55
58
 
56
- Scenario: Enabling an asset host still produces hashed files and references
59
+ @asset_hash
60
+ Scenario: Enabling an asset host still produces hashed files and references
57
61
  Given the Server is running at "asset-hash-host-app"
58
62
  When I go to "/"
59
- Then I should see 'href="http://middlemanapp.com/stylesheets/site-1fdf4fb5.css"'
63
+ Then I should see 'href="http://middlemanapp.com/stylesheets/site-a15e24a3.css"'
60
64
  And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg"'
61
65
  When I go to "/subdir/"
62
- Then I should see 'href="http://middlemanapp.com/stylesheets/site-1fdf4fb5.css"'
66
+ Then I should see 'href="http://middlemanapp.com/stylesheets/site-a15e24a3.css"'
63
67
  And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg"'
64
68
  When I go to "/other/"
65
- Then I should see 'href="http://middlemanapp.com/stylesheets/site-1fdf4fb5.css"'
69
+ Then I should see 'href="http://middlemanapp.com/stylesheets/site-a15e24a3.css"'
66
70
  And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg"'
67
- When I go to "/stylesheets/site-1fdf4fb5.css"
68
- Then I should see 'background-image: url("http://middlemanapp.com/images/100px-5fd6fb90.jpg")'
71
+ When I go to "/stylesheets/site-a15e24a3.css"
72
+ Then I should see 'background-image: url(http://middlemanapp.com/images/100px-5fd6fb90.jpg)'
69
73
 
74
+ @asset_hash
70
75
  Scenario: The asset hash should change when a SASS partial changes
71
76
  Given the Server is running at "asset-hash-app"
72
77
  And the file "source/stylesheets/_partial.sass" has the contents
@@ -75,7 +80,7 @@ Feature: Assets get a file hash appended to their URL and references to them are
75
80
  font-size: 14px
76
81
  """
77
82
  When I go to "/partials/"
78
- Then I should see 'href="../stylesheets/uses_partials-a48be509.css'
83
+ Then I should see 'href="../stylesheets/uses_partials-423a00f7.css'
79
84
  And wait a second
80
85
  And the file "source/stylesheets/_partial.sass" has the contents
81
86
  """
@@ -85,6 +90,7 @@ Feature: Assets get a file hash appended to their URL and references to them are
85
90
  When I go to "/partials/"
86
91
  Then I should see 'href="../stylesheets/uses_partials-e8c3d4eb.css'
87
92
 
93
+ @asset_hash
88
94
  Scenario: The asset hash should change when a Javascript partial changes
89
95
  Given the Server is running at "asset-hash-app"
90
96
  And the file "source/javascripts/sprockets_sub.js" has the contents
@@ -92,8 +98,8 @@ Feature: Assets get a file hash appended to their URL and references to them are
92
98
  function sprockets_sub_function() { }
93
99
  """
94
100
  When I go to "/partials/"
95
- Then I should see 'src="../javascripts/sprockets_base-0252a861.js'
96
- When I go to "/javascripts/sprockets_base-0252a861.js"
101
+ Then I should see 'src="../javascripts/sprockets_base-b80703b7.js'
102
+ When I go to "/javascripts/sprockets_base-b80703b7.js"
97
103
  Then I should see "sprockets_sub_function"
98
104
  And wait a second
99
105
  And the file "source/javascripts/sprockets_sub.js" has the contents
@@ -101,6 +107,6 @@ Feature: Assets get a file hash appended to their URL and references to them are
101
107
  function sprockets_sub2_function() { }
102
108
  """
103
109
  When I go to "/partials/"
104
- Then I should see 'src="../javascripts/sprockets_base-5121d891.js'
105
- When I go to "/javascripts/sprockets_base-5121d891.js"
106
- Then I should see "sprockets_sub2_function"
110
+ Then I should see 'src="../javascripts/sprockets_base-f624ef94.js'
111
+ When I go to "/javascripts/sprockets_base-f624ef94.js"
112
+ Then I should see "sprockets_sub2_function"
@@ -0,0 +1,31 @@
1
+ Feature: Exception response for assets
2
+ It's usefull when running preview server to have assets include an exception response instead of just returning a 500. These exceptions shouldn't be caught during build though so they will show up in the output.
3
+
4
+ Background:
5
+ Given a fixture app "base-app"
6
+ And a file named "config.rb" with:
7
+ """
8
+ activate :sprockets
9
+ """
10
+ And a file named "source/stylesheets/site.css.scss" with:
11
+ """
12
+ body { color: $missing-variable; }
13
+ """
14
+ And a file named "source/javascripts/site.js.coffee" with:
15
+ """
16
+ bad:
17
+ """
18
+
19
+ Scenario: Preview server displays an exception in the language it was generated
20
+ Given the Server is running
21
+
22
+ When going to "/stylesheets/site.css" should not raise an exception
23
+ And I should see 'Error: Undefined variable: "$missing-variable"'
24
+
25
+ When going to "/javascripts/site.js" should not raise an exception
26
+ And I should see 'throw Error("ExecJS::RuntimeError: SyntaxError:'
27
+
28
+
29
+ Scenario: Exceptions are raised during build
30
+ Given a built app
31
+ Then the exit status should be 1
@@ -0,0 +1,39 @@
1
+ Feature: Files with unhandled file extensions are ignored
2
+ We should be able to handle having files in one of the sprockets directories that sprockets can't process without blowing up.
3
+
4
+ Background:
5
+ Given a fixture app "base-app"
6
+
7
+
8
+ Scenario: Dotfiles in js_dir are handled by middleman only
9
+ Given a file named "source/library/js/.jslintrc" with:
10
+ """
11
+ {"bitwise":true}
12
+ """
13
+ And the Server is running
14
+
15
+ When I go to "/library/js/.jslintrc"
16
+ Then I should see '{"bitwise":true}'
17
+
18
+
19
+ Scenario: Files that output as HTML in js_dir aren't handled by Sprockets
20
+ Given a file named "source/library/js/index.html.erb" with:
21
+ """
22
+ <h1><%= current_resource.url %></h1>
23
+ """
24
+ And the Server is running
25
+
26
+ When I go to "/library/js"
27
+ Then I should see "<h1>/library/js/</h1>"
28
+
29
+
30
+ Scenario: Files with Tilt templates, but not supported by sprockets, are handled properly
31
+ Given a file named "source/library/js/index.js.haml" with:
32
+ """
33
+ :plain
34
+ alert('why haml?');
35
+ """
36
+ And the Server is running
37
+
38
+ When I go to "/library/js/index.js"
39
+ Then I should see "alert('why haml?');"
@@ -0,0 +1,31 @@
1
+ Feature: Throw sane error when Sprockets doesn't find an asset
2
+
3
+ Background:
4
+ Given a fixture app "base-app"
5
+ And a file named "config.rb" with:
6
+ """
7
+ activate :sprockets
8
+
9
+ # trick to ensure sprockets has no paths to
10
+ # lookup assets
11
+ ready do
12
+ sprockets.clear_paths
13
+ end
14
+ """
15
+ And a file named "source/stylesheets/main.css.scss" with:
16
+ """
17
+ body { content: 'main'; }
18
+ """
19
+ And a file named "source/javascripts/main.js.coffee" with:
20
+ """
21
+ console.log 'main'
22
+ """
23
+
24
+ Scenario: When a file is removed, a FileNotFound is caught
25
+ Given the Server is running
26
+
27
+ When I go to "/stylesheets/main.css"
28
+ Then I should see "Sprockets::FileNotFound: stylesheets/main.css"
29
+
30
+ When I go to "/javascripts/main.js"
31
+ Then I should see "Sprockets::FileNotFound: javascripts/main.js"
@@ -0,0 +1,90 @@
1
+ Feature: Files that match ignore directives are not built
2
+
3
+ Scenario: Sprockets asset that matches an ignore isn't built # but does link assets
4
+ Given a fixture app "base-app"
5
+ And a file named "config.rb" with:
6
+ """
7
+ activate :sprockets
8
+ ignore "javascripts/vendor/*"
9
+ """
10
+ And a file named "source/javascripts/vendor/site.js" with:
11
+ """
12
+ console.log('vendor/site.js');
13
+ """
14
+ And a file named "source/javascripts/site.js" with:
15
+ """
16
+ //= require 'vendor/site'
17
+ """
18
+ And the Server is running
19
+
20
+ When I go to "/javascripts/vendor/site.js"
21
+ Then the status code should be "404"
22
+
23
+ When I go to "/javascripts/site.js"
24
+ Then the status code should be "200"
25
+ And I should see "console.log('vendor/site.js');"
26
+
27
+ And a built app
28
+ Then the following files should not exist:
29
+ | build/javascripts/vendor/site.js |
30
+ Then the following files should exist:
31
+ | build/javascripts/site.js |
32
+
33
+ Scenario: Sprockets assets that are ignored are processed for links
34
+ Given a fixture app "base-app"
35
+ And a file named "config.rb" with:
36
+ """
37
+ activate :sprockets
38
+ sprockets.append_path File.join(root, 'vendor')
39
+ ignore "javascripts/manifest.js"
40
+ """
41
+ And a file named "vendor/linked.js" with:
42
+ """
43
+ console.log('vendor/linked.js');
44
+ """
45
+ And a file named "source/javascripts/manifest.js" with:
46
+ """
47
+ //= link 'linked'
48
+ """
49
+ And the Server is running
50
+
51
+ When I go to "/javascripts/manifest.js"
52
+ Then the status code should be "404"
53
+
54
+ When I go to "/assets/linked.js"
55
+ Then the status code should be "200"
56
+ And I should see "console.log('vendor/linked.js');"
57
+
58
+ And a built app
59
+ Then the following files should not exist:
60
+ | build/javascripts/manifest.js |
61
+ Then the following files should exist:
62
+ | build/assets/linked.js |
63
+
64
+
65
+ Scenario: Linked assets that match don't build
66
+ Given a fixture app "base-app"
67
+ And a file named "config.rb" with:
68
+ """
69
+ activate :sprockets
70
+ sprockets.append_path File.join(root, 'vendor')
71
+ ignore "assets/vendor/*"
72
+ """
73
+ And a file named "vendor/vendor/site.js" with:
74
+ """
75
+ console.log('vendor/site.js');
76
+ """
77
+ And a file named "source/javascripts/manifest.js" with:
78
+ """
79
+ //= link 'vendor/site'
80
+ """
81
+ And the Server is running
82
+
83
+ When I go to "/assets/vendor/site.js"
84
+ Then the status code should be "404"
85
+
86
+ And a built app
87
+ Then the following files should exist:
88
+ | build/javascripts/manifest.js |
89
+ Then the following files should not exist:
90
+ | build/assets/vendor/site.js |
@@ -0,0 +1,77 @@
1
+ Feature: Imported assets are built with the correct extensions
2
+
3
+ Background:
4
+ Given a fixture app "base-app"
5
+ And a file named "config.rb" with:
6
+ """
7
+ activate :sprockets
8
+ sprockets.append_path File.join(root, 'vendor')
9
+ """
10
+ And a file named "vendor/fonts/webfont-vendor.svg" with:
11
+ """
12
+ """
13
+ And a file named "vendor/fonts/webfont-vendor.svg.gz" with:
14
+ """
15
+ """
16
+ And a file named "vendor/fonts/webfont-vendor.ttf.gz" with:
17
+ """
18
+ """
19
+ And a file named "source/fonts/webfont-source.svg" with:
20
+ """
21
+ """
22
+ And a file named "source/fonts/webfont-source.svg.gz" with:
23
+ """
24
+ """
25
+ And a file named "source/fonts/webfont-source.ttf.gz" with:
26
+ """
27
+ """
28
+ And a file named "vendor/images/drawing-vendor.svg" with:
29
+ """
30
+ """
31
+ And a file named "source/images/drawing-source.svg" with:
32
+ """
33
+ """
34
+ And a file named "vendor/images/extensions-source.svg.gz" with:
35
+ """
36
+ """
37
+ And a file named "vendor/images/extensions-source.min.js" with:
38
+ """
39
+ """
40
+ And a file named "vendor/images/extensions-source.asdf.asdf.min.js.asdf" with:
41
+ """
42
+ """
43
+
44
+
45
+ Scenario: Assets built by being linked are built with the right extension
46
+ Given a file named "source/stylesheets/manifest.css" with:
47
+ """
48
+ //= link 'fonts/webfont-vendor.svg'
49
+ //= link 'fonts/webfont-vendor.svg.gz'
50
+ //= link 'fonts/webfont-vendor.ttf.gz'
51
+ //= link 'images/drawing-vendor.svg'
52
+ //= link 'images/extensions-source.svg.gz'
53
+ //= link 'images/extensions-source.min.js'
54
+ //= link 'images/extensions-source.asdf.asdf.min.js.asdf'
55
+ """
56
+ And a successfully built app
57
+
58
+ When I cd to "build"
59
+ Then the following files should exist:
60
+ | assets/fonts/webfont-vendor.svg |
61
+ | assets/fonts/webfont-vendor.svg.gz |
62
+ | assets/fonts/webfont-vendor.ttf.gz |
63
+ | assets/images/drawing-vendor.svg |
64
+ | assets/images/extensions-source.svg.gz |
65
+ | assets/images/extensions-source.min.js |
66
+ | assets/images/extensions-source.asdf.asdf.min.js.asdf |
67
+
68
+ Scenario: Assets in source don't have their extensions mangled
69
+ Given a successfully built app
70
+
71
+ When I cd to "build"
72
+ Then the following files should exist:
73
+ | fonts/webfont-source.svg |
74
+ | fonts/webfont-source.svg.gz |
75
+ | fonts/webfont-source.ttf.gz |
76
+ | images/drawing-source.svg |
77
+
@@ -0,0 +1,36 @@
1
+ Feature: Sprockets JST & EJS
2
+
3
+ Background:
4
+ Given a fixture app "base-app"
5
+ And a file named "config.rb" with:
6
+ """
7
+ activate :sprockets
8
+ """
9
+ And a file named "source/javascripts/templates.js" with:
10
+ """
11
+ //= require_tree "./_templates"
12
+ """
13
+ And a file named "source/javascripts/_templates/test.jst.ejs" with:
14
+ """
15
+ <%= 'hello' %>
16
+ """
17
+ And a file named "source/javascripts/_templates/test2.jst.eco" with:
18
+ """
19
+ <%= 'world' %>
20
+ """
21
+
22
+ Scenario: Serving .ejs & .eco
23
+ Given the Server is running
24
+
25
+ When I go to "/javascripts/templates.js"
26
+ Then I should see '["_templates/test"] = function'
27
+ And I should see '["_templates/test2"] = function'
28
+
29
+
30
+ Scenario: Building .ejs & .eco
31
+ Given a successfully built app
32
+
33
+ When I cd to "build"
34
+ Then a file named "javascripts/templates.js" should exist
35
+ And the file "javascripts/templates.js" should contain '["_templates/test"] = function'
36
+ And the file "javascripts/templates.js" should contain '["_templates/test2"] = function'