middleman-core 4.3.0.rc.4 → 4.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (223) hide show
  1. checksums.yaml +4 -4
  2. data/cucumber.yml +2 -2
  3. data/features/builder.feature +1 -1
  4. data/features/chained_templates.feature +0 -7
  5. data/features/coffee-script.feature +1 -1
  6. data/features/collections.feature +2 -2
  7. data/features/console.feature +1 -1
  8. data/features/data.feature +31 -0
  9. data/features/extension_api_deprecations.feature +3 -1
  10. data/features/extension_hooks.feature +3 -1
  11. data/features/helpers_external.feature +1 -17
  12. data/features/i18n_link_to.feature +0 -23
  13. data/features/i18n_mixed_sources.feature +0 -8
  14. data/features/i18n_preview.feature +1 -30
  15. data/features/ignore.feature +11 -67
  16. data/features/ignore_already_minified.feature +1 -1
  17. data/features/markdown.feature +1 -0
  18. data/features/minify_javascript.feature +35 -35
  19. data/features/mount_rack.feature +0 -1
  20. data/features/page-id.feature +2 -2
  21. data/features/partials.feature +1 -1
  22. data/features/relative_assets_helpers_only.feature +6 -4
  23. data/features/scss-support.feature +6 -1
  24. data/features/support/env.rb +5 -5
  25. data/features/tilde_directories.feature +2 -0
  26. data/features/unicode_filenames.feature +1 -1
  27. data/fixtures/asset-hash-app/config.rb +1 -0
  28. data/fixtures/asset-hash-app/lib/middleware.rb +2 -2
  29. data/fixtures/asset-hash-app/source/stylesheets/_partial.sass +1 -1
  30. data/fixtures/asset-hash-minified-app/config.rb +1 -1
  31. data/fixtures/asset-hash-prefix/config.rb +2 -1
  32. data/fixtures/asset-hash-prefix/lib/middleware.rb +2 -2
  33. data/fixtures/asset-hash-source-map/config.rb +1 -0
  34. data/fixtures/asset-hash-source-map/lib/middleware.rb +2 -2
  35. data/fixtures/asset-host-app/config.rb +1 -1
  36. data/fixtures/auto-css-app/config.rb +2 -2
  37. data/fixtures/auto-js-app/config.rb +2 -2
  38. data/fixtures/auto-js-directory-index-app/config.rb +1 -1
  39. data/fixtures/automatic-directory-matcher-app/config.rb +1 -1
  40. data/fixtures/basic-data-app/config.rb +2 -2
  41. data/fixtures/capture-html-app/config.rb +4 -4
  42. data/fixtures/clean-app/config-complications.rb +6 -6
  43. data/fixtures/clean-app/config-hidden-dir-after.rb +4 -4
  44. data/fixtures/clean-app/config-hidden-dir-before.rb +1 -1
  45. data/fixtures/clean-app/config.rb +6 -6
  46. data/fixtures/clean-dir-app/config.rb +1 -0
  47. data/fixtures/clean-nested-app/config.rb +1 -1
  48. data/fixtures/collections-app/source/blog1/2011-01-01-new-article.html.markdown +1 -1
  49. data/fixtures/collections-app/source/blog1/2011-01-02-another-article.html.markdown +1 -1
  50. data/fixtures/collections-app/source/blog2/2011-01-01-new-article.html.markdown +1 -1
  51. data/fixtures/collections-app/source/blog2/2011-01-02-another-article.html.markdown +1 -1
  52. data/fixtures/content-for-app/config.rb +4 -4
  53. data/fixtures/dynamic-pages-app/config.rb +26 -25
  54. data/fixtures/ember-cli-app/config.rb +4 -4
  55. data/fixtures/env-app/environments/development.rb +1 -1
  56. data/fixtures/env-app/environments/production.rb +1 -1
  57. data/fixtures/env-app/source/stylesheets/site.css.scss +1 -1
  58. data/fixtures/extension-hooks-app/config.rb +8 -8
  59. data/fixtures/external-helpers/config.rb +2 -2
  60. data/fixtures/external-helpers/helpers/derp.rb +1 -3
  61. data/fixtures/external-helpers/helpers/four_helpers.rb +1 -3
  62. data/fixtures/external-helpers/helpers/one_helper.rb +1 -3
  63. data/fixtures/external-helpers/helpers/yet_another_thingy.rb +1 -3
  64. data/fixtures/external-helpers/lib/hello_helper.rb +1 -1
  65. data/fixtures/external-pipeline-error/config.rb +4 -4
  66. data/fixtures/feature-params-app/config.rb +1 -1
  67. data/fixtures/frontmatter-app/config.rb +1 -1
  68. data/fixtures/generator-test/config.rb +15 -1
  69. data/fixtures/glob-app/config.rb +1 -1
  70. data/fixtures/i-8859-1-app/config.rb +1 -1
  71. data/fixtures/i18n-force-locale/config.rb +4 -4
  72. data/fixtures/i18n-mixed-sources/config.rb +1 -1
  73. data/fixtures/i18n-test-app/locales/en.yml +1 -7
  74. data/fixtures/i18n-test-app/locales/es.yml +1 -2
  75. data/fixtures/import-app/config.rb +3 -3
  76. data/fixtures/indexable-app/config.rb +3 -3
  77. data/fixtures/large-build-app/config.rb +1 -1
  78. data/fixtures/manual-layout-override/config.rb +1 -1
  79. data/fixtures/missing-tilt-library-app/config.rb +2 -2
  80. data/fixtures/more-traversal-app/config.rb +4 -4
  81. data/fixtures/multiple-data-sources-app/config.rb +1 -1
  82. data/fixtures/multiple-sources-app/config.rb +1 -1
  83. data/fixtures/multiple-sources-with-duplicate-file-names-app/config.rb +1 -1
  84. data/fixtures/nested-layout-app/source/another.html.markdown +1 -1
  85. data/fixtures/nested-layout-app/source/haml-test.html.markdown +1 -1
  86. data/fixtures/nested-layout-app/source/slim-test.html.markdown +1 -1
  87. data/fixtures/padrino-helpers-app/config.rb +1 -1
  88. data/fixtures/page-classes-app/config.rb +2 -2
  89. data/fixtures/page-helper-layout-block-app/config.rb +1 -1
  90. data/fixtures/page-id-app/config-proc.rb +4 -4
  91. data/fixtures/page-id-app/config.rb +3 -3
  92. data/fixtures/page-id-app/source/{forty-two.html.erb → fourty-two.html.erb} +0 -0
  93. data/fixtures/paginate-app/source/blog/2011-01-01-test-article.html.markdown +1 -1
  94. data/fixtures/paginate-app/source/blog/2011-01-02-test-article.html.markdown +1 -1
  95. data/fixtures/paginate-app/source/blog/2011-01-03-test-article.html.markdown +1 -1
  96. data/fixtures/paginate-app/source/blog/2011-01-04-test-article.html.markdown +1 -1
  97. data/fixtures/paginate-app/source/blog/2011-01-05-test-article.html.markdown +1 -1
  98. data/fixtures/paginate-app/source/blog/2011-02-01-test-article.html.markdown +1 -1
  99. data/fixtures/paginate-app/source/blog/2011-02-02-test-article.html.markdown +1 -1
  100. data/fixtures/partials-app/source/_locals.erb +1 -1
  101. data/fixtures/partials-app/source/locals.html.erb +1 -1
  102. data/fixtures/proxy-pages-app/config.rb +14 -13
  103. data/fixtures/sass-assets-path-app/config.rb +2 -2
  104. data/fixtures/scss-app/source/stylesheets/error.css.sass +1 -0
  105. data/fixtures/sinatra-app/config.rb +6 -6
  106. data/fixtures/traversal-app/config.rb +4 -4
  107. data/fixtures/v4-extension-callbacks/config.rb +2 -2
  108. data/fixtures/wildcard-app/config.rb +1 -1
  109. data/fixtures/wildcard-directory-index-app/config.rb +1 -1
  110. data/lib/middleman/rack.rb +7 -0
  111. data/lib/middleman-core/application.rb +9 -10
  112. data/lib/middleman-core/builder.rb +21 -50
  113. data/lib/middleman-core/callback_manager.rb +1 -1
  114. data/lib/middleman-core/config_context.rb +2 -2
  115. data/lib/middleman-core/configuration.rb +5 -5
  116. data/lib/middleman-core/contracts.rb +2 -2
  117. data/lib/middleman-core/core_extensions/collections/lazy_root.rb +1 -1
  118. data/lib/middleman-core/core_extensions/collections/lazy_step.rb +9 -9
  119. data/lib/middleman-core/core_extensions/collections/pagination.rb +6 -6
  120. data/lib/middleman-core/core_extensions/collections.rb +1 -1
  121. data/lib/middleman-core/core_extensions/data.rb +11 -11
  122. data/lib/middleman-core/core_extensions/default_helpers.rb +29 -26
  123. data/lib/middleman-core/core_extensions/external_helpers.rb +1 -1
  124. data/lib/middleman-core/core_extensions/file_watcher.rb +1 -1
  125. data/lib/middleman-core/core_extensions/front_matter.rb +3 -3
  126. data/lib/middleman-core/core_extensions/i18n.rb +23 -44
  127. data/lib/middleman-core/core_extensions/inline_url_rewriter.rb +7 -10
  128. data/lib/middleman-core/core_extensions/routing.rb +1 -1
  129. data/lib/middleman-core/core_extensions.rb +2 -2
  130. data/lib/middleman-core/dns_resolver/basic_network_resolver.rb +3 -3
  131. data/lib/middleman-core/dns_resolver/hosts_resolver.rb +1 -1
  132. data/lib/middleman-core/dns_resolver/local_link_resolver.rb +1 -1
  133. data/lib/middleman-core/dns_resolver/network_resolver.rb +1 -1
  134. data/lib/middleman-core/dns_resolver.rb +1 -1
  135. data/lib/middleman-core/extension.rb +32 -34
  136. data/lib/middleman-core/extension_manager.rb +2 -6
  137. data/lib/middleman-core/extensions/asset_hash.rb +22 -24
  138. data/lib/middleman-core/extensions/asset_host.rb +10 -10
  139. data/lib/middleman-core/extensions/automatic_alt_tags.rb +1 -1
  140. data/lib/middleman-core/extensions/automatic_image_sizes.rb +3 -3
  141. data/lib/middleman-core/extensions/cache_buster.rb +2 -2
  142. data/lib/middleman-core/extensions/directory_indexes.rb +1 -1
  143. data/lib/middleman-core/extensions/external_pipeline.rb +9 -14
  144. data/lib/middleman-core/extensions/gzip.rb +6 -8
  145. data/lib/middleman-core/extensions/lorem.rb +9 -9
  146. data/lib/middleman-core/extensions/minify_css.rb +16 -14
  147. data/lib/middleman-core/extensions/minify_javascript.rb +13 -13
  148. data/lib/middleman-core/extensions/relative_assets.rb +8 -8
  149. data/lib/middleman-core/extensions.rb +7 -8
  150. data/lib/middleman-core/file_renderer.rb +6 -7
  151. data/lib/middleman-core/load_paths.rb +10 -13
  152. data/lib/middleman-core/logger.rb +4 -3
  153. data/lib/middleman-core/meta_pages/sitemap_resource.rb +2 -0
  154. data/lib/middleman-core/meta_pages/sitemap_tree.rb +1 -1
  155. data/lib/middleman-core/meta_pages.rb +1 -1
  156. data/lib/middleman-core/preview_server/checks.rb +1 -1
  157. data/lib/middleman-core/preview_server/information.rb +13 -13
  158. data/lib/middleman-core/preview_server/network_interface_inventory.rb +3 -3
  159. data/lib/middleman-core/preview_server/server_information.rb +1 -1
  160. data/lib/middleman-core/preview_server/server_information_callback_proxy.rb +1 -1
  161. data/lib/middleman-core/preview_server/server_url.rb +1 -1
  162. data/lib/middleman-core/preview_server/tcp_port_prober.rb +1 -1
  163. data/lib/middleman-core/preview_server.rb +25 -25
  164. data/lib/middleman-core/rack.rb +1 -1
  165. data/lib/middleman-core/renderers/coffee_script.rb +2 -2
  166. data/lib/middleman-core/renderers/haml.rb +4 -8
  167. data/lib/middleman-core/renderers/less.rb +1 -1
  168. data/lib/middleman-core/renderers/liquid.rb +2 -3
  169. data/lib/middleman-core/renderers/markdown.rb +7 -7
  170. data/lib/middleman-core/renderers/redcarpet.rb +2 -2
  171. data/lib/middleman-core/renderers/sass.rb +23 -26
  172. data/lib/middleman-core/renderers/sass_functions.rb +14 -17
  173. data/lib/middleman-core/renderers/slim.rb +2 -2
  174. data/lib/middleman-core/sitemap/extensions/ignores.rb +4 -2
  175. data/lib/middleman-core/sitemap/extensions/import.rb +1 -1
  176. data/lib/middleman-core/sitemap/extensions/on_disk.rb +1 -1
  177. data/lib/middleman-core/sitemap/extensions/proxies.rb +1 -2
  178. data/lib/middleman-core/sitemap/extensions/redirects.rb +1 -1
  179. data/lib/middleman-core/sitemap/extensions/request_endpoints.rb +1 -1
  180. data/lib/middleman-core/sitemap/extensions/traversal.rb +25 -80
  181. data/lib/middleman-core/sitemap/resource.rb +20 -21
  182. data/lib/middleman-core/sitemap/store.rb +6 -6
  183. data/lib/middleman-core/sources/source_watcher.rb +11 -17
  184. data/lib/middleman-core/sources.rb +12 -12
  185. data/lib/middleman-core/step_definitions/builder_steps.rb +12 -38
  186. data/lib/middleman-core/step_definitions/commandline_steps.rb +6 -6
  187. data/lib/middleman-core/step_definitions/middleman_steps.rb +14 -13
  188. data/lib/middleman-core/step_definitions/server_steps.rb +16 -18
  189. data/lib/middleman-core/template_context.rb +10 -17
  190. data/lib/middleman-core/template_renderer.rb +33 -35
  191. data/lib/middleman-core/util/binary.rb +1 -3
  192. data/lib/middleman-core/util/data.rb +22 -12
  193. data/lib/middleman-core/util/files.rb +3 -3
  194. data/lib/middleman-core/util/paths.rb +44 -47
  195. data/lib/middleman-core/util/rack.rb +3 -3
  196. data/lib/middleman-core/util/uri_templates.rb +0 -1
  197. data/lib/middleman-core/util.rb +2 -2
  198. data/lib/middleman-core/version.rb +1 -1
  199. data/lib/middleman-core.rb +3 -3
  200. data/middleman-core.gemspec +13 -12
  201. data/spec/middleman-core/callbacks_spec.rb +14 -15
  202. data/spec/middleman-core/core_extensions/data_spec.rb +74 -70
  203. data/spec/middleman-core/dns_resolver_spec.rb +6 -6
  204. data/spec/middleman-core/util_spec.rb +86 -81
  205. data/spec/spec_helper.rb +6 -1
  206. data/spec/support/given.rb +15 -11
  207. metadata +59 -76
  208. data/features/multiple-sources-reload.feature +0 -40
  209. data/fixtures/chained-app/source/stylesheets/main.css.scss.erb +0 -3
  210. data/fixtures/chained-app/source/stylesheets/sub.scss +0 -1
  211. data/fixtures/destination-dir-different-from-source-dir-name/external/page.html.erb +0 -1
  212. data/fixtures/destination-dir-different-from-source-dir-name/my-app/config.rb +0 -2
  213. data/fixtures/destination-dir-different-from-source-dir-name/my-app/source/index.html.erb +0 -1
  214. data/fixtures/i18n-default-app/source/name.html.erb +0 -1
  215. data/fixtures/i18n-mixed-sources/source/c/d/index.html.erb +0 -9
  216. data/fixtures/i18n-mixed-sources/source/localizable/c/d/index.html.erb +0 -9
  217. data/fixtures/i18n-test-app/source/localizable/tac.html.erb +0 -1
  218. data/fixtures/multiple-sources-with-destination-dir/config.rb +0 -2
  219. data/fixtures/multiple-sources-with-destination-dir/external/page.html.erb +0 -1
  220. data/fixtures/multiple-sources-with-destination-dir/source/index.html.erb +0 -1
  221. data/fixtures/multiple-sources-without-destination-dir/config.rb +0 -1
  222. data/fixtures/multiple-sources-without-destination-dir/external/page.html.erb +0 -1
  223. data/fixtures/multiple-sources-without-destination-dir/source/index.html.erb +0 -1
