nanoc 4.8.12 → 4.8.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/NEWS.md +6 -0
- data/lib/nanoc/base/entities/document.rb +16 -1
- data/lib/nanoc/base/feature.rb +1 -1
- data/lib/nanoc/base/repos/action_sequence_store.rb +3 -3
- data/lib/nanoc/base/repos/checksum_store.rb +3 -3
- data/lib/nanoc/base/repos/compiled_content_cache.rb +3 -3
- data/lib/nanoc/base/repos/dependency_store.rb +3 -3
- data/lib/nanoc/base/repos/outdatedness_store.rb +3 -3
- data/lib/nanoc/base/repos/store.rb +3 -5
- data/lib/nanoc/base/services/compiler_loader.rb +5 -5
- data/lib/nanoc/base/views/mixins/mutable_document_view_mixin.rb +2 -14
- data/lib/nanoc/cli/commands/compile.rb +18 -0
- data/lib/nanoc/cli/commands/live.rb +1 -0
- data/lib/nanoc/cli/commands/view.rb +12 -35
- data/lib/nanoc/filters/redcarpet.rb +26 -65
- data/lib/nanoc/version.rb +1 -1
- metadata +2 -293
- data/.rspec +0 -3
- data/.rubocop.yml +0 -173
- data/Rakefile +0 -25
- data/nanoc.gemspec +0 -44
- data/nanoc.manifest +0 -543
- data/spec/contributors_spec.rb +0 -20
- data/spec/gem_spec.rb +0 -21
- data/spec/manifest_spec.rb +0 -22
- data/spec/nanoc/base/changes_stream_spec.rb +0 -45
- data/spec/nanoc/base/checksummer_spec.rb +0 -419
- data/spec/nanoc/base/compiler_spec.rb +0 -149
- data/spec/nanoc/base/core_ext/array_spec.rb +0 -35
- data/spec/nanoc/base/core_ext/hash_spec.rb +0 -41
- data/spec/nanoc/base/core_ext/string_spec.rb +0 -23
- data/spec/nanoc/base/directed_graph_spec.rb +0 -258
- data/spec/nanoc/base/entities/action_sequence_spec.rb +0 -297
- data/spec/nanoc/base/entities/code_snippet_spec.rb +0 -60
- data/spec/nanoc/base/entities/configuration_spec.rb +0 -132
- data/spec/nanoc/base/entities/content_spec.rb +0 -195
- data/spec/nanoc/base/entities/context_spec.rb +0 -26
- data/spec/nanoc/base/entities/document_spec.rb +0 -258
- data/spec/nanoc/base/entities/identifiable_collection_spec.rb +0 -209
- data/spec/nanoc/base/entities/identifier_spec.rb +0 -472
- data/spec/nanoc/base/entities/item_rep_spec.rb +0 -26
- data/spec/nanoc/base/entities/item_spec.rb +0 -13
- data/spec/nanoc/base/entities/layout_spec.rb +0 -13
- data/spec/nanoc/base/entities/lazy_value_spec.rb +0 -108
- data/spec/nanoc/base/entities/outdatedness_status_spec.rb +0 -115
- data/spec/nanoc/base/entities/pattern_spec.rb +0 -133
- data/spec/nanoc/base/entities/processing_action_spec.rb +0 -11
- data/spec/nanoc/base/entities/processing_actions/filter_spec.rb +0 -20
- data/spec/nanoc/base/entities/processing_actions/layout_spec.rb +0 -20
- data/spec/nanoc/base/entities/processing_actions/snapshot_spec.rb +0 -40
- data/spec/nanoc/base/entities/props_spec.rb +0 -413
- data/spec/nanoc/base/entities/site_spec.rb +0 -80
- data/spec/nanoc/base/errors/dependency_cycle_spec.rb +0 -35
- data/spec/nanoc/base/feature_spec.rb +0 -109
- data/spec/nanoc/base/filter_spec.rb +0 -166
- data/spec/nanoc/base/item_rep_writer_spec.rb +0 -140
- data/spec/nanoc/base/memoization_spec.rb +0 -108
- data/spec/nanoc/base/repos/aggregate_data_source_spec.rb +0 -87
- data/spec/nanoc/base/repos/checksum_store_spec.rb +0 -155
- data/spec/nanoc/base/repos/compiled_content_cache_spec.rb +0 -65
- data/spec/nanoc/base/repos/config_loader_spec.rb +0 -245
- data/spec/nanoc/base/repos/data_source_spec.rb +0 -95
- data/spec/nanoc/base/repos/dependency_store_spec.rb +0 -515
- data/spec/nanoc/base/repos/in_mem_data_source_spec.rb +0 -39
- data/spec/nanoc/base/repos/outdatedness_store_spec.rb +0 -72
- data/spec/nanoc/base/repos/prefixed_data_source_spec.rb +0 -39
- data/spec/nanoc/base/repos/site_loader_spec.rb +0 -264
- data/spec/nanoc/base/repos/snapshot_repo_spec.rb +0 -316
- data/spec/nanoc/base/repos/store_spec.rb +0 -93
- data/spec/nanoc/base/services/compiler/phases/abstract_spec.rb +0 -63
- data/spec/nanoc/base/services/compiler/phases/cache_spec.rb +0 -156
- data/spec/nanoc/base/services/compiler/stages/calculate_checksums_spec.rb +0 -74
- data/spec/nanoc/base/services/compiler/stages/cleanup_spec.rb +0 -88
- data/spec/nanoc/base/services/compiler/stages/compile_reps_spec.rb +0 -142
- data/spec/nanoc/base/services/compiler/stages/determine_outdatedness_spec.rb +0 -148
- data/spec/nanoc/base/services/compiler/stages/preprocess_spec.rb +0 -110
- data/spec/nanoc/base/services/dependency_tracker_spec.rb +0 -245
- data/spec/nanoc/base/services/executor_spec.rb +0 -686
- data/spec/nanoc/base/services/item_rep_router_spec.rb +0 -198
- data/spec/nanoc/base/services/item_rep_selector_spec.rb +0 -227
- data/spec/nanoc/base/services/notification_center_spec.rb +0 -25
- data/spec/nanoc/base/services/outdatedness_checker_spec.rb +0 -778
- data/spec/nanoc/base/services/outdatedness_rules_spec.rb +0 -495
- data/spec/nanoc/base/services/pruner_spec.rb +0 -116
- data/spec/nanoc/base/services/temp_filename_factory_spec.rb +0 -89
- data/spec/nanoc/base/views/basic_item_rep_collection_view_spec.rb +0 -8
- data/spec/nanoc/base/views/basic_item_rep_view_spec.rb +0 -9
- data/spec/nanoc/base/views/compilation_item_rep_collection_view_spec.rb +0 -8
- data/spec/nanoc/base/views/compilation_item_rep_view_spec.rb +0 -136
- data/spec/nanoc/base/views/config_view_spec.rb +0 -144
- data/spec/nanoc/base/views/item_collection_with_reps_view_spec.rb +0 -23
- data/spec/nanoc/base/views/item_collection_without_reps_view_spec.rb +0 -23
- data/spec/nanoc/base/views/item_view_spec.rb +0 -376
- data/spec/nanoc/base/views/layout_collection_view_spec.rb +0 -23
- data/spec/nanoc/base/views/layout_view_spec.rb +0 -18
- data/spec/nanoc/base/views/mutable_config_view_spec.rb +0 -18
- data/spec/nanoc/base/views/mutable_item_collection_view_spec.rb +0 -60
- data/spec/nanoc/base/views/mutable_item_view_spec.rb +0 -26
- data/spec/nanoc/base/views/mutable_layout_collection_view_spec.rb +0 -60
- data/spec/nanoc/base/views/mutable_layout_view_spec.rb +0 -17
- data/spec/nanoc/base/views/post_compile_item_rep_collection_view_spec.rb +0 -8
- data/spec/nanoc/base/views/post_compile_item_rep_view_spec.rb +0 -216
- data/spec/nanoc/base/views/post_compile_item_view_spec.rb +0 -58
- data/spec/nanoc/base/views/support/document_view_examples.rb +0 -340
- data/spec/nanoc/base/views/support/identifiable_collection_view_examples.rb +0 -277
- data/spec/nanoc/base/views/support/item_rep_collection_view_examples.rb +0 -140
- data/spec/nanoc/base/views/support/item_rep_view_examples.rb +0 -308
- data/spec/nanoc/base/views/support/mutable_document_view_examples.rb +0 -188
- data/spec/nanoc/base/views/support/mutable_identifiable_collection_view_examples.rb +0 -44
- data/spec/nanoc/checking/runner_spec.rb +0 -26
- data/spec/nanoc/cli/command_runner_spec.rb +0 -107
- data/spec/nanoc/cli/commands/compile/abstract_spec.rb +0 -80
- data/spec/nanoc/cli/commands/compile/diff_generator_spec.rb +0 -44
- data/spec/nanoc/cli/commands/compile/file_action_printer_spec.rb +0 -112
- data/spec/nanoc/cli/commands/compile/timing_recorder_spec.rb +0 -287
- data/spec/nanoc/cli/commands/compile_spec.rb +0 -45
- data/spec/nanoc/cli/commands/deploy_spec.rb +0 -329
- data/spec/nanoc/cli/commands/shell_spec.rb +0 -77
- data/spec/nanoc/cli/commands/show_data_spec.rb +0 -286
- data/spec/nanoc/cli/commands/show_plugins_spec.rb +0 -20
- data/spec/nanoc/cli/commands/show_rules_spec.rb +0 -118
- data/spec/nanoc/cli/commands/view_spec.rb +0 -75
- data/spec/nanoc/cli/error_handler_spec.rb +0 -43
- data/spec/nanoc/cli/stack_trace_writer_spec.rb +0 -156
- data/spec/nanoc/cli/stream_cleaners/utf8_spec.rb +0 -9
- data/spec/nanoc/cli_spec.rb +0 -44
- data/spec/nanoc/data_sources/filesystem_spec.rb +0 -128
- data/spec/nanoc/deploying/fog_spec.rb +0 -199
- data/spec/nanoc/deploying/git_spec.rb +0 -305
- data/spec/nanoc/extra/live_recompiler_spec.rb +0 -129
- data/spec/nanoc/extra/parallel_collection_spec.rb +0 -110
- data/spec/nanoc/filters/asciidoctor_spec.rb +0 -12
- data/spec/nanoc/filters/colorize_syntax/rouge_spec.rb +0 -155
- data/spec/nanoc/filters/less_spec.rb +0 -122
- data/spec/nanoc/helpers/blogging_spec.rb +0 -219
- data/spec/nanoc/helpers/breadcrumbs_spec.rb +0 -135
- data/spec/nanoc/helpers/capturing_spec.rb +0 -256
- data/spec/nanoc/helpers/child_parent_spec.rb +0 -76
- data/spec/nanoc/helpers/filtering_spec.rb +0 -77
- data/spec/nanoc/helpers/html_escape_spec.rb +0 -37
- data/spec/nanoc/helpers/link_to_spec.rb +0 -320
- data/spec/nanoc/helpers/rendering_spec.rb +0 -144
- data/spec/nanoc/helpers/tagging_spec.rb +0 -106
- data/spec/nanoc/helpers/text_spec.rb +0 -60
- data/spec/nanoc/integration/compile_command_spec.rb +0 -33
- data/spec/nanoc/integration/outdatedness_integration_spec.rb +0 -269
- data/spec/nanoc/integration/partial_recompilation_spec.rb +0 -50
- data/spec/nanoc/regressions/gh_1015_spec.rb +0 -19
- data/spec/nanoc/regressions/gh_1022_spec.rb +0 -26
- data/spec/nanoc/regressions/gh_1031_spec.rb +0 -56
- data/spec/nanoc/regressions/gh_1035_spec.rb +0 -35
- data/spec/nanoc/regressions/gh_1037a_spec.rb +0 -31
- data/spec/nanoc/regressions/gh_1037b_spec.rb +0 -20
- data/spec/nanoc/regressions/gh_1040_spec.rb +0 -24
- data/spec/nanoc/regressions/gh_1045_spec.rb +0 -50
- data/spec/nanoc/regressions/gh_1047_spec.rb +0 -30
- data/spec/nanoc/regressions/gh_1064_spec.rb +0 -20
- data/spec/nanoc/regressions/gh_1067_spec.rb +0 -36
- data/spec/nanoc/regressions/gh_1082a_spec.rb +0 -20
- data/spec/nanoc/regressions/gh_1082b_spec.rb +0 -22
- data/spec/nanoc/regressions/gh_1082c_spec.rb +0 -21
- data/spec/nanoc/regressions/gh_1082d_spec.rb +0 -19
- data/spec/nanoc/regressions/gh_1093_spec.rb +0 -51
- data/spec/nanoc/regressions/gh_1094_spec.rb +0 -24
- data/spec/nanoc/regressions/gh_1097_spec.rb +0 -23
- data/spec/nanoc/regressions/gh_1100_spec.rb +0 -22
- data/spec/nanoc/regressions/gh_1102_spec.rb +0 -28
- data/spec/nanoc/regressions/gh_1107_spec.rb +0 -15
- data/spec/nanoc/regressions/gh_1130_spec.rb +0 -21
- data/spec/nanoc/regressions/gh_1134_spec.rb +0 -29
- data/spec/nanoc/regressions/gh_1145_spec.rb +0 -18
- data/spec/nanoc/regressions/gh_1171_spec.rb +0 -57
- data/spec/nanoc/regressions/gh_1185_spec.rb +0 -22
- data/spec/nanoc/regressions/gh_1216_spec.rb +0 -91
- data/spec/nanoc/regressions/gh_1248_spec.rb +0 -24
- data/spec/nanoc/regressions/gh_761_spec.rb +0 -25
- data/spec/nanoc/regressions/gh_767_spec.rb +0 -21
- data/spec/nanoc/regressions/gh_769_spec.rb +0 -32
- data/spec/nanoc/regressions/gh_776_spec.rb +0 -42
- data/spec/nanoc/regressions/gh_787_spec.rb +0 -21
- data/spec/nanoc/regressions/gh_795_spec.rb +0 -21
- data/spec/nanoc/regressions/gh_804_spec.rb +0 -28
- data/spec/nanoc/regressions/gh_807_spec.rb +0 -19
- data/spec/nanoc/regressions/gh_809_spec.rb +0 -19
- data/spec/nanoc/regressions/gh_813_spec.rb +0 -24
- data/spec/nanoc/regressions/gh_815_spec.rb +0 -20
- data/spec/nanoc/regressions/gh_828_spec.rb +0 -25
- data/spec/nanoc/regressions/gh_833_spec.rb +0 -16
- data/spec/nanoc/regressions/gh_841_spec.rb +0 -17
- data/spec/nanoc/regressions/gh_867_spec.rb +0 -17
- data/spec/nanoc/regressions/gh_882_spec.rb +0 -31
- data/spec/nanoc/regressions/gh_885_spec.rb +0 -32
- data/spec/nanoc/regressions/gh_891_spec.rb +0 -28
- data/spec/nanoc/regressions/gh_913_spec.rb +0 -26
- data/spec/nanoc/regressions/gh_924_spec.rb +0 -91
- data/spec/nanoc/regressions/gh_928_spec.rb +0 -7
- data/spec/nanoc/regressions/gh_937_spec.rb +0 -27
- data/spec/nanoc/regressions/gh_942_spec.rb +0 -23
- data/spec/nanoc/regressions/gh_947_spec.rb +0 -23
- data/spec/nanoc/regressions/gh_948_spec.rb +0 -18
- data/spec/nanoc/regressions/gh_951_spec.rb +0 -21
- data/spec/nanoc/regressions/gh_954_spec.rb +0 -35
- data/spec/nanoc/regressions/gh_970a_spec.rb +0 -19
- data/spec/nanoc/regressions/gh_970b_spec.rb +0 -52
- data/spec/nanoc/regressions/gh_974_spec.rb +0 -19
- data/spec/nanoc/regressions/gh_981_spec.rb +0 -23
- data/spec/nanoc/rule_dsl/action_sequence_calculator_spec.rb +0 -230
- data/spec/nanoc/rule_dsl/recording_executor_spec.rb +0 -145
- data/spec/nanoc/rule_dsl/rule_context_spec.rb +0 -251
- data/spec/nanoc/rule_dsl/rule_spec.rb +0 -111
- data/spec/nanoc/rule_dsl/rules_collection_spec.rb +0 -301
- data/spec/nanoc/spec_spec.rb +0 -70
- data/spec/nanoc/telemetry/counter_spec.rb +0 -20
- data/spec/nanoc/telemetry/labelled_counter_spec.rb +0 -94
- data/spec/nanoc/telemetry/labelled_summary_spec.rb +0 -78
- data/spec/nanoc/telemetry/stopwatch_spec.rb +0 -63
- data/spec/nanoc/telemetry/summary_spec.rb +0 -68
- data/spec/nanoc/telemetry/table_spec.rb +0 -22
- data/spec/nanoc/telemetry_spec.rb +0 -28
- data/spec/regression_filenames_spec.rb +0 -18
- data/spec/spec_helper.rb +0 -371
- data/test/base/test_compiler.rb +0 -389
- data/test/base/test_filter.rb +0 -73
- data/test/base/test_site.rb +0 -146
- data/test/checking/checks/test_css.rb +0 -66
- data/test/checking/checks/test_external_links.rb +0 -88
- data/test/checking/checks/test_html.rb +0 -47
- data/test/checking/checks/test_internal_links.rb +0 -118
- data/test/checking/checks/test_mixed_content.rb +0 -190
- data/test/checking/checks/test_stale.rb +0 -69
- data/test/checking/test_check.rb +0 -22
- data/test/checking/test_dsl.rb +0 -35
- data/test/checking/test_runner.rb +0 -45
- data/test/cli/commands/test_check.rb +0 -20
- data/test/cli/commands/test_compile.rb +0 -199
- data/test/cli/commands/test_create_site.rb +0 -126
- data/test/cli/commands/test_help.rb +0 -10
- data/test/cli/commands/test_prune.rb +0 -157
- data/test/cli/test_cleaning_stream.rb +0 -97
- data/test/cli/test_cli.rb +0 -195
- data/test/cli/test_error_handler.rb +0 -102
- data/test/cli/test_logger.rb +0 -7
- data/test/data_sources/test_filesystem.rb +0 -1033
- data/test/data_sources/test_filesystem_tools.rb +0 -146
- data/test/deploying/test_fog.rb +0 -117
- data/test/deploying/test_git.rb +0 -263
- data/test/deploying/test_rsync.rb +0 -94
- data/test/extra/core_ext/test_time.rb +0 -17
- data/test/extra/test_link_collector.rb +0 -110
- data/test/extra/test_piper.rb +0 -48
- data/test/filters/colorize_syntax/test_coderay.rb +0 -247
- data/test/filters/colorize_syntax/test_common.rb +0 -109
- data/test/filters/colorize_syntax/test_pygmentize.rb +0 -39
- data/test/filters/colorize_syntax/test_pygments.rb +0 -21
- data/test/filters/colorize_syntax/test_simon.rb +0 -24
- data/test/filters/test_asciidoc.rb +0 -16
- data/test/filters/test_bluecloth.rb +0 -16
- data/test/filters/test_coffeescript.rb +0 -16
- data/test/filters/test_erb.rb +0 -107
- data/test/filters/test_erubi.rb +0 -75
- data/test/filters/test_erubis.rb +0 -76
- data/test/filters/test_haml.rb +0 -94
- data/test/filters/test_handlebars.rb +0 -61
- data/test/filters/test_kramdown.rb +0 -56
- data/test/filters/test_markaby.rb +0 -16
- data/test/filters/test_maruku.rb +0 -16
- data/test/filters/test_mustache.rb +0 -43
- data/test/filters/test_pandoc.rb +0 -47
- data/test/filters/test_rainpress.rb +0 -27
- data/test/filters/test_rdiscount.rb +0 -30
- data/test/filters/test_rdoc.rb +0 -14
- data/test/filters/test_redcarpet.rb +0 -111
- data/test/filters/test_redcloth.rb +0 -31
- data/test/filters/test_relativize_paths.rb +0 -887
- data/test/filters/test_rubypants.rb +0 -16
- data/test/filters/test_sass.rb +0 -315
- data/test/filters/test_slim.rb +0 -59
- data/test/filters/test_typogruby.rb +0 -18
- data/test/filters/test_uglify_js.rb +0 -30
- data/test/filters/test_xsl.rb +0 -192
- data/test/filters/test_yui_compressor.rb +0 -42
- data/test/fixtures/vcr_cassettes/css_run_error.yml +0 -70
- data/test/fixtures/vcr_cassettes/css_run_ok.yml +0 -60
- data/test/fixtures/vcr_cassettes/css_run_parse_error.yml +0 -70
- data/test/fixtures/vcr_cassettes/html_run_error.yml +0 -56
- data/test/fixtures/vcr_cassettes/html_run_ok.yml +0 -58
- data/test/helper.rb +0 -255
- data/test/helpers/test_blogging.rb +0 -684
- data/test/helpers/test_capturing.rb +0 -184
- data/test/helpers/test_link_to.rb +0 -57
- data/test/helpers/test_xml_sitemap.rb +0 -246
- data/test/rule_dsl/test_action_provider.rb +0 -80
- data/test/rule_dsl/test_compiler_dsl.rb +0 -448
- data/test/rule_dsl/test_rules_collection.rb +0 -93
@@ -1,77 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Nanoc::Helpers::Filtering, helper: true do
|
4
|
-
describe '#filter' do
|
5
|
-
before do
|
6
|
-
ctx.create_item('some content', { title: 'Hello!' }, '/about.md')
|
7
|
-
ctx.create_rep(ctx.items['/about.md'], '/about.html')
|
8
|
-
|
9
|
-
ctx.item = ctx.items['/about.md']
|
10
|
-
ctx.item_rep = ctx.item.reps[:default]
|
11
|
-
end
|
12
|
-
|
13
|
-
let(:content) do
|
14
|
-
"A<% filter :erb do %><%%= 'X' %><% end %>B"
|
15
|
-
end
|
16
|
-
|
17
|
-
subject { ::ERB.new(content).result(helper.get_binding) }
|
18
|
-
|
19
|
-
context 'basic case' do
|
20
|
-
it { is_expected.to eql('AXB') }
|
21
|
-
|
22
|
-
it 'notifies' do
|
23
|
-
ns = Set.new
|
24
|
-
Nanoc::Int::NotificationCenter.on(:filtering_started) { ns << :filtering_started }
|
25
|
-
Nanoc::Int::NotificationCenter.on(:filtering_ended) { ns << :filtering_ended }
|
26
|
-
|
27
|
-
subject
|
28
|
-
|
29
|
-
expect(ns).to include(:filtering_started)
|
30
|
-
expect(ns).to include(:filtering_ended)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
context 'with assigns' do
|
35
|
-
let(:content) do
|
36
|
-
'A<% filter :erb do %><%%= @item[:title] %><% end %>B'
|
37
|
-
end
|
38
|
-
|
39
|
-
it { is_expected.to eql('AHello!B') }
|
40
|
-
end
|
41
|
-
|
42
|
-
context 'unknonwn filter name' do
|
43
|
-
let(:content) do
|
44
|
-
'A<% filter :donkey do %>X<% end %>B'
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'errors' do
|
48
|
-
expect { subject }.to raise_error(Nanoc::Int::Errors::UnknownFilter)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
context 'with locals' do
|
53
|
-
let(:content) do
|
54
|
-
"A<% filter :erb, locals: { sheep: 'baah' } do %><%%= @sheep %><% end %>B"
|
55
|
-
end
|
56
|
-
|
57
|
-
it { is_expected.to eql('AbaahB') }
|
58
|
-
end
|
59
|
-
|
60
|
-
context 'with Haml' do
|
61
|
-
let(:content) do
|
62
|
-
"%p Foo.\n" \
|
63
|
-
"- filter(:erb) do\n" \
|
64
|
-
" <%= 'abc' + 'xyz' %>\n" \
|
65
|
-
"%p Bar.\n"
|
66
|
-
end
|
67
|
-
|
68
|
-
before do
|
69
|
-
require 'haml'
|
70
|
-
end
|
71
|
-
|
72
|
-
subject { ::Haml::Engine.new(content).render(helper.get_binding) }
|
73
|
-
|
74
|
-
it { is_expected.to match(%r{^<p>Foo.</p>\s*abcxyz\s*<p>Bar.</p>$}) }
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Nanoc::Helpers::HTMLEscape, helper: true do
|
4
|
-
describe '#html_escape' do
|
5
|
-
subject { helper.html_escape(string) }
|
6
|
-
|
7
|
-
context 'given strings to escape' do
|
8
|
-
let(:string) { '< > & "' }
|
9
|
-
it { is_expected.to eql('< > & "') }
|
10
|
-
end
|
11
|
-
|
12
|
-
context 'given a block' do
|
13
|
-
let!(:_erbout) { +'moo' }
|
14
|
-
|
15
|
-
it 'adds escaped content to _erbout' do
|
16
|
-
helper.html_escape { _erbout << '<h1>Stuff!</h1>' }
|
17
|
-
expect(_erbout).to eql('moo<h1>Stuff!</h1>')
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
context 'given no argument nor block' do
|
22
|
-
subject { helper.html_escape }
|
23
|
-
|
24
|
-
it 'raises' do
|
25
|
-
expect { subject }.to raise_error(RuntimeError)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
context 'given argument that is not a string' do
|
30
|
-
let(:string) { 1 }
|
31
|
-
|
32
|
-
it 'raises an ArgumentError' do
|
33
|
-
expect { subject }.to raise_error(ArgumentError)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,320 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Nanoc::Helpers::LinkTo, helper: true do
|
4
|
-
describe '#link_to' do
|
5
|
-
subject { helper.link_to(text, target, attributes) }
|
6
|
-
|
7
|
-
let(:text) { 'Text' }
|
8
|
-
let(:target) { raise 'override me' }
|
9
|
-
let(:attributes) { {} }
|
10
|
-
|
11
|
-
context 'with string path' do
|
12
|
-
let(:target) { '/foo/' }
|
13
|
-
it { is_expected.to eql('<a href="/foo/">Text</a>') }
|
14
|
-
|
15
|
-
context 'with attributes' do
|
16
|
-
let(:attributes) { { title: 'Donkey' } }
|
17
|
-
it { is_expected.to eql('<a title="Donkey" href="/foo/">Text</a>') }
|
18
|
-
end
|
19
|
-
|
20
|
-
context 'special HTML characters in text' do
|
21
|
-
let(:text) { 'Foo & Bar' }
|
22
|
-
it { is_expected.to eql('<a href="/foo/">Foo & Bar</a>') }
|
23
|
-
# Not escaped!
|
24
|
-
end
|
25
|
-
|
26
|
-
context 'special HTML characters in URL' do
|
27
|
-
let(:target) { '/r&d/' }
|
28
|
-
it { is_expected.to eql('<a href="/r&d/">Text</a>') }
|
29
|
-
end
|
30
|
-
|
31
|
-
context 'special HTML characters in attribute' do
|
32
|
-
let(:attributes) { { title: 'Research & Development' } }
|
33
|
-
it { is_expected.to eql('<a title="Research & Development" href="/foo/">Text</a>') }
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
context 'with rep' do
|
38
|
-
before do
|
39
|
-
ctx.create_item('content', {}, '/target')
|
40
|
-
ctx.create_rep(ctx.items['/target'], '/target.html')
|
41
|
-
end
|
42
|
-
|
43
|
-
let(:target) { ctx.items['/target'].reps[:default] }
|
44
|
-
|
45
|
-
it { is_expected.to eql('<a href="/target.html">Text</a>') }
|
46
|
-
end
|
47
|
-
|
48
|
-
context 'with item' do
|
49
|
-
before do
|
50
|
-
ctx.create_item('content', {}, '/target')
|
51
|
-
end
|
52
|
-
|
53
|
-
let(:target) { ctx.items['/target'] }
|
54
|
-
|
55
|
-
before do
|
56
|
-
ctx.create_rep(target, '/target.html')
|
57
|
-
end
|
58
|
-
|
59
|
-
it { is_expected.to eql('<a href="/target.html">Text</a>') }
|
60
|
-
end
|
61
|
-
|
62
|
-
context 'with nil' do
|
63
|
-
let(:target) { nil }
|
64
|
-
|
65
|
-
it 'raises' do
|
66
|
-
expect { subject }.to raise_error(ArgumentError)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
context 'with something else' do
|
71
|
-
let(:target) { :donkey }
|
72
|
-
|
73
|
-
it 'raises' do
|
74
|
-
expect { subject }.to raise_error(ArgumentError)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
context 'with nil path' do
|
79
|
-
before do
|
80
|
-
ctx.create_item('content', {}, '/target')
|
81
|
-
ctx.create_rep(ctx.items['/target'], nil)
|
82
|
-
end
|
83
|
-
|
84
|
-
let(:target) { ctx.items['/target'].reps[:default] }
|
85
|
-
|
86
|
-
it 'raises' do
|
87
|
-
expect { subject }.to raise_error(RuntimeError)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
describe '#link_to_unless_current' do
|
93
|
-
subject { helper.link_to_unless_current(text, target, attributes) }
|
94
|
-
|
95
|
-
let(:text) { 'Text' }
|
96
|
-
let(:target) { raise 'override me' }
|
97
|
-
let(:attributes) { {} }
|
98
|
-
|
99
|
-
context 'with string path' do
|
100
|
-
let(:target) { '/target.html' }
|
101
|
-
|
102
|
-
context 'current' do
|
103
|
-
before do
|
104
|
-
ctx.create_item('content', {}, '/target.md')
|
105
|
-
ctx.create_rep(ctx.items['/target.md'], '/target.html')
|
106
|
-
|
107
|
-
ctx.item = ctx.items['/target.md']
|
108
|
-
ctx.item_rep = ctx.item.reps[:default]
|
109
|
-
end
|
110
|
-
|
111
|
-
it { is_expected.to eql('<span class="active">Text</span>') }
|
112
|
-
end
|
113
|
-
|
114
|
-
context 'no item rep present' do
|
115
|
-
it { is_expected.to eql('<a href="/target.html">Text</a>') }
|
116
|
-
end
|
117
|
-
|
118
|
-
context 'item rep present, but not current' do
|
119
|
-
before do
|
120
|
-
ctx.create_item('content', {}, '/other.md')
|
121
|
-
ctx.create_rep(ctx.items['/other.md'], '/other.html')
|
122
|
-
|
123
|
-
ctx.item = ctx.items['/other.md']
|
124
|
-
ctx.item_rep = ctx.item.reps[:default]
|
125
|
-
end
|
126
|
-
|
127
|
-
it { is_expected.to eql('<a href="/target.html">Text</a>') }
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
context 'with rep' do
|
132
|
-
before do
|
133
|
-
ctx.create_item('content', {}, '/target.md')
|
134
|
-
ctx.create_rep(ctx.items['/target.md'], '/target.html')
|
135
|
-
|
136
|
-
ctx.create_item('content', {}, '/other.md')
|
137
|
-
ctx.create_rep(ctx.items['/other.md'], '/other.html')
|
138
|
-
|
139
|
-
ctx.item = ctx.items['/target.md']
|
140
|
-
ctx.item_rep = ctx.item.reps[:default]
|
141
|
-
end
|
142
|
-
|
143
|
-
let(:some_item) { ctx.items['/other.md'] }
|
144
|
-
let(:some_item_rep) { some_item.reps[:default] }
|
145
|
-
|
146
|
-
context 'current' do
|
147
|
-
let(:target) { ctx.item_rep }
|
148
|
-
it { is_expected.to eql('<span class="active">Text</span>') }
|
149
|
-
end
|
150
|
-
|
151
|
-
context 'no item rep present' do
|
152
|
-
let(:target) { some_item_rep }
|
153
|
-
|
154
|
-
before do
|
155
|
-
ctx.item = nil
|
156
|
-
ctx.item_rep = nil
|
157
|
-
end
|
158
|
-
|
159
|
-
it { is_expected.to eql('<a href="/other.html">Text</a>') }
|
160
|
-
end
|
161
|
-
|
162
|
-
context 'item rep present, but not current' do
|
163
|
-
let(:target) { some_item_rep }
|
164
|
-
it { is_expected.to eql('<a href="/other.html">Text</a>') }
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
context 'with item' do
|
169
|
-
before do
|
170
|
-
ctx.create_item('content', {}, '/target.md')
|
171
|
-
ctx.create_rep(ctx.items['/target.md'], '/target.html')
|
172
|
-
|
173
|
-
ctx.create_item('content', {}, '/other.md')
|
174
|
-
ctx.create_rep(ctx.items['/other.md'], '/other.html')
|
175
|
-
|
176
|
-
ctx.item = ctx.items['/target.md']
|
177
|
-
ctx.item_rep = ctx.item.reps[:default]
|
178
|
-
end
|
179
|
-
|
180
|
-
let(:some_item) { ctx.items['/other.md'] }
|
181
|
-
let(:some_item_rep) { some_item.reps[:default] }
|
182
|
-
|
183
|
-
context 'current' do
|
184
|
-
let(:target) { ctx.item }
|
185
|
-
it { is_expected.to eql('<span class="active">Text</span>') }
|
186
|
-
end
|
187
|
-
|
188
|
-
context 'no item rep present' do
|
189
|
-
let(:target) { some_item }
|
190
|
-
|
191
|
-
before do
|
192
|
-
ctx.item = nil
|
193
|
-
ctx.item_rep = nil
|
194
|
-
end
|
195
|
-
|
196
|
-
it { is_expected.to eql('<a href="/other.html">Text</a>') }
|
197
|
-
end
|
198
|
-
|
199
|
-
context 'item rep present, but not current' do
|
200
|
-
let(:target) { some_item }
|
201
|
-
it { is_expected.to eql('<a href="/other.html">Text</a>') }
|
202
|
-
end
|
203
|
-
end
|
204
|
-
end
|
205
|
-
|
206
|
-
describe '#relative_path_to' do
|
207
|
-
subject { helper.relative_path_to(target) }
|
208
|
-
|
209
|
-
before do
|
210
|
-
ctx.create_item('content', {}, '/foo/self.md')
|
211
|
-
ctx.create_rep(ctx.items['/foo/self.md'], self_path)
|
212
|
-
|
213
|
-
ctx.item = ctx.items['/foo/self.md']
|
214
|
-
ctx.item_rep = ctx.item.reps[:default]
|
215
|
-
end
|
216
|
-
|
217
|
-
context 'current item rep has non-nil path' do
|
218
|
-
let(:self_path) { '/foo/self.html' }
|
219
|
-
|
220
|
-
context 'to string path' do
|
221
|
-
context 'to relative path' do
|
222
|
-
let(:target) { 'bar/target.html' }
|
223
|
-
|
224
|
-
it 'errors' do
|
225
|
-
# TODO: Might make sense to allow this case (and return the path itself)
|
226
|
-
expect { subject }.to raise_error(ArgumentError)
|
227
|
-
end
|
228
|
-
end
|
229
|
-
|
230
|
-
context 'to path without trailing slash' do
|
231
|
-
let(:target) { '/bar/target.html' }
|
232
|
-
it { is_expected.to eql('../bar/target.html') }
|
233
|
-
end
|
234
|
-
|
235
|
-
context 'to path with trailing slash' do
|
236
|
-
let(:target) { '/bar/target/' }
|
237
|
-
it { is_expected.to eql('../bar/target/') }
|
238
|
-
end
|
239
|
-
|
240
|
-
context 'to Windows/UNC path (forward slashes)' do
|
241
|
-
let(:target) { '//foo' }
|
242
|
-
it { is_expected.to eql('//foo') }
|
243
|
-
end
|
244
|
-
|
245
|
-
context 'to Windows/UNC path (backslashes)' do
|
246
|
-
let(:target) { '\\\\foo' }
|
247
|
-
it { is_expected.to eql('\\\\foo') }
|
248
|
-
end
|
249
|
-
end
|
250
|
-
|
251
|
-
context 'to rep' do
|
252
|
-
before do
|
253
|
-
ctx.create_rep(ctx.item, '/bar/target.html', :special)
|
254
|
-
end
|
255
|
-
|
256
|
-
let(:target) { ctx.item.reps[:special] }
|
257
|
-
|
258
|
-
it { is_expected.to eql('../bar/target.html') }
|
259
|
-
|
260
|
-
context 'to self' do
|
261
|
-
let(:target) { ctx.item_rep }
|
262
|
-
|
263
|
-
context 'self is a filename' do
|
264
|
-
it { is_expected.to eql('self.html') }
|
265
|
-
end
|
266
|
-
|
267
|
-
context 'self is a directory' do
|
268
|
-
let(:self_path) { '/foo/self/' }
|
269
|
-
it { is_expected.to eql('./') }
|
270
|
-
end
|
271
|
-
end
|
272
|
-
end
|
273
|
-
|
274
|
-
context 'to item' do
|
275
|
-
let(:target) { ctx.items['/bar/target.md'] }
|
276
|
-
|
277
|
-
before do
|
278
|
-
ctx.create_item('content', {}, '/bar/target.md')
|
279
|
-
ctx.create_rep(ctx.items['/bar/target.md'], '/bar/target.html')
|
280
|
-
end
|
281
|
-
|
282
|
-
it { is_expected.to eql('../bar/target.html') }
|
283
|
-
|
284
|
-
context 'to self' do
|
285
|
-
let(:target) { ctx.item }
|
286
|
-
|
287
|
-
context 'self is a filename' do
|
288
|
-
it { is_expected.to eql('self.html') }
|
289
|
-
end
|
290
|
-
|
291
|
-
context 'self is a directory' do
|
292
|
-
let(:self_path) { '/foo/self/' }
|
293
|
-
it { is_expected.to eql('./') }
|
294
|
-
end
|
295
|
-
end
|
296
|
-
end
|
297
|
-
|
298
|
-
context 'to nil path' do
|
299
|
-
let(:target) { ctx.item.reps[:special] }
|
300
|
-
|
301
|
-
before do
|
302
|
-
ctx.create_rep(ctx.item, nil, :special)
|
303
|
-
end
|
304
|
-
|
305
|
-
it 'raises' do
|
306
|
-
expect { subject }.to raise_error(RuntimeError)
|
307
|
-
end
|
308
|
-
end
|
309
|
-
end
|
310
|
-
|
311
|
-
context 'current item rep has nil path' do
|
312
|
-
let(:self_path) { nil }
|
313
|
-
let(:target) { '/bar/target.html' }
|
314
|
-
|
315
|
-
it 'errors' do
|
316
|
-
expect { subject }.to raise_error(RuntimeError)
|
317
|
-
end
|
318
|
-
end
|
319
|
-
end
|
320
|
-
end
|
@@ -1,144 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Nanoc::Helpers::Rendering, helper: true do
|
4
|
-
describe '#render' do
|
5
|
-
subject { helper.instance_eval { render('/partial.erb') } }
|
6
|
-
|
7
|
-
let(:action_sequence_for_layout) do
|
8
|
-
[Nanoc::Int::ProcessingActions::Filter.new(:erb, {})]
|
9
|
-
end
|
10
|
-
|
11
|
-
let(:layout_view) { ctx.layouts[layout_identifier] }
|
12
|
-
let(:layout) { layout_view.unwrap }
|
13
|
-
|
14
|
-
before do
|
15
|
-
ctx.create_layout(layout_content, {}, layout_identifier)
|
16
|
-
ctx.update_action_sequence(layout, action_sequence_for_layout)
|
17
|
-
end
|
18
|
-
|
19
|
-
context 'legacy identifier' do
|
20
|
-
let(:layout_identifier) { Nanoc::Identifier.new('/partial/', type: :legacy) }
|
21
|
-
|
22
|
-
context 'cleaned identifier' do
|
23
|
-
subject { helper.instance_eval { render('/partial/') } }
|
24
|
-
|
25
|
-
context 'layout without instructions' do
|
26
|
-
let(:layout_content) { 'blah' }
|
27
|
-
|
28
|
-
it { is_expected.to eql('blah') }
|
29
|
-
|
30
|
-
it 'tracks proper dependencies' do
|
31
|
-
expect(ctx.dependency_tracker).to receive(:enter)
|
32
|
-
.with(an_instance_of(Nanoc::Int::LayoutCollection), raw_content: ['/partial/'], attributes: false, compiled_content: false, path: false)
|
33
|
-
.ordered
|
34
|
-
expect(ctx.dependency_tracker).to receive(:enter)
|
35
|
-
.with(layout, raw_content: true, attributes: false, compiled_content: false, path: false)
|
36
|
-
.ordered
|
37
|
-
|
38
|
-
subject
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
context 'layout with instructions' do
|
43
|
-
let(:layout_content) { 'blah <%= @layout.identifier %>' }
|
44
|
-
it { is_expected.to eql('blah /partial/') }
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
context 'non-cleaned identifier' do
|
49
|
-
subject { helper.instance_eval { render('/partial') } }
|
50
|
-
|
51
|
-
context 'layout without instructions' do
|
52
|
-
let(:layout_content) { 'blah' }
|
53
|
-
it { is_expected.to eql('blah') }
|
54
|
-
end
|
55
|
-
|
56
|
-
context 'layout with instructions' do
|
57
|
-
let(:layout_content) { 'blah <%= @layout.identifier %>' }
|
58
|
-
it { is_expected.to eql('blah /partial/') }
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
context 'full-style identifier' do
|
64
|
-
let(:layout_identifier) { Nanoc::Identifier.new('/partial.erb') }
|
65
|
-
|
66
|
-
context 'layout without instructions' do
|
67
|
-
let(:layout_content) { 'blah' }
|
68
|
-
it { is_expected.to eql('blah') }
|
69
|
-
end
|
70
|
-
|
71
|
-
context 'layout with instructions' do
|
72
|
-
let(:layout_content) { 'blah <%= @layout.identifier %>' }
|
73
|
-
it { is_expected.to eql('blah /partial.erb') }
|
74
|
-
end
|
75
|
-
|
76
|
-
context 'printing wrapped layout class' do
|
77
|
-
let(:layout_content) { 'blah <%= @layout.class %>' }
|
78
|
-
it { is_expected.to eql('blah Nanoc::LayoutView') }
|
79
|
-
end
|
80
|
-
|
81
|
-
context 'printing unwrapped layout class' do
|
82
|
-
let(:layout_content) { 'blah <%= @layout.unwrap.class %>' }
|
83
|
-
it { is_expected.to eql('blah Nanoc::Int::Layout') }
|
84
|
-
end
|
85
|
-
|
86
|
-
context 'unknown layout' do
|
87
|
-
subject { helper.instance_eval { render('/unknown.erb') } }
|
88
|
-
|
89
|
-
let(:layout_content) { 'blah' }
|
90
|
-
|
91
|
-
it 'raises' do
|
92
|
-
expect { subject }.to raise_error(Nanoc::Int::Errors::UnknownLayout)
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
context 'layout with unknown filter' do
|
97
|
-
let(:action_sequence_for_layout) do
|
98
|
-
[Nanoc::Int::ProcessingActions::Filter.new(:donkey, {})]
|
99
|
-
end
|
100
|
-
|
101
|
-
let(:layout_content) { 'blah' }
|
102
|
-
|
103
|
-
it 'raises' do
|
104
|
-
expect { subject }.to raise_error(Nanoc::Int::Errors::UnknownFilter)
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
context 'layout without filter' do
|
109
|
-
let(:action_sequence_for_layout) do
|
110
|
-
[Nanoc::Int::ProcessingActions::Filter.new(nil, {})]
|
111
|
-
end
|
112
|
-
|
113
|
-
let(:layout_content) { 'blah' }
|
114
|
-
|
115
|
-
it 'raises' do
|
116
|
-
expect { subject }.to raise_error(Nanoc::Int::Errors::CannotDetermineFilter)
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
context 'with block' do
|
121
|
-
subject do
|
122
|
-
helper.instance_eval do
|
123
|
-
render('/partial.erb') { _erbout << 'extra content' }
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
before do
|
128
|
-
ctx.erbout << '[erbout-before]'
|
129
|
-
end
|
130
|
-
|
131
|
-
let(:layout_content) { '[partial-before]<%= yield %>[partial-after]' }
|
132
|
-
|
133
|
-
it 'returns an empty string' do
|
134
|
-
expect(subject).to eql('')
|
135
|
-
end
|
136
|
-
|
137
|
-
it 'modifies erbout' do
|
138
|
-
subject
|
139
|
-
expect(ctx.erbout).to eql('[erbout-before][partial-before]extra content[partial-after]')
|
140
|
-
end
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|