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.
- checksums.yaml +4 -4
- data/cucumber.yml +2 -2
- data/features/builder.feature +1 -1
- data/features/chained_templates.feature +0 -7
- data/features/coffee-script.feature +1 -1
- data/features/collections.feature +2 -2
- data/features/console.feature +1 -1
- data/features/data.feature +31 -0
- data/features/extension_api_deprecations.feature +3 -1
- data/features/extension_hooks.feature +3 -1
- data/features/helpers_external.feature +1 -17
- data/features/i18n_link_to.feature +0 -23
- data/features/i18n_mixed_sources.feature +0 -8
- data/features/i18n_preview.feature +1 -30
- data/features/ignore.feature +11 -67
- data/features/ignore_already_minified.feature +1 -1
- data/features/markdown.feature +1 -0
- data/features/minify_javascript.feature +35 -35
- data/features/mount_rack.feature +0 -1
- data/features/page-id.feature +2 -2
- data/features/partials.feature +1 -1
- data/features/relative_assets_helpers_only.feature +6 -4
- data/features/scss-support.feature +6 -1
- data/features/support/env.rb +5 -5
- data/features/tilde_directories.feature +2 -0
- data/features/unicode_filenames.feature +1 -1
- data/fixtures/asset-hash-app/config.rb +1 -0
- 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-minified-app/config.rb +1 -1
- data/fixtures/asset-hash-prefix/config.rb +2 -1
- data/fixtures/asset-hash-prefix/lib/middleware.rb +2 -2
- data/fixtures/asset-hash-source-map/config.rb +1 -0
- 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 +1 -0
- 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/dynamic-pages-app/config.rb +26 -25
- 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/env-app/source/stylesheets/site.css.scss +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 +1 -3
- data/fixtures/external-helpers/helpers/four_helpers.rb +1 -3
- data/fixtures/external-helpers/helpers/one_helper.rb +1 -3
- data/fixtures/external-helpers/helpers/yet_another_thingy.rb +1 -3
- 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/generator-test/config.rb +15 -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-test-app/locales/en.yml +1 -7
- data/fixtures/i18n-test-app/locales/es.yml +1 -2
- 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-duplicate-file-names-app/config.rb +1 -1
- 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/page-id-app/source/{forty-two.html.erb → fourty-two.html.erb} +0 -0
- 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 +14 -13
- data/fixtures/sass-assets-path-app/config.rb +2 -2
- data/fixtures/scss-app/source/stylesheets/error.css.sass +1 -0
- 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/rack.rb +7 -0
- data/lib/middleman-core/application.rb +9 -10
- data/lib/middleman-core/builder.rb +21 -50
- 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/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/collections.rb +1 -1
- data/lib/middleman-core/core_extensions/data.rb +11 -11
- data/lib/middleman-core/core_extensions/default_helpers.rb +29 -26
- data/lib/middleman-core/core_extensions/external_helpers.rb +1 -1
- 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 +23 -44
- data/lib/middleman-core/core_extensions/inline_url_rewriter.rb +7 -10
- data/lib/middleman-core/core_extensions/routing.rb +1 -1
- data/lib/middleman-core/core_extensions.rb +2 -2
- 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/dns_resolver.rb +1 -1
- data/lib/middleman-core/extension.rb +32 -34
- data/lib/middleman-core/extension_manager.rb +2 -6
- data/lib/middleman-core/extensions/asset_hash.rb +22 -24
- 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 +9 -14
- data/lib/middleman-core/extensions/gzip.rb +6 -8
- data/lib/middleman-core/extensions/lorem.rb +9 -9
- data/lib/middleman-core/extensions/minify_css.rb +16 -14
- data/lib/middleman-core/extensions/minify_javascript.rb +13 -13
- data/lib/middleman-core/extensions/relative_assets.rb +8 -8
- data/lib/middleman-core/extensions.rb +7 -8
- data/lib/middleman-core/file_renderer.rb +6 -7
- data/lib/middleman-core/load_paths.rb +10 -13
- data/lib/middleman-core/logger.rb +4 -3
- data/lib/middleman-core/meta_pages/sitemap_resource.rb +2 -0
- data/lib/middleman-core/meta_pages/sitemap_tree.rb +1 -1
- data/lib/middleman-core/meta_pages.rb +1 -1
- 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_information_callback_proxy.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/preview_server.rb +25 -25
- 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 +4 -8
- data/lib/middleman-core/renderers/less.rb +1 -1
- data/lib/middleman-core/renderers/liquid.rb +2 -3
- 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 +23 -26
- data/lib/middleman-core/renderers/sass_functions.rb +14 -17
- data/lib/middleman-core/renderers/slim.rb +2 -2
- data/lib/middleman-core/sitemap/extensions/ignores.rb +4 -2
- 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 +1 -2
- 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 +25 -80
- data/lib/middleman-core/sitemap/resource.rb +20 -21
- data/lib/middleman-core/sitemap/store.rb +6 -6
- data/lib/middleman-core/sources/source_watcher.rb +11 -17
- data/lib/middleman-core/sources.rb +12 -12
- data/lib/middleman-core/step_definitions/builder_steps.rb +12 -38
- data/lib/middleman-core/step_definitions/commandline_steps.rb +6 -6
- data/lib/middleman-core/step_definitions/middleman_steps.rb +14 -13
- data/lib/middleman-core/step_definitions/server_steps.rb +16 -18
- data/lib/middleman-core/template_context.rb +10 -17
- data/lib/middleman-core/template_renderer.rb +33 -35
- data/lib/middleman-core/util/binary.rb +1 -3
- data/lib/middleman-core/util/data.rb +22 -12
- data/lib/middleman-core/util/files.rb +3 -3
- data/lib/middleman-core/util/paths.rb +44 -47
- data/lib/middleman-core/util/rack.rb +3 -3
- data/lib/middleman-core/util/uri_templates.rb +0 -1
- data/lib/middleman-core/util.rb +2 -2
- data/lib/middleman-core/version.rb +1 -1
- data/lib/middleman-core.rb +3 -3
- data/middleman-core.gemspec +13 -12
- data/spec/middleman-core/callbacks_spec.rb +14 -15
- data/spec/middleman-core/core_extensions/data_spec.rb +74 -70
- data/spec/middleman-core/dns_resolver_spec.rb +6 -6
- data/spec/middleman-core/util_spec.rb +86 -81
- data/spec/spec_helper.rb +6 -1
- data/spec/support/given.rb +15 -11
- metadata +59 -76
- data/features/multiple-sources-reload.feature +0 -40
- data/fixtures/chained-app/source/stylesheets/main.css.scss.erb +0 -3
- data/fixtures/chained-app/source/stylesheets/sub.scss +0 -1
- data/fixtures/destination-dir-different-from-source-dir-name/external/page.html.erb +0 -1
- data/fixtures/destination-dir-different-from-source-dir-name/my-app/config.rb +0 -2
- data/fixtures/destination-dir-different-from-source-dir-name/my-app/source/index.html.erb +0 -1
- data/fixtures/i18n-default-app/source/name.html.erb +0 -1
- data/fixtures/i18n-mixed-sources/source/c/d/index.html.erb +0 -9
- data/fixtures/i18n-mixed-sources/source/localizable/c/d/index.html.erb +0 -9
- data/fixtures/i18n-test-app/source/localizable/tac.html.erb +0 -1
- data/fixtures/multiple-sources-with-destination-dir/config.rb +0 -2
- data/fixtures/multiple-sources-with-destination-dir/external/page.html.erb +0 -1
- data/fixtures/multiple-sources-with-destination-dir/source/index.html.erb +0 -1
- data/fixtures/multiple-sources-without-destination-dir/config.rb +0 -1
- data/fixtures/multiple-sources-without-destination-dir/external/page.html.erb +0 -1
- 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
|
-
|
9
|
+
|
10
|
+
describe "#store" do
|
10
11
|
before :each do
|
11
|
-
@subject = described_class.new instance_double(
|
12
|
+
@subject = described_class.new instance_double("Middleman::Application"),
|
12
13
|
Middleman::CoreExtensions::Data::DATA_FILE_MATCHER
|
13
14
|
end
|
14
15
|
|
15
|
-
context
|
16
|
-
it
|
17
|
-
@subject.store :foo, 'bar' => 'baz'
|
18
|
-
@subject.store :baz,
|
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
|
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
|
25
|
-
@subject.store :foo, 'bar' => 'baz'
|
26
|
-
@subject.store :foo,
|
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
|
29
|
+
expect( @subject.store['foo'] ).to match_array [:wu, :tang]
|
29
30
|
end
|
30
31
|
end
|
31
32
|
|
32
|
-
context
|
33
|
-
it
|
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
|
41
|
+
describe "#callbacks" do
|
41
42
|
before :each do
|
42
|
-
@subject = described_class.new instance_double(
|
43
|
+
@subject = described_class.new instance_double("Middleman::Application"),
|
43
44
|
Middleman::CoreExtensions::Data::DATA_FILE_MATCHER
|
44
45
|
end
|
45
46
|
|
46
|
-
context
|
47
|
-
it
|
48
|
-
@subject.callbacks :foo,
|
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
|
52
|
+
expect( callback.call ).to eq "bar"
|
52
53
|
end
|
53
54
|
|
54
|
-
it
|
55
|
-
@subject.callbacks :foo,
|
56
|
-
@subject.callbacks :foo,
|
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
|
60
|
+
expect( callback.call ).to eq "baz"
|
60
61
|
end
|
61
62
|
end
|
62
63
|
|
63
|
-
context
|
64
|
-
it
|
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
|
72
|
+
describe "#data_for_path" do
|
72
73
|
before :each do
|
73
|
-
@subject = described_class.new instance_double(
|
74
|
+
@subject = described_class.new instance_double("Middleman::Application"),
|
74
75
|
Middleman::CoreExtensions::Data::DATA_FILE_MATCHER
|
75
76
|
end
|
76
77
|
|
77
|
-
context
|
78
|
-
it
|
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
|
84
|
-
@subject.store :foo,
|
85
|
-
expect(@subject.data_for_path(:foo)).to match_array
|
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
|
90
|
-
it
|
91
|
-
@subject.callbacks :foo,
|
92
|
-
@subject.callbacks :wu,
|
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
|
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
|
100
|
-
it
|
101
|
-
@subject.store :foo, 'local' => 'data'
|
102
|
-
@subject.callbacks :foo,
|
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
|
109
|
-
it
|
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
|
116
|
-
|
117
|
-
|
118
|
-
subject.
|
119
|
-
subject.
|
120
|
-
subject.
|
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?(
|
123
|
-
expect(subject.key?(
|
124
|
-
expect(subject.key?(
|
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
|
128
|
-
subject = described_class.new instance_double(
|
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?(
|
131
|
-
expect(subject.key?(
|
132
|
-
expect(subject.key?(
|
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(
|
138
|
+
subject = described_class.new instance_double("Middleman::Application"), Middleman::CoreExtensions::Data::DATA_FILE_MATCHER
|
137
139
|
|
138
|
-
expect
|
140
|
+
expect{
|
139
141
|
subject.respond_to? :test
|
140
|
-
|
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
|
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,82 +2,85 @@ require 'spec_helper'
|
|
2
2
|
require 'middleman-core'
|
3
3
|
|
4
4
|
describe Middleman::Util do
|
5
|
-
|
6
|
-
|
7
|
-
|
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
|
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
|
16
|
+
expect(Middleman::Util.path_match 'ind', '/index.html').to be false
|
16
17
|
end
|
17
18
|
|
18
|
-
it
|
19
|
-
expect(Middleman::Util.path_match
|
20
|
-
expect(Middleman::Util.path_match
|
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
|
24
|
-
matcher =
|
24
|
+
it "works with a proc" do
|
25
|
+
matcher = lambda {|p| p.length > 5 }
|
25
26
|
|
26
|
-
expect(Middleman::Util.path_match
|
27
|
-
expect(Middleman::Util.path_match
|
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
|
31
|
-
expect(Middleman::Util.path_match
|
32
|
-
expect(Middleman::Util.path_match
|
33
|
-
expect(Middleman::Util.path_match
|
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
|
36
|
-
expect(Middleman::Util.path_match
|
37
|
-
expect(Middleman::Util.path_match
|
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
|
42
|
-
%w
|
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
|
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
|
56
|
-
it
|
57
|
-
input = {
|
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
|
61
|
+
expect( subject.test ).to eq "subject"
|
61
62
|
end
|
62
63
|
|
63
|
-
it
|
64
|
-
indifferent_hash = {
|
65
|
-
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
|
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
|
76
|
+
describe "::asset_url" do
|
77
|
+
|
76
78
|
after(:each) do
|
77
79
|
Given.cleanup!
|
78
80
|
end
|
79
81
|
|
80
|
-
context
|
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
|
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
|
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
|
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
|
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
|
114
|
-
current_resource = instance_double(
|
115
|
-
expect(Middleman::Util.asset_url(@mm, 'blank.gif', 'images', current_resource: current_resource,
|
116
|
-
|
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
|
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
|
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
|
-
|
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
|
134
|
-
expect
|
135
|
-
Middleman::Util.asset_url(@mm, 'blank.gif', 'images', relative: true)
|
136
|
-
|
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
|
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
|
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
|
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
|
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
|
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
|
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(
|
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(
|
193
|
+
expect(related).to include File.expand_path("source/index.html.erb")
|
189
194
|
end
|
190
195
|
|
191
|
-
it
|
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(
|
194
|
-
expect(related).to include File.expand_path(
|
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(
|
198
|
-
expect(related).not_to include File.expand_path(
|
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(
|
202
|
-
expect(related).to include File.expand_path(
|
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(
|
206
|
-
expect(related).to include File.expand_path(
|
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
|
211
|
-
it
|
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
|
221
|
+
it "does not loop infinitely when file name is a possible templating engine" do
|
217
222
|
expect do
|
218
|
-
Timeout
|
219
|
-
result = Middleman::Util.step_through_extensions(
|
220
|
-
expect(result).to eq
|
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
|
-
|
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|
|
data/spec/support/given.rb
CHANGED
@@ -1,38 +1,42 @@
|
|
1
1
|
module Given
|
2
|
-
ROOT = File.expand_path('../..',
|
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
|
-
|
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
|
15
|
+
def no_file name
|
15
16
|
FileUtils.rm name, force: true
|
16
17
|
end
|
17
18
|
|
18
|
-
def symlink
|
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
|
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
|
-
|
36
|
+
if File.exist? TMP
|
37
|
+
`rm -rf #{TMP}`
|
38
|
+
end
|
36
39
|
end
|
40
|
+
|
37
41
|
end
|
38
42
|
end
|