@@ -6,138 +6,142 @@ describe Middleman::CoreExtensions::Data do
6
6
  end
7
7
 
8
8
  describe Middleman::CoreExtensions::Data::DataStore do
9
- describe '#store' do
9
+
10
+ describe "#store" do
10
11
  before :each do
11
- @subject = described_class.new instance_double('Middleman::Application'),
12
+ @subject = described_class.new instance_double("Middleman::Application"),
12
13
  Middleman::CoreExtensions::Data::DATA_FILE_MATCHER
13
14
  end
14
15
 
15
- context 'when given a name and data' do
16
- it 'adds data at the given name' do
17
- @subject.store :foo, 'bar' => 'baz'
18
- @subject.store :baz, %i[wu tang]
16
+ context "when given a name and data" do
17
+ it "adds data at the given name" do
18
+ @subject.store :foo, { 'bar' => 'baz' }
19
+ @subject.store :baz, [:wu, :tang]
19
20
 
20
- expect(@subject.store['foo']).to eq('bar' => 'baz')
21
- expect(@subject.store['baz']).to match_array %i[wu tang]
21
+ expect( @subject.store['foo'] ).to eq({ 'bar' => 'baz' })
22
+ expect( @subject.store['baz'] ).to match_array [:wu, :tang]
22
23
  end
