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,78 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Nanoc::Telemetry::LabelledSummary do
|
4
|
-
subject(:summary) { described_class.new }
|
5
|
-
|
6
|
-
describe '#empty?' do
|
7
|
-
subject { summary.empty? }
|
8
|
-
|
9
|
-
context 'empty summary' do
|
10
|
-
it { is_expected.to be }
|
11
|
-
end
|
12
|
-
|
13
|
-
context 'some observations' do
|
14
|
-
before do
|
15
|
-
summary.observe(7.2, :erb)
|
16
|
-
summary.observe(5.3, :erb)
|
17
|
-
summary.observe(3.0, :haml)
|
18
|
-
end
|
19
|
-
|
20
|
-
it { is_expected.not_to be }
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe '#get' do
|
25
|
-
subject { summary.get(:erb) }
|
26
|
-
|
27
|
-
context 'empty summary' do
|
28
|
-
its(:count) { is_expected.to eq(0) }
|
29
|
-
end
|
30
|
-
|
31
|
-
context 'one observation with that label' do
|
32
|
-
before { summary.observe(0.1, :erb) }
|
33
|
-
its(:count) { is_expected.to eq(1) }
|
34
|
-
end
|
35
|
-
|
36
|
-
context 'one observation with a different label' do
|
37
|
-
before { summary.observe(0.1, :haml) }
|
38
|
-
its(:count) { is_expected.to eq(0) }
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe '#map' do
|
43
|
-
before do
|
44
|
-
subject.observe(2.1, :erb)
|
45
|
-
subject.observe(4.1, :erb)
|
46
|
-
subject.observe(5.3, :haml)
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'yields label and summary' do
|
50
|
-
res = subject.map { |label, summary| [label, summary.avg.round(3)] }
|
51
|
-
expect(res).to eql([[:erb, 3.1], [:haml, 5.3]])
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
describe '#quantile' do
|
56
|
-
before do
|
57
|
-
subject.observe(2.1, :erb)
|
58
|
-
subject.observe(4.1, :erb)
|
59
|
-
subject.observe(5.3, :haml)
|
60
|
-
end
|
61
|
-
|
62
|
-
it 'has proper quantiles for :erb' do
|
63
|
-
expect(subject.quantile(0.00, :erb)).to be_within(0.000001).of(2.1)
|
64
|
-
expect(subject.quantile(0.25, :erb)).to be_within(0.000001).of(2.6)
|
65
|
-
expect(subject.quantile(0.50, :erb)).to be_within(0.000001).of(3.1)
|
66
|
-
expect(subject.quantile(0.90, :erb)).to be_within(0.000001).of(3.9)
|
67
|
-
expect(subject.quantile(0.99, :erb)).to be_within(0.000001).of(4.08)
|
68
|
-
end
|
69
|
-
|
70
|
-
it 'has proper quantiles for :erb' do
|
71
|
-
expect(subject.quantile(0.00, :haml)).to be_within(0.000001).of(5.3)
|
72
|
-
expect(subject.quantile(0.25, :haml)).to be_within(0.000001).of(5.3)
|
73
|
-
expect(subject.quantile(0.50, :haml)).to be_within(0.000001).of(5.3)
|
74
|
-
expect(subject.quantile(0.90, :haml)).to be_within(0.000001).of(5.3)
|
75
|
-
expect(subject.quantile(0.99, :haml)).to be_within(0.000001).of(5.3)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Nanoc::Telemetry::Stopwatch do
|
4
|
-
subject(:stopwatch) { described_class.new }
|
5
|
-
|
6
|
-
after { Timecop.return }
|
7
|
-
|
8
|
-
it 'is zero by default' do
|
9
|
-
expect(stopwatch.duration).to eq(0.0)
|
10
|
-
end
|
11
|
-
|
12
|
-
# TODO: if running, raise error when asking for #duration
|
13
|
-
|
14
|
-
it 'records correct duration after start+stop' do
|
15
|
-
Timecop.freeze(Time.local(2008, 9, 1, 10, 5, 0))
|
16
|
-
stopwatch.start
|
17
|
-
|
18
|
-
Timecop.freeze(Time.local(2008, 9, 1, 10, 5, 1))
|
19
|
-
stopwatch.stop
|
20
|
-
|
21
|
-
expect(stopwatch.duration).to eq(1.0)
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'records correct duration after start+stop+start+stop' do
|
25
|
-
Timecop.freeze(Time.local(2008, 9, 1, 10, 5, 0))
|
26
|
-
stopwatch.start
|
27
|
-
|
28
|
-
Timecop.freeze(Time.local(2008, 9, 1, 10, 5, 1))
|
29
|
-
stopwatch.stop
|
30
|
-
|
31
|
-
Timecop.freeze(Time.local(2008, 9, 1, 10, 5, 3))
|
32
|
-
stopwatch.start
|
33
|
-
|
34
|
-
Timecop.freeze(Time.local(2008, 9, 1, 10, 5, 6))
|
35
|
-
stopwatch.stop
|
36
|
-
|
37
|
-
expect(stopwatch.duration).to eq(1.0 + 3.0)
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'errors when stopping when not started' do
|
41
|
-
expect { stopwatch.stop }.to raise_error(Nanoc::Telemetry::Stopwatch::NotRunningError)
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'errors when starting when already started' do
|
45
|
-
stopwatch.start
|
46
|
-
expect { stopwatch.start }.to raise_error(Nanoc::Telemetry::Stopwatch::AlreadyRunningError)
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'reports running status' do
|
50
|
-
expect(stopwatch).not_to be_running
|
51
|
-
expect(stopwatch).to be_stopped
|
52
|
-
|
53
|
-
stopwatch.start
|
54
|
-
|
55
|
-
expect(stopwatch).to be_running
|
56
|
-
expect(stopwatch).not_to be_stopped
|
57
|
-
|
58
|
-
stopwatch.stop
|
59
|
-
|
60
|
-
expect(stopwatch).not_to be_running
|
61
|
-
expect(stopwatch).to be_stopped
|
62
|
-
end
|
63
|
-
end
|
@@ -1,68 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Nanoc::Telemetry::Summary do
|
4
|
-
subject(:summary) { described_class.new }
|
5
|
-
|
6
|
-
context 'no observations' do
|
7
|
-
it 'errors on #min' do
|
8
|
-
expect { subject.min }
|
9
|
-
.to raise_error(Nanoc::Telemetry::Summary::EmptySummaryError)
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'errors on #max' do
|
13
|
-
expect { subject.max }
|
14
|
-
.to raise_error(Nanoc::Telemetry::Summary::EmptySummaryError)
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'errors on #avg' do
|
18
|
-
expect { subject.avg }
|
19
|
-
.to raise_error(Nanoc::Telemetry::Summary::EmptySummaryError)
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'errors on #sum' do
|
23
|
-
expect { subject.sum }
|
24
|
-
.to raise_error(Nanoc::Telemetry::Summary::EmptySummaryError)
|
25
|
-
end
|
26
|
-
|
27
|
-
its(:count) { is_expected.to eq(0) }
|
28
|
-
end
|
29
|
-
|
30
|
-
context 'one observation' do
|
31
|
-
before { subject.observe(2.1) }
|
32
|
-
|
33
|
-
its(:count) { is_expected.to eq(1) }
|
34
|
-
its(:sum) { is_expected.to eq(2.1) }
|
35
|
-
its(:avg) { is_expected.to eq(2.1) }
|
36
|
-
its(:min) { is_expected.to eq(2.1) }
|
37
|
-
its(:max) { is_expected.to eq(2.1) }
|
38
|
-
|
39
|
-
it 'has proper quantiles' do
|
40
|
-
expect(subject.quantile(0.00)).to eq(2.1)
|
41
|
-
expect(subject.quantile(0.25)).to eq(2.1)
|
42
|
-
expect(subject.quantile(0.50)).to eq(2.1)
|
43
|
-
expect(subject.quantile(0.90)).to eq(2.1)
|
44
|
-
expect(subject.quantile(0.99)).to eq(2.1)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
context 'two observations' do
|
49
|
-
before do
|
50
|
-
subject.observe(2.1)
|
51
|
-
subject.observe(4.1)
|
52
|
-
end
|
53
|
-
|
54
|
-
its(:count) { is_expected.to be_within(0.000001).of(2) }
|
55
|
-
its(:sum) { is_expected.to be_within(0.000001).of(6.2) }
|
56
|
-
its(:avg) { is_expected.to be_within(0.000001).of(3.1) }
|
57
|
-
its(:min) { is_expected.to be_within(0.000001).of(2.1) }
|
58
|
-
its(:max) { is_expected.to be_within(0.000001).of(4.1) }
|
59
|
-
|
60
|
-
it 'has proper quantiles' do
|
61
|
-
expect(subject.quantile(0.00)).to be_within(0.000001).of(2.1)
|
62
|
-
expect(subject.quantile(0.25)).to be_within(0.000001).of(2.6)
|
63
|
-
expect(subject.quantile(0.50)).to be_within(0.000001).of(3.1)
|
64
|
-
expect(subject.quantile(0.90)).to be_within(0.000001).of(3.9)
|
65
|
-
expect(subject.quantile(0.99)).to be_within(0.000001).of(4.08)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Nanoc::Telemetry::Table do
|
4
|
-
let(:table) { described_class.new(rows) }
|
5
|
-
|
6
|
-
let(:rows) do
|
7
|
-
[
|
8
|
-
%w[name awesomeness],
|
9
|
-
%w[denis high],
|
10
|
-
%w[REDACTED low],
|
11
|
-
]
|
12
|
-
end
|
13
|
-
|
14
|
-
example do
|
15
|
-
expect(table.to_s).to eq(<<~EOS.rstrip)
|
16
|
-
name │ awesomeness
|
17
|
-
─────────┼────────────
|
18
|
-
denis │ high
|
19
|
-
REDACTED │ low
|
20
|
-
EOS
|
21
|
-
end
|
22
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Nanoc::Telemetry do
|
4
|
-
subject { described_class.new }
|
5
|
-
|
6
|
-
example do
|
7
|
-
expect(subject.counter(:filters).values).to eq({})
|
8
|
-
expect(subject.counter(:filters).get(:erb).value).to eq(0)
|
9
|
-
expect(subject.counter(:filters).value(:erb)).to eq(0)
|
10
|
-
|
11
|
-
subject.counter(:filters).increment(:erb)
|
12
|
-
expect(subject.counter(:filters).values).to eq(erb: 1)
|
13
|
-
expect(subject.counter(:filters).get(:erb).value).to eq(1)
|
14
|
-
expect(subject.counter(:filters).value(:erb)).to eq(1)
|
15
|
-
end
|
16
|
-
|
17
|
-
example do
|
18
|
-
subject.summary(:filters).observe(0.1, :erb)
|
19
|
-
expect(subject.summary(:filters).quantile(0.0, :erb)).to be_within(0.00001).of(0.1)
|
20
|
-
expect(subject.summary(:filters).quantile(0.5, :erb)).to be_within(0.00001).of(0.1)
|
21
|
-
expect(subject.summary(:filters).quantile(1.0, :erb)).to be_within(0.00001).of(0.1)
|
22
|
-
|
23
|
-
subject.summary(:filters).observe(1.1, :erb)
|
24
|
-
expect(subject.summary(:filters).quantile(0.0, :erb)).to be_within(0.00001).of(0.1)
|
25
|
-
expect(subject.summary(:filters).quantile(0.5, :erb)).to be_within(0.00001).of(0.6)
|
26
|
-
expect(subject.summary(:filters).quantile(1.0, :erb)).to be_within(0.00001).of(1.1)
|
27
|
-
end
|
28
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe 'regression tests', chdir: false do
|
4
|
-
let(:regression_test_filenames) do
|
5
|
-
Dir['spec/nanoc/regressions/*']
|
6
|
-
end
|
7
|
-
|
8
|
-
let(:regression_test_numbers) do
|
9
|
-
regression_test_filenames
|
10
|
-
.map { |fn| File.readlines(fn).find { |l| l =~ /^describe/ }.match(/GH-(\d+)/)[1] }
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'should have the proper filenames' do
|
14
|
-
regression_test_filenames.zip(regression_test_numbers) do |fn, num|
|
15
|
-
expect(fn).to match(/gh_#{num}[a-z]*_spec/), "#{fn} has the wrong name in its #define block"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,371 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'simplecov'
|
4
|
-
SimpleCov.start
|
5
|
-
|
6
|
-
require 'codecov'
|
7
|
-
SimpleCov.formatter = SimpleCov::Formatter::Codecov
|
8
|
-
|
9
|
-
require 'nanoc'
|
10
|
-
require 'nanoc/cli'
|
11
|
-
require 'nanoc/spec'
|
12
|
-
|
13
|
-
require 'ddbuffer'
|
14
|
-
require 'timecop'
|
15
|
-
require 'rspec/its'
|
16
|
-
require 'fuubar'
|
17
|
-
require 'yard'
|
18
|
-
|
19
|
-
Nanoc::CLI.setup
|
20
|
-
|
21
|
-
RSpec.configure do |c|
|
22
|
-
c.include(Nanoc::Spec::Helper)
|
23
|
-
|
24
|
-
c.include(Nanoc::Spec::HelperHelper, helper: true)
|
25
|
-
|
26
|
-
c.fuubar_progress_bar_options = {
|
27
|
-
format: '%c/%C |<%b>%i| %p%%',
|
28
|
-
}
|
29
|
-
|
30
|
-
c.around(:each) do |example|
|
31
|
-
Nanoc::CLI::ErrorHandler.disable
|
32
|
-
example.run
|
33
|
-
Nanoc::CLI::ErrorHandler.enable
|
34
|
-
end
|
35
|
-
|
36
|
-
c.around(:each) do |example|
|
37
|
-
Dir.mktmpdir('nanoc-test') do |dir|
|
38
|
-
chdir(dir) { example.run }
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
c.around(:each, chdir: false) do |example|
|
43
|
-
Dir.chdir(__dir__ + '/..')
|
44
|
-
example.run
|
45
|
-
end
|
46
|
-
|
47
|
-
c.before(:each) do
|
48
|
-
Nanoc::Int::NotificationCenter.reset
|
49
|
-
end
|
50
|
-
|
51
|
-
c.around(:each, stdio: true) do |example|
|
52
|
-
orig_stdout = $stdout
|
53
|
-
orig_stderr = $stderr
|
54
|
-
|
55
|
-
unless ENV['QUIET'] == 'false'
|
56
|
-
$stdout = StringIO.new
|
57
|
-
$stderr = StringIO.new
|
58
|
-
end
|
59
|
-
|
60
|
-
example.run
|
61
|
-
|
62
|
-
$stdout = orig_stdout
|
63
|
-
$stderr = orig_stderr
|
64
|
-
end
|
65
|
-
|
66
|
-
c.before(:each, site: true) do
|
67
|
-
FileUtils.mkdir_p('content')
|
68
|
-
FileUtils.mkdir_p('layouts')
|
69
|
-
FileUtils.mkdir_p('lib')
|
70
|
-
FileUtils.mkdir_p('output')
|
71
|
-
|
72
|
-
File.write('nanoc.yaml', '{}')
|
73
|
-
|
74
|
-
File.write('Rules', 'passthrough "/**/*"')
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
RSpec::Matchers.define_negated_matcher :not_match, :match
|
79
|
-
|
80
|
-
RSpec::Matchers.define :raise_frozen_error do |_expected|
|
81
|
-
match do |actual|
|
82
|
-
begin
|
83
|
-
actual.call
|
84
|
-
false
|
85
|
-
rescue => e
|
86
|
-
if e.is_a?(RuntimeError) || e.is_a?(TypeError)
|
87
|
-
e.message =~ /(^can't modify frozen |^unable to modify frozen object$)/
|
88
|
-
else
|
89
|
-
false
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
supports_block_expectations
|
95
|
-
|
96
|
-
failure_message do |_actual|
|
97
|
-
'expected that proc would raise a frozen error'
|
98
|
-
end
|
99
|
-
|
100
|
-
failure_message_when_negated do |_actual|
|
101
|
-
'expected that proc would not raise a frozen error'
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
RSpec::Matchers.define :be_humanly_sorted do
|
106
|
-
match do |actual|
|
107
|
-
actual == sort(actual)
|
108
|
-
end
|
109
|
-
|
110
|
-
description do
|
111
|
-
'be humanly sorted'
|
112
|
-
end
|
113
|
-
|
114
|
-
failure_message do |actual|
|
115
|
-
expected_order = []
|
116
|
-
actual.zip(sort(actual)).each do |a, b|
|
117
|
-
if a != b
|
118
|
-
expected_order << b
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
"expected collection to be sorted (incorrect order: #{expected_order.join(' < ')})"
|
123
|
-
end
|
124
|
-
|
125
|
-
def sort(x)
|
126
|
-
x.sort_by { |n| n.dup.unicode_normalize(:nfd).encode('ASCII', fallback: ->(_) { '' }).downcase }
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
RSpec::Matchers.define :finish_in_under do |expected|
|
131
|
-
supports_block_expectations
|
132
|
-
|
133
|
-
match do |actual|
|
134
|
-
before = Time.now
|
135
|
-
actual.call
|
136
|
-
after = Time.now
|
137
|
-
@actual_duration = after - before
|
138
|
-
@actual_duration < expected
|
139
|
-
end
|
140
|
-
|
141
|
-
chain :seconds do
|
142
|
-
end
|
143
|
-
|
144
|
-
failure_message do |_actual|
|
145
|
-
"expected that proc would finish in under #{expected}s, but took #{format '%0.1fs', @actual_duration}"
|
146
|
-
end
|
147
|
-
|
148
|
-
failure_message_when_negated do |_actual|
|
149
|
-
"expected that proc would not finish in under #{expected}s, but took #{format '%0.1fs', @actual_duration}"
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
RSpec::Matchers.define :yield_from_fiber do |expected|
|
154
|
-
supports_block_expectations
|
155
|
-
|
156
|
-
include RSpec::Matchers::Composable
|
157
|
-
|
158
|
-
match do |actual|
|
159
|
-
@res = Fiber.new { actual.call }.resume
|
160
|
-
values_match?(expected, @res)
|
161
|
-
end
|
162
|
-
|
163
|
-
description do
|
164
|
-
"yield #{expected.inspect} from fiber"
|
165
|
-
end
|
166
|
-
|
167
|
-
failure_message do |_actual|
|
168
|
-
"expected that proc would yield #{expected.inspect} from fiber, but was #{@res.inspect}"
|
169
|
-
end
|
170
|
-
|
171
|
-
failure_message_when_negated do |_actual|
|
172
|
-
"expected that proc would not yield #{expected.inspect} from fiber, but was #{@res.inspect}"
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
RSpec::Matchers.define :raise_wrapped_error do |expected|
|
177
|
-
supports_block_expectations
|
178
|
-
|
179
|
-
include RSpec::Matchers::Composable
|
180
|
-
|
181
|
-
match do |actual|
|
182
|
-
begin
|
183
|
-
actual.call
|
184
|
-
rescue Nanoc::Int::Errors::CompilationError => e
|
185
|
-
values_match?(expected, e.unwrap)
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
description do
|
190
|
-
"raise wrapped error #{expected.inspect}"
|
191
|
-
end
|
192
|
-
|
193
|
-
failure_message do |_actual|
|
194
|
-
"expected that proc would raise wrapped error #{expected.inspect}"
|
195
|
-
end
|
196
|
-
|
197
|
-
failure_message_when_negated do |_actual|
|
198
|
-
"expected that proc would not raise wrapped error #{expected.inspect}"
|
199
|
-
end
|
200
|
-
end
|
201
|
-
|
202
|
-
RSpec::Matchers.define :be_some_textual_content do |expected|
|
203
|
-
include RSpec::Matchers::Composable
|
204
|
-
|
205
|
-
match do |actual|
|
206
|
-
actual.is_a?(Nanoc::Int::TextualContent) && values_match?(expected, actual.string)
|
207
|
-
end
|
208
|
-
|
209
|
-
description do
|
210
|
-
"textual content matching #{expected.inspect}"
|
211
|
-
end
|
212
|
-
|
213
|
-
failure_message do |actual|
|
214
|
-
"expected #{actual.inspect} to be textual content matching #{expected.inspect}"
|
215
|
-
end
|
216
|
-
|
217
|
-
failure_message_when_negated do |actual|
|
218
|
-
"expected #{actual.inspect} not to be textual content matching #{expected.inspect}"
|
219
|
-
end
|
220
|
-
end
|
221
|
-
|
222
|
-
RSpec::Matchers.define :be_some_binary_content do |expected|
|
223
|
-
include RSpec::Matchers::Composable
|
224
|
-
|
225
|
-
match do |actual|
|
226
|
-
actual.is_a?(Nanoc::Int::BinaryContent) && values_match?(expected, File.read(actual.filename))
|
227
|
-
end
|
228
|
-
|
229
|
-
description do
|
230
|
-
"binary content matching #{expected.inspect}"
|
231
|
-
end
|
232
|
-
|
233
|
-
failure_message do |actual|
|
234
|
-
"expected #{actual.inspect} to be binary content matching #{expected.inspect}"
|
235
|
-
end
|
236
|
-
|
237
|
-
failure_message_when_negated do |actual|
|
238
|
-
"expected #{actual.inspect} not to be binary content matching #{expected.inspect}"
|
239
|
-
end
|
240
|
-
end
|
241
|
-
|
242
|
-
RSpec::Matchers.alias_matcher :some_textual_content, :be_some_textual_content
|
243
|
-
RSpec::Matchers.alias_matcher :some_binary_content, :be_some_binary_content
|
244
|
-
|
245
|
-
RSpec::Matchers.define :send_notification do |name, *expected_args|
|
246
|
-
supports_block_expectations
|
247
|
-
|
248
|
-
include RSpec::Matchers::Composable
|
249
|
-
|
250
|
-
match do |actual|
|
251
|
-
@actual_notifications = []
|
252
|
-
Nanoc::Int::NotificationCenter.on(name, self) do |*actual_args|
|
253
|
-
@actual_notifications << actual_args
|
254
|
-
end
|
255
|
-
actual.call
|
256
|
-
@actual_notifications.any? { |c| c == expected_args }
|
257
|
-
end
|
258
|
-
|
259
|
-
description do
|
260
|
-
"send notification #{name.inspect} with args #{expected_args.inspect}"
|
261
|
-
end
|
262
|
-
|
263
|
-
failure_message do |_actual|
|
264
|
-
s = "expected that proc would send notification #{name.inspect} with args #{expected_args.inspect}"
|
265
|
-
if @actual_notifications.any?
|
266
|
-
s << " (received #{@actual_notifications.size} times with other arguments: #{@actual_notifications.map(&:inspect).join(', ')})"
|
267
|
-
end
|
268
|
-
s
|
269
|
-
end
|
270
|
-
|
271
|
-
failure_message_when_negated do |_actual|
|
272
|
-
"expected that proc would not send notification #{name.inspect} with args #{expected_args.inspect}"
|
273
|
-
end
|
274
|
-
end
|
275
|
-
|
276
|
-
RSpec::Matchers.define :have_correct_yard_examples do |_name, *_expected_args|
|
277
|
-
chain :in_file do |file|
|
278
|
-
root_dir = File.expand_path(__dir__ + '/..')
|
279
|
-
YARD.parse(root_dir + '/' + file)
|
280
|
-
end
|
281
|
-
|
282
|
-
match do |actual|
|
283
|
-
examples =
|
284
|
-
P(actual).tags(:example).flat_map do |example|
|
285
|
-
# Classify
|
286
|
-
lines = example.text.lines.map do |line|
|
287
|
-
[line =~ /^\s*# ?=>/ ? :result : :code, line]
|
288
|
-
end
|
289
|
-
|
290
|
-
# Join
|
291
|
-
pieces = []
|
292
|
-
lines.each do |line|
|
293
|
-
if !pieces.empty? && pieces.last.first == line.first
|
294
|
-
pieces.last.last << line.last
|
295
|
-
else
|
296
|
-
pieces << line
|
297
|
-
end
|
298
|
-
end
|
299
|
-
lines = pieces.map(&:last)
|
300
|
-
|
301
|
-
# Collect
|
302
|
-
lines.each_slice(2).to_a
|
303
|
-
end
|
304
|
-
|
305
|
-
b = binding
|
306
|
-
executed_examples = examples.map do |pair|
|
307
|
-
{
|
308
|
-
input: pair.first,
|
309
|
-
expected: eval(pair.last.match(/# ?=>(.*)/)[1], b),
|
310
|
-
actual: eval(pair.first, b),
|
311
|
-
}
|
312
|
-
end
|
313
|
-
|
314
|
-
@failing_examples = executed_examples.reject { |ex| ex[:expected] == ex[:actual] }
|
315
|
-
|
316
|
-
@failing_examples.empty?
|
317
|
-
end
|
318
|
-
|
319
|
-
failure_message do |_actual|
|
320
|
-
parts =
|
321
|
-
@failing_examples.map do |ex|
|
322
|
-
format(
|
323
|
-
"%s\nexpected to be\n %s\nbut was\n %s",
|
324
|
-
ex[:input],
|
325
|
-
ex[:expected].inspect,
|
326
|
-
ex[:actual].inspect,
|
327
|
-
)
|
328
|
-
end
|
329
|
-
|
330
|
-
parts.join("\n\n---\n\n")
|
331
|
-
end
|
332
|
-
end
|
333
|
-
|
334
|
-
RSpec::Matchers.define :leak_open_files do |_name, *_expected_args|
|
335
|
-
# Some remarks:
|
336
|
-
#
|
337
|
-
# • This matcher relies on global state (list of file descriptors and their
|
338
|
-
# state), which means that a test case that uses this matcher can fail if
|
339
|
-
# tests are being run in parallel.
|
340
|
-
#
|
341
|
-
# • This matcher assumes that file descriptors are closed explicitly, rather
|
342
|
-
# than implicitly through garbage collection. This means that a test case
|
343
|
-
# that uses this matcher can fail if the code exercised by the test case
|
344
|
-
# relies on file descriptors to be closed when they are garbage collected.
|
345
|
-
|
346
|
-
supports_block_expectations
|
347
|
-
|
348
|
-
match do |actual|
|
349
|
-
open_files_before = []
|
350
|
-
ObjectSpace.each_object(File) { |f| open_files_before << f.fileno unless f.closed? }
|
351
|
-
|
352
|
-
actual.call
|
353
|
-
|
354
|
-
open_files_after = []
|
355
|
-
ObjectSpace.each_object(File) { |f| open_files_after << f.fileno unless f.closed? }
|
356
|
-
|
357
|
-
open_files_before.sort != open_files_after.sort
|
358
|
-
end
|
359
|
-
|
360
|
-
description do
|
361
|
-
'leak open files'
|
362
|
-
end
|
363
|
-
|
364
|
-
failure_message do |_actual|
|
365
|
-
'expected that proc would leak open files'
|
366
|
-
end
|
367
|
-
|
368
|
-
failure_message_when_negated do |_actual|
|
369
|
-
'expected that proc would not leak open files'
|
370
|
-
end
|
371
|
-
end
|