middleman-core 4.3.0.rc.1 → 4.3.0.rc.2

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