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.
- checksums.yaml +5 -5
- data/Rakefile +0 -1
- data/cucumber.yml +2 -2
- data/features/asset_hash.feature +2 -2
- data/features/collections.feature +2 -2
- data/features/i18n_mixed_sources.feature +8 -0
- data/features/markdown.feature +0 -1
- data/features/multiple-sources-reload.feature +40 -0
- data/features/partials.feature +1 -1
- data/features/support/env.rb +4 -1
- data/features/tilde_directories.feature +0 -2
- data/features/unicode_filenames.feature +1 -1
- data/fixtures/asset-hash-app/config.rb +0 -1
- data/fixtures/asset-hash-app/lib/middleware.rb +2 -2
- data/fixtures/asset-hash-app/source/stylesheets/_partial.sass +1 -1
- data/fixtures/asset-hash-prefix/config.rb +1 -2
- data/fixtures/asset-hash-prefix/lib/middleware.rb +2 -2
- data/fixtures/asset-hash-source-map/config.rb +0 -1
- data/fixtures/asset-hash-source-map/lib/middleware.rb +2 -2
- data/fixtures/asset-host-app/config.rb +1 -1
- data/fixtures/auto-css-app/config.rb +2 -2
- data/fixtures/auto-js-app/config.rb +2 -2
- data/fixtures/auto-js-directory-index-app/config.rb +1 -1
- data/fixtures/automatic-directory-matcher-app/config.rb +1 -1
- data/fixtures/basic-data-app/config.rb +2 -2
- data/fixtures/capture-html-app/config.rb +4 -4
- data/fixtures/clean-app/config-complications.rb +6 -6
- data/fixtures/clean-app/config-hidden-dir-after.rb +4 -4
- data/fixtures/clean-app/config-hidden-dir-before.rb +1 -1
- data/fixtures/clean-app/config.rb +6 -6
- data/fixtures/clean-dir-app/config.rb +0 -1
- data/fixtures/clean-nested-app/config.rb +1 -1
- data/fixtures/collections-app/source/blog1/2011-01-01-new-article.html.markdown +1 -1
- data/fixtures/collections-app/source/blog1/2011-01-02-another-article.html.markdown +1 -1
- data/fixtures/collections-app/source/blog2/2011-01-01-new-article.html.markdown +1 -1
- data/fixtures/collections-app/source/blog2/2011-01-02-another-article.html.markdown +1 -1
- data/fixtures/content-for-app/config.rb +4 -4
- data/fixtures/destination-dir-different-from-source-dir-name/external/page.html.erb +1 -0
- data/fixtures/destination-dir-different-from-source-dir-name/my-app/config.rb +2 -0
- data/fixtures/destination-dir-different-from-source-dir-name/my-app/source/index.html.erb +1 -0
- data/fixtures/dynamic-pages-app/config.rb +25 -26
- data/fixtures/ember-cli-app/config.rb +4 -4
- data/fixtures/env-app/environments/development.rb +1 -1
- data/fixtures/env-app/environments/production.rb +1 -1
- data/fixtures/extension-hooks-app/config.rb +8 -8
- data/fixtures/external-helpers/config.rb +2 -2
- data/fixtures/external-helpers/helpers/derp.rb +3 -1
- data/fixtures/external-helpers/helpers/four_helpers.rb +3 -1
- data/fixtures/external-helpers/helpers/one_helper.rb +3 -1
- data/fixtures/external-helpers/helpers/yet_another_thingy.rb +3 -1
- data/fixtures/external-helpers/lib/hello_helper.rb +1 -1
- data/fixtures/external-pipeline-error/config.rb +4 -4
- data/fixtures/feature-params-app/config.rb +1 -1
- data/fixtures/frontmatter-app/config.rb +1 -1
- data/fixtures/glob-app/config.rb +1 -1
- data/fixtures/i-8859-1-app/config.rb +1 -1
- data/fixtures/i18n-force-locale/config.rb +4 -4
- data/fixtures/i18n-mixed-sources/config.rb +1 -1
- data/fixtures/i18n-mixed-sources/source/c/d/index.html.erb +9 -0
- data/fixtures/i18n-mixed-sources/source/localizable/c/d/index.html.erb +9 -0
- data/fixtures/import-app/config.rb +3 -3
- data/fixtures/indexable-app/config.rb +3 -3
- data/fixtures/large-build-app/config.rb +1 -1
- data/fixtures/manual-layout-override/config.rb +1 -1
- data/fixtures/missing-tilt-library-app/config.rb +2 -2
- data/fixtures/more-traversal-app/config.rb +4 -4
- data/fixtures/multiple-data-sources-app/config.rb +1 -1
- data/fixtures/multiple-sources-app/config.rb +1 -1
- data/fixtures/multiple-sources-with-destination-dir/config.rb +2 -0
- data/fixtures/multiple-sources-with-destination-dir/external/page.html.erb +1 -0
- data/fixtures/multiple-sources-with-destination-dir/source/index.html.erb +1 -0
- data/fixtures/multiple-sources-with-duplicate-file-names-app/config.rb +1 -1
- data/fixtures/multiple-sources-without-destination-dir/config.rb +1 -0
- data/fixtures/multiple-sources-without-destination-dir/external/page.html.erb +1 -0
- data/fixtures/multiple-sources-without-destination-dir/source/index.html.erb +1 -0
- data/fixtures/nested-layout-app/source/another.html.markdown +1 -1
- data/fixtures/nested-layout-app/source/haml-test.html.markdown +1 -1
- data/fixtures/nested-layout-app/source/slim-test.html.markdown +1 -1
- data/fixtures/padrino-helpers-app/config.rb +1 -1
- data/fixtures/page-classes-app/config.rb +2 -2
- data/fixtures/page-helper-layout-block-app/config.rb +1 -1
- data/fixtures/page-id-app/config-proc.rb +4 -4
- data/fixtures/page-id-app/config.rb +3 -3
- data/fixtures/paginate-app/source/blog/2011-01-01-test-article.html.markdown +1 -1
- data/fixtures/paginate-app/source/blog/2011-01-02-test-article.html.markdown +1 -1
- data/fixtures/paginate-app/source/blog/2011-01-03-test-article.html.markdown +1 -1
- data/fixtures/paginate-app/source/blog/2011-01-04-test-article.html.markdown +1 -1
- data/fixtures/paginate-app/source/blog/2011-01-05-test-article.html.markdown +1 -1
- data/fixtures/paginate-app/source/blog/2011-02-01-test-article.html.markdown +1 -1
- data/fixtures/paginate-app/source/blog/2011-02-02-test-article.html.markdown +1 -1
- data/fixtures/partials-app/source/_locals.erb +1 -1
- data/fixtures/partials-app/source/locals.html.erb +1 -1
- data/fixtures/proxy-pages-app/config.rb +13 -14
- data/fixtures/sass-assets-path-app/config.rb +2 -2
- data/fixtures/sinatra-app/config.rb +6 -6
- data/fixtures/traversal-app/config.rb +4 -4
- data/fixtures/v4-extension-callbacks/config.rb +2 -2
- data/fixtures/wildcard-app/config.rb +1 -1
- data/fixtures/wildcard-directory-index-app/config.rb +1 -1
- data/lib/middleman-core.rb +3 -3
- data/lib/middleman-core/application.rb +5 -5
- data/lib/middleman-core/builder.rb +20 -20
- data/lib/middleman-core/callback_manager.rb +1 -1
- data/lib/middleman-core/config_context.rb +2 -2
- data/lib/middleman-core/configuration.rb +5 -5
- data/lib/middleman-core/contracts.rb +2 -2
- data/lib/middleman-core/core_extensions/collections.rb +1 -1
- data/lib/middleman-core/core_extensions/collections/lazy_root.rb +1 -1
- data/lib/middleman-core/core_extensions/collections/lazy_step.rb +9 -9
- data/lib/middleman-core/core_extensions/collections/pagination.rb +6 -6
- data/lib/middleman-core/core_extensions/data.rb +10 -10
- data/lib/middleman-core/core_extensions/default_helpers.rb +26 -22
- data/lib/middleman-core/core_extensions/file_watcher.rb +1 -1
- data/lib/middleman-core/core_extensions/front_matter.rb +3 -3
- data/lib/middleman-core/core_extensions/i18n.rb +24 -24
- data/lib/middleman-core/core_extensions/inline_url_rewriter.rb +10 -7
- data/lib/middleman-core/core_extensions/routing.rb +1 -1
- data/lib/middleman-core/dns_resolver.rb +1 -1
- data/lib/middleman-core/dns_resolver/basic_network_resolver.rb +3 -3
- data/lib/middleman-core/dns_resolver/hosts_resolver.rb +1 -1
- data/lib/middleman-core/dns_resolver/local_link_resolver.rb +1 -1
- data/lib/middleman-core/dns_resolver/network_resolver.rb +1 -1
- data/lib/middleman-core/extension.rb +26 -25
- data/lib/middleman-core/extension_manager.rb +1 -1
- data/lib/middleman-core/extensions.rb +8 -7
- data/lib/middleman-core/extensions/asset_hash.rb +24 -22
- data/lib/middleman-core/extensions/asset_host.rb +10 -10
- data/lib/middleman-core/extensions/automatic_alt_tags.rb +1 -1
- data/lib/middleman-core/extensions/automatic_image_sizes.rb +3 -3
- data/lib/middleman-core/extensions/cache_buster.rb +2 -2
- data/lib/middleman-core/extensions/directory_indexes.rb +1 -1
- data/lib/middleman-core/extensions/external_pipeline.rb +14 -9
- data/lib/middleman-core/extensions/gzip.rb +7 -5
- data/lib/middleman-core/extensions/lorem.rb +9 -9
- data/lib/middleman-core/extensions/minify_css.rb +9 -9
- data/lib/middleman-core/extensions/minify_javascript.rb +10 -10
- data/lib/middleman-core/extensions/relative_assets.rb +8 -8
- data/lib/middleman-core/file_renderer.rb +6 -5
- data/lib/middleman-core/load_paths.rb +10 -10
- data/lib/middleman-core/logger.rb +2 -3
- data/lib/middleman-core/meta_pages.rb +1 -1
- data/lib/middleman-core/preview_server.rb +21 -22
- data/lib/middleman-core/preview_server/checks.rb +1 -1
- data/lib/middleman-core/preview_server/information.rb +13 -13
- data/lib/middleman-core/preview_server/network_interface_inventory.rb +3 -3
- data/lib/middleman-core/preview_server/server_information.rb +1 -1
- data/lib/middleman-core/preview_server/server_url.rb +1 -1
- data/lib/middleman-core/preview_server/tcp_port_prober.rb +1 -1
- data/lib/middleman-core/rack.rb +1 -1
- data/lib/middleman-core/renderers/coffee_script.rb +2 -2
- data/lib/middleman-core/renderers/haml.rb +1 -4
- data/lib/middleman-core/renderers/less.rb +1 -1
- data/lib/middleman-core/renderers/liquid.rb +2 -1
- data/lib/middleman-core/renderers/markdown.rb +7 -7
- data/lib/middleman-core/renderers/redcarpet.rb +2 -2
- data/lib/middleman-core/renderers/sass.rb +5 -5
- data/lib/middleman-core/renderers/sass_functions.rb +5 -5
- data/lib/middleman-core/renderers/slim.rb +2 -2
- data/lib/middleman-core/sitemap/extensions/ignores.rb +2 -4
- data/lib/middleman-core/sitemap/extensions/import.rb +1 -1
- data/lib/middleman-core/sitemap/extensions/on_disk.rb +1 -1
- data/lib/middleman-core/sitemap/extensions/proxies.rb +2 -1
- data/lib/middleman-core/sitemap/extensions/redirects.rb +1 -1
- data/lib/middleman-core/sitemap/extensions/request_endpoints.rb +1 -1
- data/lib/middleman-core/sitemap/extensions/traversal.rb +80 -25
- data/lib/middleman-core/sitemap/resource.rb +21 -20
- data/lib/middleman-core/sitemap/store.rb +3 -3
- data/lib/middleman-core/sources.rb +12 -12
- data/lib/middleman-core/sources/source_watcher.rb +16 -10
- data/lib/middleman-core/step_definitions/builder_steps.rb +23 -23
- data/lib/middleman-core/step_definitions/commandline_steps.rb +5 -5
- data/lib/middleman-core/step_definitions/middleman_steps.rb +13 -14
- data/lib/middleman-core/step_definitions/server_steps.rb +14 -16
- data/lib/middleman-core/template_context.rb +17 -10
- data/lib/middleman-core/template_renderer.rb +34 -32
- data/lib/middleman-core/util.rb +2 -2
- data/lib/middleman-core/util/binary.rb +3 -1
- data/lib/middleman-core/util/data.rb +2 -2
- data/lib/middleman-core/util/files.rb +2 -2
- data/lib/middleman-core/util/paths.rb +47 -44
- data/lib/middleman-core/util/rack.rb +3 -3
- data/lib/middleman-core/util/uri_templates.rb +1 -0
- data/lib/middleman-core/version.rb +1 -1
- data/middleman-core.gemspec +3 -2
- data/spec/middleman-core/callbacks_spec.rb +15 -14
- data/spec/middleman-core/core_extensions/data_spec.rb +70 -74
- data/spec/middleman-core/dns_resolver_spec.rb +6 -6
- data/spec/middleman-core/util_spec.rb +81 -86
- data/spec/support/given.rb +11 -15
- 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(
|
11
|
+
@subject = described_class.new instance_double('Middleman::Application'),
|
13
12
|
Middleman::CoreExtensions::Data::DATA_FILE_MATCHER
|
14
13
|
end
|
15
14
|
|
16
|
-
context
|
17
|
-
it
|
18
|
-
@subject.store :foo,
|
19
|
-
@subject.store :baz, [
|
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(
|
22
|
-
expect(
|
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
|
26
|
-
@subject.store :foo,
|
27
|
-
@subject.store :foo, [
|
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(
|
28
|
+
expect(@subject.store['foo']).to match_array %i[wu tang]
|
30
29
|
end
|
31
30
|
end
|
32
31
|
|
33
|
-
context
|
34
|
-
it
|
35
|
-
@subject.instance_variable_set :"@local_sources",
|
36
|
-
expect(
|
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
|
40
|
+
describe '#callbacks' do
|
42
41
|
before :each do
|
43
|
-
@subject = described_class.new instance_double(
|
42
|
+
@subject = described_class.new instance_double('Middleman::Application'),
|
44
43
|
Middleman::CoreExtensions::Data::DATA_FILE_MATCHER
|
45
44
|
end
|
46
45
|
|
47
|
-
context
|
48
|
-
it
|
49
|
-
@subject.callbacks :foo,
|
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(
|
51
|
+
expect(callback.call).to eq 'bar'
|
53
52
|
end
|
54
53
|
|
55
|
-
it
|
56
|
-
@subject.callbacks :foo,
|
57
|
-
@subject.callbacks :foo,
|
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(
|
59
|
+
expect(callback.call).to eq 'baz'
|
61
60
|
end
|
62
61
|
end
|
63
62
|
|
64
|
-
context
|
65
|
-
it
|
66
|
-
@subject.instance_variable_set :"@callback_sources",
|
67
|
-
expect(
|
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
|
71
|
+
describe '#data_for_path' do
|
73
72
|
before :each do
|
74
|
-
@subject = described_class.new instance_double(
|
73
|
+
@subject = described_class.new instance_double('Middleman::Application'),
|
75
74
|
Middleman::CoreExtensions::Data::DATA_FILE_MATCHER
|
76
75
|
end
|
77
76
|
|
78
|
-
context
|
79
|
-
it
|
80
|
-
@subject.store :foo,
|
81
|
-
expect(
|
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
|
85
|
-
@subject.store :foo, [
|
86
|
-
expect(
|
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
|
91
|
-
it
|
92
|
-
@subject.callbacks :foo,
|
93
|
-
@subject.callbacks :wu,
|
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(
|
96
|
-
expect(
|
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
|
101
|
-
it
|
102
|
-
@subject.store :foo,
|
103
|
-
@subject.callbacks :foo,
|
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(
|
104
|
+
expect(@subject.data_for_path(:foo)).to eq('local' => 'data')
|
106
105
|
end
|
107
106
|
end
|
108
107
|
|
109
|
-
context
|
110
|
-
it
|
111
|
-
expect(
|
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
|
117
|
-
|
118
|
-
|
119
|
-
subject
|
120
|
-
subject.
|
121
|
-
subject.
|
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(
|
125
|
-
expect(
|
126
|
-
expect(
|
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
|
130
|
-
subject = described_class.new instance_double(
|
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(
|
133
|
-
expect(
|
134
|
-
expect(
|
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(
|
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
|
-
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
-
|
7
|
-
|
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
|
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
|
15
|
+
expect(Middleman::Util.path_match('ind', '/index.html')).to be false
|
17
16
|
end
|
18
17
|
|
19
|
-
it
|
20
|
-
expect(Middleman::Util.path_match
|
21
|
-
expect(Middleman::Util.path_match
|
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
|
25
|
-
matcher =
|
23
|
+
it 'works with a proc' do
|
24
|
+
matcher = ->(p) { p.length > 5 }
|
26
25
|
|
27
|
-
expect(Middleman::Util.path_match
|
28
|
-
expect(Middleman::Util.path_match
|
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
|
32
|
-
expect(Middleman::Util.path_match
|
33
|
-
expect(Middleman::Util.path_match
|
34
|
-
expect(Middleman::Util.path_match
|
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
|
37
|
-
expect(Middleman::Util.path_match
|
38
|
-
expect(Middleman::Util.path_match
|
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
|
43
|
-
%w
|
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
|
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
|
57
|
-
it
|
58
|
-
input = {test:
|
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(
|
60
|
+
expect(subject.test).to eq 'subject'
|
62
61
|
end
|
63
62
|
|
64
|
-
it
|
65
|
-
indifferent_hash = {test:
|
66
|
-
regular_hash = {regular:
|
67
|
-
input = [
|
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(
|
71
|
-
expect(
|
72
|
-
expect(
|
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
|
77
|
-
|
75
|
+
describe '::asset_url' do
|
78
76
|
after(:each) do
|
79
77
|
Given.cleanup!
|
80
78
|
end
|
81
79
|
|
82
|
-
context
|
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
|
93
|
-
expect(
|
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
|
97
|
-
expect(
|
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
|
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(
|
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
|
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
|
118
|
-
current_resource = instance_double(
|
119
|
-
expect(
|
120
|
-
|
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
|
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
|
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(
|
133
|
-
|
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
|
138
|
-
expect
|
139
|
-
Middleman::Util.asset_url(
|
140
|
-
|
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
|
145
|
-
expect(
|
146
|
-
expect(
|
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(
|
150
|
+
expect(Middleman::Util.asset_url(@mm, '/how/about/that/index.html')).to eq '/how/about/that/'
|
155
151
|
end
|
156
152
|
|
157
|
-
it
|
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(
|
158
|
+
expect(Middleman::Util.asset_url(@mm, '/how/about/that.html')).to eq '/how/about/that/'
|
163
159
|
end
|
164
160
|
|
165
|
-
it
|
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(
|
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
|
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
|
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(
|
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(
|
188
|
+
expect(related).to include File.expand_path('source/index.html.erb')
|
194
189
|
end
|
195
190
|
|
196
|
-
it
|
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(
|
199
|
-
expect(related).to include File.expand_path(
|
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(
|
203
|
-
expect(related).not_to include File.expand_path(
|
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(
|
207
|
-
expect(related).to include File.expand_path(
|
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(
|
211
|
-
expect(related).to include File.expand_path(
|
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
|
216
|
-
it
|
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
|
216
|
+
it 'does not loop infinitely when file name is a possible templating engine' do
|
222
217
|
expect do
|
223
|
-
Timeout
|
224
|
-
result = Middleman::Util.step_through_extensions(
|
225
|
-
expect(result).to eq
|
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
|