23
24
 
24
- it 'overwrites previous keys if given the same key' do
25
- @subject.store :foo, 'bar' => 'baz'
26
- @subject.store :foo, %i[wu tang]
25
+ it "overwrites previous keys if given the same key" do
26
+ @subject.store :foo, { 'bar' => 'baz' }
27
+ @subject.store :foo, [:wu, :tang]
27
28
 
28
- expect(@subject.store['foo']).to match_array %i[wu tang]
29
+ expect( @subject.store['foo'] ).to match_array [:wu, :tang]
29
30
  end
30
31
  end
31
32
 
32
- context 'when given no args' do
33
- it 'returns @local_sources instance var' do
34
- @subject.instance_variable_set :"@local_sources", foo: 'bar'
35
- expect(@subject.store).to eq(foo: 'bar')
33
+ context "when given no args" do
34
+ it "returns @local_sources instance var" do
35
+ @subject.instance_variable_set :"@local_sources", { foo: 'bar' }
36
+ expect( @subject.store ).to eq({ foo: 'bar' })
36
37
  end
37
38
  end
38
39
  end
39
40
 
40
- describe '#callbacks' do
41
+ describe "#callbacks" do
41
42
  before :each do
42
- @subject = described_class.new instance_double('Middleman::Application'),
43
+ @subject = described_class.new instance_double("Middleman::Application"),
43
44
  Middleman::CoreExtensions::Data::DATA_FILE_MATCHER
44
45
  end
45
46
 
46
- context 'when given a name and proc' do
47
- it 'adds a callback at the given name' do
48
- @subject.callbacks :foo, -> { 'bar' }
47
+ context "when given a name and proc" do
48
+ it "adds a callback at the given name" do
49
+ @subject.callbacks :foo, lambda { "bar" }
49
50
  callback = @subject.instance_variable_get(:@callback_sources)['foo']
50
51
 
51
- expect(callback.call).to eq 'bar'
52
+ expect( callback.call ).to eq "bar"
52
53
  end
53
54
 
54
- it 'overwrites previous keys if given the same key' do
55
- @subject.callbacks :foo, -> { 'bar' }
56
- @subject.callbacks :foo, -> { 'baz' }
55
+ it "overwrites previous keys if given the same key" do
56
+ @subject.callbacks :foo, lambda { "bar" }
57
+ @subject.callbacks :foo, lambda { "baz" }
57
58
  callback = @subject.instance_variable_get(:@callback_sources)['foo']
58
59
 
59
- expect(callback.call).to eq 'baz'
60
+ expect( callback.call ).to eq "baz"
60
61
  end
61
62
  end
62
63
 
63
- context 'when given no args' do
64
- it 'returns @callback_sources instance var' do
65
- @subject.instance_variable_set :"@callback_sources", foo: 'bar'
66
- expect(@subject.callbacks).to eq(foo: 'bar')
64
+ context "when given no args" do
65
+ it "returns @callback_sources instance var" do
66
+ @subject.instance_variable_set :"@callback_sources", { foo: 'bar' }
67
+ expect( @subject.callbacks ).to eq({ foo: 'bar' })
67
68
  end
68
69
  end
69
70
  end
70
71
 
71
- describe '#data_for_path' do
72
+ describe "#data_for_path" do
72
73
  before :each do
73
- @subject = described_class.new instance_double('Middleman::Application'),
74
+ @subject = described_class.new instance_double("Middleman::Application"),
74
75
  Middleman::CoreExtensions::Data::DATA_FILE_MATCHER
75
76
  end
76
77
 
77
- context 'given path matches local data' do
78
- it 'returns hash for key' do
79
- @subject.store :foo, 'bar' => 'baz'
80
- expect(@subject.data_for_path(:foo)).to eq('bar' => 'baz')
78
+ context "given path matches local data" do
79
+ it "returns hash for key" do
80
+ @subject.store :foo, { 'bar' => 'baz' }
81
+ expect( @subject.data_for_path(:foo) ).to eq({ 'bar' => 'baz' })
81
82
  end
82
83
 
83
- it 'returns array for key' do
84
- @subject.store :foo, %i[bar baz]
85
- expect(@subject.data_for_path(:foo)).to match_array %i[bar baz]
84
+ it "returns array for key" do
85
+ @subject.store :foo, [:bar, :baz]
86
+ expect( @subject.data_for_path(:foo) ).to match_array [:bar, :baz]
86
87
  end
87
88
  end
88
89
 
89
- context 'given path matches callback data' do
90
- it 'returns value of callback lambda' do
91
- @subject.callbacks :foo, -> { { 'bar' => 'baz' } }
92
- @subject.callbacks :wu, -> { %i[tang clan] }
90
+ context "given path matches callback data" do
91
+ it "returns value of calback lambda" do
92
+ @subject.callbacks :foo, lambda { { 'bar' => 'baz' } }
93
+ @subject.callbacks :wu, lambda { [:tang, :clan] }
93
94
 
94
- expect(@subject.data_for_path(:foo)).to eq('bar' => 'baz')
95
- expect(@subject.data_for_path(:wu)).to match_array %i[tang clan]
95
+ expect( @subject.data_for_path(:foo) ).to eq({ 'bar' => 'baz' })
96
+ expect( @subject.data_for_path(:wu) ).to match_array [:tang, :clan]
96
97
  end
97
98
  end
98
99
 
99
- context 'given path matches both sources' do
100
- it 'returns match from local data' do
101
- @subject.store :foo, 'local' => 'data'
102
- @subject.callbacks :foo, -> { { 'callback' => 'data' } }
100
+ context "given path matches both sources" do
101
+ it "returns match from local data" do
102
+ @subject.store :foo, { 'local' => 'data' }
103
+ @subject.callbacks :foo, lambda { { 'callback' => 'data' } }
103
104
 
104
- expect(@subject.data_for_path(:foo)).to eq('local' => 'data')
105
+ expect( @subject.data_for_path(:foo) ).to eq({ 'local' => 'data' })
105
106
  end
106
107
  end
107
108
 
108
- context 'given path matches no sources' do
109
- it 'returns nil' do
110
- expect(@subject.data_for_path(:missing)).to be_nil
109
+ context "given path matches no sources" do
110
+ it "returns nil" do
111
+ expect( @subject.data_for_path(:missing) ).to be_nil
111
112
  end
112
113
  end
113
114
  end
114
115
 
115
- describe '#key?' do
116
- it 'returns true if key included in local_data, local_sources, or callback_sources' do
117
- subject = described_class.new instance_double('Middleman::Application'), Middleman::CoreExtensions::Data::DATA_FILE_MATCHER
118
- subject.store :"foo-store", foo: 'bar'
119
- subject.callbacks :"foo-callback", proc { 'bar' }
120
- subject.instance_variable_get(:@local_data)['foo-local'] = 'bar'
116
+ describe "#key?" do
117
+
118
+ it "returns true if key included in local_data, local_sources, or callback_sources" do
119
+ subject = described_class.new instance_double("Middleman::Application"), Middleman::CoreExtensions::Data::DATA_FILE_MATCHER
120
+ subject.store :"foo-store", { foo: "bar" }
121
+ subject.callbacks :"foo-callback", Proc.new { "bar" }
122
+ subject.instance_variable_get(:@local_data)["foo-local"] = "bar"
121
123
 
122
- expect(subject.key?('foo-store')).to be_truthy
123
- expect(subject.key?('foo-callback')).to be_truthy
124
- expect(subject.key?('foo-local')).to be_truthy
124
+ expect( subject.key?("foo-store") ).to be_truthy
125
+ expect( subject.key?("foo-callback") ).to be_truthy
126
+ expect( subject.key?("foo-local") ).to be_truthy
125
127
  end
126
128
 
127
- it 'returns false if key not in local_data, local_sources, or callback_sources' do
128
- subject = described_class.new instance_double('Middleman::Application'), Middleman::CoreExtensions::Data::DATA_FILE_MATCHER
129
+ it "returns false if key not in local_data, local_sources, or callback_sources" do
130
+ subject = described_class.new instance_double("Middleman::Application"), Middleman::CoreExtensions::Data::DATA_FILE_MATCHER
129
131
 
130
- expect(subject.key?('foo-store')).to be_falsy
131
- expect(subject.key?('foo-callback')).to be_falsy
132
- expect(subject.key?('foo-local')).to be_falsy
132
+ expect( subject.key?("foo-store") ).to be_falsy
133
+ expect( subject.key?("foo-callback") ).to be_falsy
134
+ expect( subject.key?("foo-local") ).to be_falsy
133
135
  end
134
136
 
135
137
  it "doesn't raise a stack error if missing the given key" do
136
- subject = described_class.new instance_double('Middleman::Application'), Middleman::CoreExtensions::Data::DATA_FILE_MATCHER
138
+ subject = described_class.new instance_double("Middleman::Application"), Middleman::CoreExtensions::Data::DATA_FILE_MATCHER
137
139
 
138
- expect do
140
+ expect{
139
141
  subject.respond_to? :test
140
- end.not_to raise_error
142
+ }.not_to raise_error
141
143
  end
144
+
142
145
  end
146
+
143
147
  end
@@ -29,7 +29,7 @@ RSpec.describe Middleman::DnsResolver do
29
29
  end
30
30
 
31
31
  let(:unresolved_ip) { '127.0.0.1' }
32
- let(:resolved_names) { %w[localhost] }
32
+ let(:resolved_names) { %w(localhost) }
33
33
 
34
34
  it { expect(resolver.names_for(unresolved_ip)).to eq resolved_names }
35
35
  end
@@ -46,7 +46,7 @@ RSpec.describe Middleman::DnsResolver do
46
46
  end
47
47
 
48
48
  let(:unresolved_ip) { '127.0.0.1' }
49
- let(:resolved_names) { %w[localhost] }
49
+ let(:resolved_names) { %w(localhost) }
50
50
 
51
51
  it { expect(resolver.names_for(unresolved_ip)).to eq resolved_names }
52
52
  end
@@ -61,7 +61,7 @@ RSpec.describe Middleman::DnsResolver do
61
61
  end
62
62
 
63
63
  let(:unresolved_ip) { '127.0.0.1' }
64
- let(:resolved_names) { %w[localhost] }
64
+ let(:resolved_names) { %w(localhost) }
65
65
 
66
66
  it { expect(resolver.names_for(unresolved_ip)).to eq resolved_names }
67
67
  end
@@ -78,7 +78,7 @@ RSpec.describe Middleman::DnsResolver do
78
78
  end
79
79
 
80
80
  let(:unresolved_ips) { '127.0.0.1' }
81
- let(:resolved_name) { %w[localhost] }
81
+ let(:resolved_name) { %w(localhost) }
82
82
 
83
83
  it { expect(resolver.ips_for(unresolved_ips)).to eq resolved_name }
84
84
  end
@@ -95,7 +95,7 @@ RSpec.describe Middleman::DnsResolver do
95
95
  end
96
96
 
97
97
  let(:unresolved_ips) { '127.0.0.1' }
98
- let(:resolved_name) { %w[localhost] }
98
+ let(:resolved_name) { %w(localhost) }
99
99
 
100
100
  it { expect(resolver.ips_for(unresolved_ips)).to eq resolved_name }
101
101
  end
@@ -110,7 +110,7 @@ RSpec.describe Middleman::DnsResolver do
110
110
  end
111
111
 
112
112
  let(:unresolved_ips) { '127.0.0.1' }
113
- let(:resolved_name) { %w[localhost] }
113
+ let(:resolved_name) { %w(localhost) }
114
114
 
115
115
  it { expect(resolver.ips_for(unresolved_ips)).to eq resolved_name }
116
116
  end
@@ -2,82 +2,85 @@ require 'spec_helper'
2
2
  require 'middleman-core'
3
3
 
4
4
  describe Middleman::Util do
5
- describe '::path_match' do
6
- it 'matches a literal string' do
7
- expect(Middleman::Util.path_match('/index.html', '/index.html')).to be true
5
+
6
+ describe "::path_match" do
7
+ it "matches a literal string" do
8
+ expect(Middleman::Util.path_match '/index.html', '/index.html').to be true
8
9
  end
9
10
 
10
11
  it "won't match a wrong string" do
11
- expect(Middleman::Util.path_match('/foo.html', '/index.html')).to be false
12
+ expect(Middleman::Util.path_match '/foo.html', '/index.html').to be false
12
13
  end
13
14
 
14
15
  it "won't match a partial string" do
15
- expect(Middleman::Util.path_match('ind', '/index.html')).to be false
16
+ expect(Middleman::Util.path_match 'ind', '/index.html').to be false
16
17
  end
17
18
 
18
- it 'works with a regex' do
19
- expect(Middleman::Util.path_match(/\.html$/, '/index.html')).to be true
20
- expect(Middleman::Util.path_match(/\.js$/, '/index.html')).to be false
19
+ it "works with a regex" do
20
+ expect(Middleman::Util.path_match /\.html$/, '/index.html').to be true
21
+ expect(Middleman::Util.path_match /\.js$/, '/index.html').to be false
21
22
  end
22
23
 
23
- it 'works with a proc' do
24
- matcher = ->(p) { p.length > 5 }
24
+ it "works with a proc" do
25
+ matcher = lambda {|p| p.length > 5 }
25
26
 
26
- expect(Middleman::Util.path_match(matcher, '/index.html')).to be true
27
- expect(Middleman::Util.path_match(matcher, '/i')).to be false
27
+ expect(Middleman::Util.path_match matcher, '/index.html').to be true
28
+ expect(Middleman::Util.path_match matcher, '/i').to be false
28
29
  end
29
30
 
30
- it 'works with globs' do
31
- expect(Middleman::Util.path_match('/foo/*.html', '/foo/index.html')).to be true
32
- expect(Middleman::Util.path_match('/foo/*.html', '/foo/index.js')).to be false
33
- expect(Middleman::Util.path_match('/bar/*.html', '/foo/index.js')).to be false
31
+ it "works with globs" do
32
+ expect(Middleman::Util.path_match '/foo/*.html', '/foo/index.html').to be true
33
+ expect(Middleman::Util.path_match '/foo/*.html', '/foo/index.js').to be false
34
+ expect(Middleman::Util.path_match '/bar/*.html', '/foo/index.js').to be false
34
35
 
35
- expect(Middleman::Util.path_match('/foo/*', '/foo/bar/index.html')).to be true
36
- expect(Middleman::Util.path_match('/foo/**/*', '/foo/bar/index.html')).to be true
37
- expect(Middleman::Util.path_match('/foo/**', '/foo/bar/index.html')).to be true
36
+ expect(Middleman::Util.path_match '/foo/*', '/foo/bar/index.html').to be true
37
+ expect(Middleman::Util.path_match '/foo/**/*', '/foo/bar/index.html').to be true
38
+ expect(Middleman::Util.path_match '/foo/**', '/foo/bar/index.html').to be true
38
39
  end
39
40
  end
40
41
 
41
- describe '::binary?' do
42
- %w[plain.txt unicode.txt unicode].each do |file|
42
+ describe "::binary?" do
43
+ %w(plain.txt unicode.txt unicode).each do |file|
43
44
  it "recognizes #{file} as not binary" do
44
45
  expect(Middleman::Util.binary?(File.join(File.dirname(__FILE__), "binary_spec/#{file}"))).to be false
45
46
  end
46
47
  end
47
48
 
48
- %w[middleman.png middleman stars.svgz].each do |file|
49
+ %w(middleman.png middleman stars.svgz).each do |file|
49
50
  it "recognizes #{file} as binary" do
50
51
  expect(Middleman::Util.binary?(File.join(File.dirname(__FILE__), "binary_spec/#{file}"))).to be true
51
52
  end
52
53
  end
53
54
  end
54
55
 
55
- describe '::recursively_enhance' do
56
- it 'returns Hashie extended Hash if given a hash' do
57
- input = { test: 'subject' }
56
+ describe "::recursively_enhance" do
57
+ it "returns Hashie extended Hash if given a hash" do
58
+ input = {test: "subject"}
58
59
  subject = Middleman::Util.recursively_enhance input
59
60
 
60
- expect(subject.test).to eq 'subject'
61
+ expect( subject.test ).to eq "subject"
61
62
  end
62
63
 
63
- it 'returns Array with strings, or IndifferentHash, true, false' do
64
- indifferent_hash = { test: 'subject' }
65
- regular_hash = { regular: 'hash' }
66
- input = [indifferent_hash, regular_hash, true, false]
64
+ it "returns Array with strings, or IndifferentHash, true, false" do
65
+ indifferent_hash = {test: "subject"}
66
+ regular_hash = {regular: "hash"}
67
+ input = [ indifferent_hash, regular_hash, true, false ]
67
68
  subject = Middleman::Util.recursively_enhance input
68
69
 
69
- expect(subject[1].regular).to eq 'hash'
70
- expect(subject[2]).to eq true
71
- expect(subject[3]).to eq false
70
+ expect( subject[1].regular ).to eq "hash"
71
+ expect( subject[2] ).to eq true
72
+ expect( subject[3] ).to eq false
72
73
  end
73
74
  end
74
75
 
75
- describe '::asset_url' do
76
+ describe "::asset_url" do
77
+
76
78
  after(:each) do
77
79
  Given.cleanup!
78
80
  end
79
81
 
80
- context 'when http_prefix is activated' do
82
+ context "when http_prefix is activated" do
83
+
81
84
  before(:each) do
82
85
  Given.fixture 'clean-dir-app'
83
86
  Given.file 'source/images/blank.gif', ''
@@ -86,60 +89,61 @@ describe Middleman::Util do
86
89
  end
87
90
  end
88
91
 
89
- it 'returns path with http_prefix pre-pended if resource is found' do
90
- expect(Middleman::Util.asset_url(@mm, 'blank.gif', 'images', http_prefix: 'http_prefix')).to eq 'http_prefix/images/blank.gif'
92
+ it "returns path with http_prefix pre-pended if resource is found" do
93
+ expect( Middleman::Util.asset_url( @mm, 'blank.gif', 'images', http_prefix: 'http_prefix' ) ).to eq 'http_prefix/images/blank.gif'
91
94
  end
92
95
 
93
- it 'returns path with http_prefix pre-pended if resource is not found' do
94
- expect(Middleman::Util.asset_url(@mm, 'missing.gif', 'images', http_prefix: 'http_prefix')).to eq 'http_prefix/images/missing.gif'
96
+ it "returns path with http_prefix pre-pended if resource is not found" do
97
+ expect( Middleman::Util.asset_url( @mm, 'missing.gif', 'images', http_prefix: 'http_prefix' ) ).to eq 'http_prefix/images/missing.gif'
95
98
  end
96
99
  end
97
100
 
98
- it 'returns path relative to the provided current_resource' do
101
+ it "returns path relative to the provided current_resource" do
99
102
  Given.fixture 'clean-dir-app'
100
103
  Given.file 'source/a-path/index.html', ''
101
104
  Given.file 'source/a-path/images/blank.gif', ''
102
105
  @mm = Middleman::Application.new
103
106
  current_resource = @mm.sitemap.find_resource_by_path('a-path/index.html')
104
- expect(Middleman::Util.asset_url(@mm, 'images/blank.gif', 'images', current_resource: current_resource)).to eq '/a-path/images/blank.gif'
107
+ expect( Middleman::Util.asset_url( @mm, 'images/blank.gif', 'images', current_resource: current_resource ) ).to eq '/a-path/images/blank.gif'
105
108
  end
106
109
 
107
- context 'when relative is true' do
110
+ context "when relative is true" do
111
+
108
112
  before(:each) do
109
113
  Given.fixture 'relative-assets-app'
110
114
  @mm = Middleman::Application.new
111
115
  end
112
116
 
113
- it 'returns path relative to the provided current_resource' do
114
- current_resource = instance_double('Middleman::Sitemap::Resource', destination_path: 'a-path/index.html', path: 'a-path/index.html')
115
- expect(Middleman::Util.asset_url(@mm, 'blank.gif', 'images', current_resource: current_resource,
116
- relative: true)).to eq '../images/blank.gif'
117
+ it "returns path relative to the provided current_resource" do
118
+ current_resource = instance_double("Middleman::Sitemap::Resource", destination_path: 'a-path/index.html', path: 'a-path/index.html')
119
+ expect( Middleman::Util.asset_url( @mm, 'blank.gif', 'images', current_resource: current_resource,
120
+ relative: true ) ).to eq '../images/blank.gif'
117
121
  end
118
122
 
119
- context 'when the asset is stored in the same directory as current_resource' do
123
+ context "when the asset is stored in the same directory as current_resource" do
120
124
  before do
121
125
  Given.file 'source/a-path/index.html', ''
122
126
  Given.file 'source/a-path/blank.gif', ''
123
127
  @mm = Middleman::Application.new
124
128
  end
125
129
 
126
- it 'returns path relative to the provided current_resource' do
130
+ it "returns path relative to the provided current_resource" do
127
131
  current_resource = @mm.sitemap.find_resource_by_path('a-path/index.html')
128
- expect(Middleman::Util.asset_url(@mm, 'blank.gif', 'images', current_resource: current_resource,
129
- relative: true)).to eq 'blank.gif'
132
+ expect( Middleman::Util.asset_url( @mm, 'blank.gif', 'images', current_resource: current_resource,
133
+ relative: true) ).to eq 'blank.gif'
130
134
  end
131
135
  end
132
136
 
133
- it 'raises error if not given a current_resource' do
134
- expect do
135
- Middleman::Util.asset_url(@mm, 'blank.gif', 'images', relative: true)
136
- end.to raise_error ArgumentError
137
+ it "raises error if not given a current_resource" do
138
+ expect{
139
+ Middleman::Util.asset_url( @mm, 'blank.gif', 'images', relative: true )
140
+ }.to raise_error ArgumentError
137
141
  end
138
142
  end
139
143
 
140
- it 'returns path if it is already a full path' do
141
- expect(Middleman::Util.asset_url(@mm, 'http://example.com')).to eq 'http://example.com'
142
- expect(Middleman::Util.asset_url(@mm, 'data:example')).to eq 'data:example'
144
+ it "returns path if it is already a full path" do
145
+ expect( Middleman::Util.asset_url( @mm, 'http://example.com' ) ).to eq 'http://example.com'
146
+ expect( Middleman::Util.asset_url( @mm, 'data:example' ) ).to eq 'data:example'
143
147
  end
144
148
 
145
149
  it "returns a resource url if given a resource's destination path" do
@@ -147,26 +151,27 @@ describe Middleman::Util do
147
151
  Given.file 'source/how/about/that.html', ''
148
152
  @mm = Middleman::Application.new
149
153
 
150
- expect(Middleman::Util.asset_url(@mm, '/how/about/that/index.html')).to eq '/how/about/that/'
154
+ expect( Middleman::Util.asset_url( @mm, '/how/about/that/index.html' ) ).to eq '/how/about/that/'
151
155
  end
152
156
 
153
- it 'returns a resource url if given a resources path' do
157
+ it "returns a resource url if given a resources path" do
154
158
  Given.fixture 'clean-dir-app' # includes directory indexes extension
155
159
  Given.file 'source/how/about/that.html', ''
156
160
  @mm = Middleman::Application.new
157
161
 
158
- expect(Middleman::Util.asset_url(@mm, '/how/about/that.html')).to eq '/how/about/that/'
162
+ expect( Middleman::Util.asset_url( @mm, '/how/about/that.html' ) ).to eq '/how/about/that/'
159
163
  end
160
164
 
161
- it 'returns a resource url when asset_hash is on' do
165
+ it "returns a resource url when asset_hash is on" do
162
166
  Given.fixture 'asset-hash-app'
163
167
  @mm = Middleman::Application.new
164
168
 
165
- expect(Middleman::Util.asset_url(@mm, '100px.png', 'images')).to match %r{/images/100px-[a-f0-9]+.png}
169
+ expect( Middleman::Util.asset_url( @mm, '100px.png', 'images') ).to match %r|/images/100px-[a-f0-9]+.png|
166
170
  end
171
+
167
172
  end
168
173
 
169
- describe '::find_related_files' do
174
+ describe "::find_related_files" do
170
175
  after(:each) do
171
176
  Given.cleanup!
172
177
  end
@@ -180,44 +185,44 @@ describe Middleman::Util do
180
185
  Pathname(File.expand_path("source/#{path}"))
181
186
  end
182
187
 
183
- it 'Finds partials possibly related to ERb files' do
188
+ it "Finds partials possibly related to ERb files" do
184
189
  related = Middleman::Util.find_related_files(@mm, [source_file('partials/_test.erb')]).map { |f| f[:full_path].to_s }
185
- expect(related).to include File.expand_path('source/index.html.erb')
190
+ expect(related).to include File.expand_path("source/index.html.erb")
186
191
 
187
192
  related = Middleman::Util.find_related_files(@mm, [source_file('partials/_test2.haml')]).map { |f| f[:full_path].to_s }
188
- expect(related).to include File.expand_path('source/index.html.erb')
193
+ expect(related).to include File.expand_path("source/index.html.erb")
189
194
  end
190
195
 
191
- it 'Finds partials possible related to Scss files' do
196
+ it "Finds partials possible related to Scss files" do
192
197
  related = Middleman::Util.find_related_files(@mm, [source_file('stylesheets/_include4.scss')]).map { |f| f[:full_path].to_s }
193
- expect(related).to include File.expand_path('source/stylesheets/site.css.scss')
194
- expect(related).to include File.expand_path('source/stylesheets/include2.css.scss')
198
+ expect(related).to include File.expand_path("source/stylesheets/site.css.scss")
199
+ expect(related).to include File.expand_path("source/stylesheets/include2.css.scss")
195
200
 
196
201
  related = Middleman::Util.find_related_files(@mm, [source_file('stylesheets/include2.css.scss')]).map { |f| f[:full_path].to_s }
197
- expect(related).to include File.expand_path('source/stylesheets/site.css.scss')
198
- expect(related).not_to include File.expand_path('source/stylesheets/include2.css.scss')
202
+ expect(related).to include File.expand_path("source/stylesheets/site.css.scss")
203
+ expect(related).not_to include File.expand_path("source/stylesheets/include2.css.scss")
199
204
 
200
205
  related = Middleman::Util.find_related_files(@mm, [source_file('stylesheets/include1.css')]).map { |f| f[:full_path].to_s }
201
- expect(related).to include File.expand_path('source/stylesheets/site.css.scss')
202
- expect(related).to include File.expand_path('source/stylesheets/include2.css.scss')
206
+ expect(related).to include File.expand_path("source/stylesheets/site.css.scss")
207
+ expect(related).to include File.expand_path("source/stylesheets/include2.css.scss")
203
208
 
204
209
  related = Middleman::Util.find_related_files(@mm, [source_file('stylesheets/_include3.sass')]).map { |f| f[:full_path].to_s }
205
- expect(related).to include File.expand_path('source/stylesheets/site.css.scss')
206
- expect(related).to include File.expand_path('source/stylesheets/include2.css.scss')
210
+ expect(related).to include File.expand_path("source/stylesheets/site.css.scss")
211
+ expect(related).to include File.expand_path("source/stylesheets/include2.css.scss")
207
212
  end
208
213
  end
209
214
 
210
- describe '::step_through_extensions' do
211
- it 'returns the base name after templating engine extensions are removed' do
215
+ describe "::step_through_extensions" do
216
+ it "returns the base name after templating engine extensions are removed" do
212
217
  result = Middleman::Util.step_through_extensions('my_file.html.haml.erb')
213
218
  expect(result).to eq 'my_file.html'
214
219
  end
215
220
 
216
- it 'does not loop infinitely when file name is a possible templating engine' do
221
+ it "does not loop infinitely when file name is a possible templating engine" do
217
222
  expect do
218
- Timeout.timeout(3.0) do
219
- result = Middleman::Util.step_through_extensions('markdown.scss')
220
- expect(result).to eq 'markdown'
223
+ Timeout::timeout(3.0) do
224
+ result = Middleman::Util.step_through_extensions("markdown.scss")
225
+ expect(result).to eq "markdown"
221
226
  end
222
227
  end.not_to raise_error
223
228
  end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,11 @@
1
1
  require 'simplecov'
2
2
  SimpleCov.root(File.expand_path(File.dirname(__FILE__) + '/..'))
3
- SimpleCov.start
3
+
4
+ require 'coveralls'
5
+ Coveralls.wear!
6
+
7
+ require 'codeclimate-test-reporter'
8
+ CodeClimate::TestReporter.start
4
9
 
5
10
  require 'aruba/api'
6
11
  RSpec.configure do |config|
@@ -1,38 +1,42 @@
1
1
  module Given
2
- ROOT = File.expand_path('../..', __dir__)
3
- TMP = File.join(ROOT, 'tmp')
2
+ ROOT = File.expand_path( '../..', File.dirname( File.realpath(__FILE__) ) )
3
+ TMP = File.join( ROOT, 'tmp' )
4
4
 
5
5
  class << self
6
- def fixture(name)
6
+
7
+ def fixture name
7
8
  cleanup!
8
9
 
9
- `rsync -av #{File.join(ROOT, 'fixtures', name)}/ #{TMP}/`
10
+ `rsync -av #{File.join( ROOT, 'fixtures', name )}/ #{TMP}/`
10
11
  Dir.chdir TMP
11
12
  ENV['MM_ROOT'] = TMP
12
13
  end
13
14
 
14
- def no_file(name)
15
+ def no_file name
15
16
  FileUtils.rm name, force: true
16
17
  end
17
18
 
18
- def symlink(source, destination)
19
+ def symlink source, destination
19
20
  no_file destination
20
21
  FileUtils.symlink File.expand_path(source),
21
22
  File.expand_path(destination),
22
23
  force: true
23
24
  end
24
25
 
25
- def file(name, content)
26
- file_path = File.join(TMP, name)
27
- FileUtils.mkdir_p(File.dirname(file_path))
28
- File.open(file_path, 'w') do |file|
26
+ def file name, content
27
+ file_path = File.join( TMP, name )
28
+ FileUtils.mkdir_p( File.dirname(file_path) )
29
+ File.open( file_path, 'w' ) do |file|
29
30
  file.write content
30
31
  end
31
32
  end
32
33
 
33
34
  def cleanup!
34
35
  Dir.chdir ROOT
35
- `rm -rf #{TMP}` if File.exist? TMP
36
+ if File.exist? TMP
37
+ `rm -rf #{TMP}`
38
+ end
36
39
  end
40
+
37
41
  end
38
42
  end