nanoc 4.4.5 → 4.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +6 -2
- data/Gemfile.lock +37 -18
- data/NEWS.md +6 -0
- data/Rakefile +8 -20
- data/lib/nanoc/base/entities/code_snippet.rb +0 -2
- data/lib/nanoc/base/entities/item_rep.rb +4 -22
- data/lib/nanoc/base/entities/processing_actions/snapshot.rb +9 -7
- data/lib/nanoc/base/entities/rule_memory.rb +15 -7
- data/lib/nanoc/base/entities/snapshot_def.rb +2 -8
- data/lib/nanoc/base/repos/store.rb +2 -28
- data/lib/nanoc/base/services/checksummer.rb +9 -10
- data/lib/nanoc/base/services/compiler.rb +14 -16
- data/lib/nanoc/base/services/executor.rb +2 -13
- data/lib/nanoc/base/views/mixins/with_reps_view_mixin.rb +1 -1
- data/lib/nanoc/checking/checks/external_links.rb +2 -1
- data/lib/nanoc/cli/commands/compile.rb +8 -14
- data/lib/nanoc/extra/parallel_collection.rb +57 -0
- data/lib/nanoc/extra.rb +1 -0
- data/lib/nanoc/filters/mustache.rb +1 -1
- data/lib/nanoc/rule_dsl/recording_executor.rb +6 -34
- data/lib/nanoc/rule_dsl/rule_memory_calculator.rb +42 -12
- data/lib/nanoc/spec.rb +1 -1
- data/lib/nanoc/version.rb +1 -1
- data/nanoc.gemspec +1 -2
- data/spec/contributors_spec.rb +18 -0
- data/spec/nanoc/base/checksummer_spec.rb +381 -0
- data/spec/nanoc/base/compiler_spec.rb +181 -0
- data/spec/nanoc/base/entities/configuration_spec.rb +49 -0
- data/spec/nanoc/base/entities/content_spec.rb +193 -0
- data/spec/nanoc/base/entities/document_spec.rb +206 -0
- data/spec/nanoc/base/entities/identifier_spec.rb +460 -0
- data/spec/nanoc/base/entities/item_rep_spec.rb +226 -0
- data/spec/nanoc/base/entities/item_spec.rb +3 -0
- data/spec/nanoc/base/entities/layout_spec.rb +3 -0
- data/spec/nanoc/base/entities/lazy_value_spec.rb +106 -0
- data/spec/nanoc/base/entities/outdatedness_status_spec.rb +113 -0
- data/spec/nanoc/base/entities/pattern_spec.rb +125 -0
- data/spec/nanoc/base/entities/processing_action_spec.rb +9 -0
- data/spec/nanoc/base/entities/processing_actions/filter_spec.rb +18 -0
- data/spec/nanoc/base/entities/processing_actions/layout_spec.rb +18 -0
- data/spec/nanoc/base/entities/processing_actions/snapshot_spec.rb +32 -0
- data/spec/nanoc/base/entities/props_spec.rb +195 -0
- data/spec/nanoc/base/entities/rule_memory_spec.rb +131 -0
- data/spec/nanoc/base/entities/site_spec.rb +73 -0
- data/spec/nanoc/base/feature_spec.rb +107 -0
- data/spec/nanoc/base/filter_spec.rb +99 -0
- data/spec/nanoc/base/item_rep_writer_spec.rb +131 -0
- data/spec/nanoc/base/plugin_registry_spec.rb +29 -0
- data/spec/nanoc/base/repos/checksum_store_spec.rb +133 -0
- data/spec/nanoc/base/repos/compiled_content_cache_spec.rb +55 -0
- data/spec/nanoc/base/repos/config_loader_spec.rb +243 -0
- data/spec/nanoc/base/repos/dependency_store_spec.rb +195 -0
- data/spec/nanoc/base/repos/site_loader_spec.rb +214 -0
- data/spec/nanoc/base/services/dependency_tracker_spec.rb +238 -0
- data/spec/nanoc/base/services/executor_spec.rb +495 -0
- data/spec/nanoc/base/services/item_rep_router_spec.rb +134 -0
- data/spec/nanoc/base/services/item_rep_selector_spec.rb +169 -0
- data/spec/nanoc/base/services/outdatedness_checker_spec.rb +370 -0
- data/spec/nanoc/base/services/outdatedness_rules_spec.rb +432 -0
- data/spec/nanoc/base/services/pruner_spec.rb +105 -0
- data/spec/nanoc/base/services/temp_filename_factory_spec.rb +87 -0
- data/spec/nanoc/base/views/config_view_spec.rb +96 -0
- data/spec/nanoc/base/views/document_view_spec.rb +332 -0
- data/spec/nanoc/base/views/identifiable_collection_view_spec.rb +190 -0
- data/spec/nanoc/base/views/item_collection_with_reps_view_spec.rb +18 -0
- data/spec/nanoc/base/views/item_collection_without_reps_view_spec.rb +18 -0
- data/spec/nanoc/base/views/item_rep_collection_view_spec.rb +143 -0
- data/spec/nanoc/base/views/item_rep_view_spec.rb +265 -0
- data/spec/nanoc/base/views/item_view_spec.rb +341 -0
- data/spec/nanoc/base/views/layout_collection_view_spec.rb +18 -0
- data/spec/nanoc/base/views/layout_view_spec.rb +14 -0
- data/spec/nanoc/base/views/mutable_config_view_spec.rb +16 -0
- data/spec/nanoc/base/views/mutable_document_view_spec.rb +92 -0
- data/spec/nanoc/base/views/mutable_identifiable_collection_view_spec.rb +36 -0
- data/spec/nanoc/base/views/mutable_item_collection_view_spec.rb +49 -0
- data/spec/nanoc/base/views/mutable_item_view_spec.rb +22 -0
- data/spec/nanoc/base/views/mutable_layout_collection_view_spec.rb +49 -0
- data/spec/nanoc/base/views/mutable_layout_view_spec.rb +13 -0
- data/spec/nanoc/base/views/post_compile_item_rep_collection_view_spec.rb +4 -0
- data/spec/nanoc/base/views/post_compile_item_rep_view_spec.rb +137 -0
- data/spec/nanoc/base/views/post_compile_item_view_spec.rb +56 -0
- data/spec/nanoc/cli/commands/compile/file_action_printer_spec.rb +76 -0
- data/spec/nanoc/cli/commands/compile/timing_recorder_spec.rb +66 -0
- data/spec/nanoc/cli/commands/compile_spec.rb +64 -0
- data/spec/nanoc/cli/commands/deploy_spec.rb +327 -0
- data/spec/nanoc/cli/commands/shell_spec.rb +54 -0
- data/spec/nanoc/cli/commands/show_data_spec.rb +126 -0
- data/spec/nanoc/cli/commands/show_rules_spec.rb +112 -0
- data/spec/nanoc/cli/commands/view_spec.rb +58 -0
- data/spec/nanoc/data_sources/filesystem_spec.rb +56 -0
- data/spec/nanoc/deploying/fog_spec.rb +193 -0
- data/spec/nanoc/extra/parallel_collection_spec.rb +108 -0
- data/spec/nanoc/filters/colorize_syntax/rouge_spec.rb +195 -0
- data/spec/nanoc/filters/less_spec.rb +120 -0
- data/spec/nanoc/helpers/blogging_spec.rb +216 -0
- data/spec/nanoc/helpers/breadcrumbs_spec.rb +133 -0
- data/spec/nanoc/helpers/capturing_spec.rb +181 -0
- data/spec/nanoc/helpers/child_parent_spec.rb +105 -0
- data/spec/nanoc/helpers/filtering_spec.rb +72 -0
- data/spec/nanoc/helpers/html_escape_spec.rb +35 -0
- data/spec/nanoc/helpers/link_to_spec.rb +275 -0
- data/spec/nanoc/helpers/rendering_spec.rb +141 -0
- data/spec/nanoc/helpers/tagging_spec.rb +104 -0
- data/spec/nanoc/helpers/text_spec.rb +58 -0
- data/spec/nanoc/integration/outdatedness_integration_spec.rb +208 -0
- data/spec/nanoc/regressions/gh_1015_spec.rb +17 -0
- data/spec/nanoc/regressions/gh_1031_spec.rb +54 -0
- data/spec/nanoc/regressions/gh_1035_spec.rb +33 -0
- data/spec/nanoc/regressions/gh_1040_spec.rb +22 -0
- data/spec/nanoc/regressions/gh_761_spec.rb +23 -0
- data/spec/nanoc/regressions/gh_767_spec.rb +19 -0
- data/spec/nanoc/regressions/gh_769_spec.rb +30 -0
- data/spec/nanoc/regressions/gh_776_spec.rb +43 -0
- data/spec/nanoc/regressions/gh_787_spec.rb +19 -0
- data/spec/nanoc/regressions/gh_795_spec.rb +19 -0
- data/spec/nanoc/regressions/gh_804_spec.rb +26 -0
- data/spec/nanoc/regressions/gh_807_spec.rb +17 -0
- data/spec/nanoc/regressions/gh_809_spec.rb +17 -0
- data/spec/nanoc/regressions/gh_813_spec.rb +22 -0
- data/spec/nanoc/regressions/gh_815_spec.rb +18 -0
- data/spec/nanoc/regressions/gh_828_spec.rb +23 -0
- data/spec/nanoc/regressions/gh_833_spec.rb +14 -0
- data/spec/nanoc/regressions/gh_841_spec.rb +15 -0
- data/spec/nanoc/regressions/gh_867_spec.rb +15 -0
- data/spec/nanoc/regressions/gh_882_spec.rb +29 -0
- data/spec/nanoc/regressions/gh_885_spec.rb +30 -0
- data/spec/nanoc/regressions/gh_891_spec.rb +26 -0
- data/spec/nanoc/regressions/gh_913_spec.rb +24 -0
- data/spec/nanoc/regressions/gh_928_spec.rb +5 -0
- data/spec/nanoc/regressions/gh_937_spec.rb +25 -0
- data/spec/nanoc/regressions/gh_942_spec.rb +21 -0
- data/spec/nanoc/regressions/gh_947_spec.rb +21 -0
- data/spec/nanoc/regressions/gh_948_spec.rb +16 -0
- data/spec/nanoc/regressions/gh_951_spec.rb +19 -0
- data/spec/nanoc/regressions/gh_954_spec.rb +33 -0
- data/spec/nanoc/regressions/gh_970a_spec.rb +17 -0
- data/spec/nanoc/regressions/gh_970b_spec.rb +50 -0
- data/spec/nanoc/regressions/gh_974_spec.rb +17 -0
- data/spec/nanoc/regressions/gh_981_spec.rb +21 -0
- data/spec/nanoc/rule_dsl/recording_executor_spec.rb +142 -0
- data/spec/nanoc/rule_dsl/rule_context_spec.rb +177 -0
- data/spec/nanoc/rule_dsl/rule_memory_calculator_spec.rb +233 -0
- data/spec/nanoc/rule_dsl/rules_collection_spec.rb +299 -0
- data/spec/regression_filenames_spec.rb +16 -0
- data/spec/spec_helper.rb +173 -0
- data/test/base/core_ext/array_spec.rb +2 -0
- data/test/base/core_ext/hash_spec.rb +2 -0
- data/test/base/core_ext/string_spec.rb +2 -0
- data/test/base/test_code_snippet.rb +2 -0
- data/test/base/test_compiler.rb +2 -0
- data/test/base/test_context.rb +4 -2
- data/test/base/test_data_source.rb +2 -0
- data/test/base/test_dependency_tracker.rb +2 -0
- data/test/base/test_directed_graph.rb +2 -0
- data/test/base/test_filter.rb +7 -5
- data/test/base/test_item.rb +2 -0
- data/test/base/test_item_array.rb +3 -1
- data/test/base/test_layout.rb +2 -0
- data/test/base/test_memoization.rb +2 -0
- data/test/base/test_notification_center.rb +2 -0
- data/test/base/test_outdatedness_checker.rb +2 -0
- data/test/base/test_plugin.rb +2 -0
- data/test/base/test_site.rb +2 -0
- data/test/base/test_store.rb +2 -0
- data/test/checking/checks/test_css.rb +2 -0
- data/test/checking/checks/test_external_links.rb +4 -2
- data/test/checking/checks/test_html.rb +2 -0
- data/test/checking/checks/test_internal_links.rb +5 -3
- data/test/checking/checks/test_mixed_content.rb +2 -0
- data/test/checking/checks/test_stale.rb +2 -0
- data/test/checking/test_check.rb +2 -0
- data/test/checking/test_dsl.rb +2 -0
- data/test/checking/test_runner.rb +2 -0
- data/test/cli/commands/test_check.rb +2 -0
- data/test/cli/commands/test_compile.rb +2 -0
- data/test/cli/commands/test_create_site.rb +2 -0
- data/test/cli/commands/test_help.rb +2 -0
- data/test/cli/commands/test_info.rb +2 -0
- data/test/cli/commands/test_prune.rb +2 -0
- data/test/cli/test_cleaning_stream.rb +2 -0
- data/test/cli/test_cli.rb +11 -9
- data/test/cli/test_error_handler.rb +2 -0
- data/test/cli/test_logger.rb +2 -0
- data/test/data_sources/test_filesystem.rb +8 -6
- data/test/data_sources/test_filesystem_tools.rb +2 -0
- data/test/deploying/test_fog.rb +2 -0
- data/test/deploying/test_rsync.rb +4 -2
- data/test/extra/core_ext/test_pathname.rb +2 -0
- data/test/extra/core_ext/test_time.rb +2 -0
- data/test/extra/test_link_collector.rb +2 -0
- data/test/extra/test_piper.rb +2 -0
- data/test/filters/colorize_syntax/test_coderay.rb +2 -0
- data/test/filters/colorize_syntax/test_common.rb +2 -0
- data/test/filters/colorize_syntax/test_pygmentize.rb +2 -0
- data/test/filters/colorize_syntax/test_pygments.rb +2 -0
- data/test/filters/colorize_syntax/test_simon.rb +2 -0
- data/test/filters/test_asciidoc.rb +2 -0
- data/test/filters/test_bluecloth.rb +2 -0
- data/test/filters/test_coffeescript.rb +2 -0
- data/test/filters/test_erb.rb +7 -5
- data/test/filters/test_erubis.rb +6 -4
- data/test/filters/test_haml.rb +7 -5
- data/test/filters/test_handlebars.rb +2 -0
- data/test/filters/test_kramdown.rb +2 -0
- data/test/filters/test_markaby.rb +2 -0
- data/test/filters/test_maruku.rb +2 -0
- data/test/filters/test_mustache.rb +4 -2
- data/test/filters/test_pandoc.rb +2 -0
- data/test/filters/test_rainpress.rb +2 -0
- data/test/filters/test_rdiscount.rb +2 -0
- data/test/filters/test_rdoc.rb +2 -0
- data/test/filters/test_redcarpet.rb +2 -0
- data/test/filters/test_redcloth.rb +2 -0
- data/test/filters/test_relativize_paths.rb +2 -0
- data/test/filters/test_rubypants.rb +2 -0
- data/test/filters/test_sass.rb +4 -2
- data/test/filters/test_slim.rb +4 -2
- data/test/filters/test_typogruby.rb +2 -0
- data/test/filters/test_uglify_js.rb +2 -0
- data/test/filters/test_xsl.rb +2 -0
- data/test/filters/test_yui_compressor.rb +5 -3
- data/test/helpers/test_blogging.rb +2 -0
- data/test/helpers/test_capturing.rb +2 -0
- data/test/helpers/test_link_to.rb +2 -0
- data/test/helpers/test_xml_sitemap.rb +2 -0
- data/test/rule_dsl/test_action_provider.rb +2 -0
- data/test/rule_dsl/test_compiler_dsl.rb +6 -4
- data/test/rule_dsl/test_rule.rb +2 -0
- data/test/rule_dsl/test_rules_collection.rb +2 -0
- data/test/test_gem.rb +2 -0
- metadata +124 -17
- data/test/base/test_item_rep.rb +0 -156
@@ -0,0 +1,16 @@
|
|
1
|
+
describe 'regression tests', chdir: false do
|
2
|
+
let(:regression_test_filenames) do
|
3
|
+
Dir['spec/nanoc/regressions/*']
|
4
|
+
end
|
5
|
+
|
6
|
+
let(:regression_test_numbers) do
|
7
|
+
regression_test_filenames
|
8
|
+
.map { |fn| File.readlines(fn).first.match(/GH-(\d+)/)[1] }
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should have the proper filenames' do
|
12
|
+
regression_test_filenames.zip(regression_test_numbers) do |fn, num|
|
13
|
+
expect(fn).to match(/gh_#{num}[a-z]*_spec/), "#{fn} has the wrong name in its #define block"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,173 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
SimpleCov.start
|
3
|
+
|
4
|
+
require 'nanoc'
|
5
|
+
require 'nanoc/cli'
|
6
|
+
require 'nanoc/spec'
|
7
|
+
|
8
|
+
require 'timecop'
|
9
|
+
require 'rspec/its'
|
10
|
+
|
11
|
+
Nanoc::CLI.setup
|
12
|
+
|
13
|
+
RSpec.configure do |c|
|
14
|
+
c.around(:each) do |example|
|
15
|
+
Nanoc::CLI::ErrorHandler.disable
|
16
|
+
example.run
|
17
|
+
Nanoc::CLI::ErrorHandler.enable
|
18
|
+
end
|
19
|
+
|
20
|
+
c.around(:each) do |example|
|
21
|
+
Dir.mktmpdir('nanoc-test') do |dir|
|
22
|
+
FileUtils.cd(dir) do
|
23
|
+
example.run
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
c.around(:each, chdir: false) do |example|
|
29
|
+
FileUtils.cd(File.dirname(__FILE__) + '/..') do
|
30
|
+
example.run
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
c.before(:each) do
|
35
|
+
Nanoc::Int::NotificationCenter.reset
|
36
|
+
end
|
37
|
+
|
38
|
+
c.before(:each, v8: true) do
|
39
|
+
if ENV.key?('DISABLE_V8')
|
40
|
+
skip 'V8 specs are disabled (broken on Ruby 2.4)'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
c.around(:each, stdio: true) do |example|
|
45
|
+
orig_stdout = $stdout
|
46
|
+
orig_stderr = $stderr
|
47
|
+
|
48
|
+
unless ENV['QUIET'] == 'false'
|
49
|
+
$stdout = StringIO.new
|
50
|
+
$stderr = StringIO.new
|
51
|
+
end
|
52
|
+
|
53
|
+
example.run
|
54
|
+
|
55
|
+
$stdout = orig_stdout
|
56
|
+
$stderr = orig_stderr
|
57
|
+
end
|
58
|
+
|
59
|
+
c.before(:each, site: true) do
|
60
|
+
FileUtils.mkdir_p('content')
|
61
|
+
FileUtils.mkdir_p('layouts')
|
62
|
+
FileUtils.mkdir_p('lib')
|
63
|
+
FileUtils.mkdir_p('output')
|
64
|
+
|
65
|
+
File.write('nanoc.yaml', '{}')
|
66
|
+
|
67
|
+
File.write('Rules', 'passthrough "/**/*"')
|
68
|
+
end
|
69
|
+
|
70
|
+
c.include(Nanoc::Spec::HelperHelper, helper: true)
|
71
|
+
|
72
|
+
# Set focus if any
|
73
|
+
if ENV.fetch('FOCUS', false)
|
74
|
+
$stdout.puts "Focusing spec on '#{ENV['FOCUS']}'"
|
75
|
+
c.filter_run_including ENV['FOCUS'].to_sym => true
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
RSpec::Matchers.define :raise_frozen_error do |_expected|
|
80
|
+
match do |actual|
|
81
|
+
begin
|
82
|
+
actual.call
|
83
|
+
false
|
84
|
+
rescue => e
|
85
|
+
if e.is_a?(RuntimeError) || e.is_a?(TypeError)
|
86
|
+
e.message =~ /(^can't modify frozen |^unable to modify frozen object$)/
|
87
|
+
else
|
88
|
+
false
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
supports_block_expectations
|
94
|
+
|
95
|
+
failure_message do |_actual|
|
96
|
+
'expected that proc would raise a frozen error'
|
97
|
+
end
|
98
|
+
|
99
|
+
failure_message_when_negated do |_actual|
|
100
|
+
'expected that proc would not raise a frozen error'
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
RSpec::Matchers.define :be_humanly_sorted do
|
105
|
+
match do |actual|
|
106
|
+
actual == sort(actual)
|
107
|
+
end
|
108
|
+
|
109
|
+
description do
|
110
|
+
'be humanly sorted'
|
111
|
+
end
|
112
|
+
|
113
|
+
failure_message do |actual|
|
114
|
+
expected_order = []
|
115
|
+
actual.zip(sort(actual)).each do |a, b|
|
116
|
+
if a != b
|
117
|
+
expected_order << b
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
"expected collection to be sorted (incorrect order: #{expected_order.join(' < ')})"
|
122
|
+
end
|
123
|
+
|
124
|
+
def sort(x)
|
125
|
+
x.sort_by { |n| n.dup.unicode_normalize(:nfd).encode('ASCII', fallback: ->(_) { '' }).downcase }
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
RSpec::Matchers.define :finish_in_under do |expected|
|
130
|
+
supports_block_expectations
|
131
|
+
|
132
|
+
match do |actual|
|
133
|
+
before = Time.now
|
134
|
+
actual.call
|
135
|
+
after = Time.now
|
136
|
+
@actual_duration = after - before
|
137
|
+
@actual_duration < expected
|
138
|
+
end
|
139
|
+
|
140
|
+
chain :seconds do
|
141
|
+
end
|
142
|
+
|
143
|
+
failure_message do |_actual|
|
144
|
+
"expected that proc would finish in under #{expected}s, but took #{format '%0.1fs', @actual_duration}"
|
145
|
+
end
|
146
|
+
|
147
|
+
failure_message_when_negated do |_actual|
|
148
|
+
"expected that proc would not finish in under #{expected}s, but took #{format '%0.1fs', @actual_duration}"
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
RSpec::Matchers.define :yield_from_fiber do |expected|
|
153
|
+
supports_block_expectations
|
154
|
+
|
155
|
+
include RSpec::Matchers::Composable
|
156
|
+
|
157
|
+
match do |actual|
|
158
|
+
@res = Fiber.new { actual.call }.resume
|
159
|
+
values_match?(expected, @res)
|
160
|
+
end
|
161
|
+
|
162
|
+
description do
|
163
|
+
"yield #{expected.inspect} from fiber"
|
164
|
+
end
|
165
|
+
|
166
|
+
failure_message do |_actual|
|
167
|
+
"expected that proc would yield #{expected.inspect} from fiber, but was #{@res.inspect}"
|
168
|
+
end
|
169
|
+
|
170
|
+
failure_message_when_negated do |_actual|
|
171
|
+
"expected that proc would not yield #{expected.inspect} from fiber, but was #{@res.inspect}"
|
172
|
+
end
|
173
|
+
end
|
data/test/base/test_compiler.rb
CHANGED
data/test/base/test_context.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
1
3
|
class Nanoc::Int::ContextTest < Nanoc::TestCase
|
2
4
|
def test_context_with_instance_variable
|
3
5
|
# Create context
|
4
|
-
context = Nanoc::Int::Context.new(
|
6
|
+
context = Nanoc::Int::Context.new(foo: 'bar', baz: 'quux')
|
5
7
|
|
6
8
|
# Ensure correct evaluation
|
7
9
|
assert_equal('bar', eval('@foo', context.get_binding))
|
@@ -9,7 +11,7 @@ class Nanoc::Int::ContextTest < Nanoc::TestCase
|
|
9
11
|
|
10
12
|
def test_context_with_instance_method
|
11
13
|
# Create context
|
12
|
-
context = Nanoc::Int::Context.new(
|
14
|
+
context = Nanoc::Int::Context.new(foo: 'bar', baz: 'quux')
|
13
15
|
|
14
16
|
# Ensure correct evaluation
|
15
17
|
assert_equal('bar', eval('foo', context.get_binding))
|
data/test/base/test_filter.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
1
3
|
class Nanoc::FilterTest < Nanoc::TestCase
|
2
4
|
def test_initialize
|
3
5
|
# Create filter
|
@@ -9,7 +11,7 @@ class Nanoc::FilterTest < Nanoc::TestCase
|
|
9
11
|
|
10
12
|
def test_assigns
|
11
13
|
# Create filter
|
12
|
-
filter = Nanoc::Filter.new(
|
14
|
+
filter = Nanoc::Filter.new(foo: 'bar')
|
13
15
|
|
14
16
|
# Check assigns
|
15
17
|
assert_equal('bar', filter.assigns[:foo])
|
@@ -17,7 +19,7 @@ class Nanoc::FilterTest < Nanoc::TestCase
|
|
17
19
|
|
18
20
|
def test_assigns_with_instance_variables
|
19
21
|
# Create filter
|
20
|
-
filter = Nanoc::Filter.new(
|
22
|
+
filter = Nanoc::Filter.new(foo: 'bar')
|
21
23
|
|
22
24
|
# Check assigns
|
23
25
|
assert_equal('bar', filter.instance_eval { @foo })
|
@@ -25,7 +27,7 @@ class Nanoc::FilterTest < Nanoc::TestCase
|
|
25
27
|
|
26
28
|
def test_assigns_with_instance_methods
|
27
29
|
# Create filter
|
28
|
-
filter = Nanoc::Filter.new(
|
30
|
+
filter = Nanoc::Filter.new(foo: 'bar')
|
29
31
|
|
30
32
|
# Check assigns
|
31
33
|
assert_equal('bar', filter.instance_eval { foo })
|
@@ -49,7 +51,7 @@ class Nanoc::FilterTest < Nanoc::TestCase
|
|
49
51
|
item_rep.expects(:name).returns(:quux)
|
50
52
|
|
51
53
|
# Create filter
|
52
|
-
filter = Nanoc::Filter.new(
|
54
|
+
filter = Nanoc::Filter.new(item: item, item_rep: item_rep)
|
53
55
|
|
54
56
|
# Check filename
|
55
57
|
assert_equal('item /foo/bar/baz/ (rep quux)', filter.filename)
|
@@ -61,7 +63,7 @@ class Nanoc::FilterTest < Nanoc::TestCase
|
|
61
63
|
layout.expects(:identifier).returns('/wohba/')
|
62
64
|
|
63
65
|
# Create filter
|
64
|
-
filter = Nanoc::Filter.new(
|
66
|
+
filter = Nanoc::Filter.new(item: mock, item_rep: mock, layout: layout)
|
65
67
|
|
66
68
|
# Check filename
|
67
69
|
assert_equal('layout /wohba/', filter.filename)
|
data/test/base/test_item.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
1
3
|
class Nanoc::Int::IdentifiableCollectionTest < Nanoc::TestCase
|
2
4
|
def setup
|
3
5
|
super
|
@@ -25,7 +27,7 @@ class Nanoc::Int::IdentifiableCollectionTest < Nanoc::TestCase
|
|
25
27
|
end
|
26
28
|
|
27
29
|
def test_brackets_with_glob
|
28
|
-
@items = Nanoc::Int::IdentifiableCollection.new(
|
30
|
+
@items = Nanoc::Int::IdentifiableCollection.new(string_pattern_type: 'glob')
|
29
31
|
@items << @one
|
30
32
|
@items << @two
|
31
33
|
|
data/test/base/test_layout.rb
CHANGED
data/test/base/test_plugin.rb
CHANGED
data/test/base/test_site.rb
CHANGED
data/test/base/test_store.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
1
3
|
class Nanoc::Checking::Checks::ExternalLinksTest < Nanoc::TestCase
|
2
4
|
def test_run
|
3
5
|
with_site do |site|
|
@@ -77,7 +79,7 @@ class Nanoc::Checking::Checks::ExternalLinksTest < Nanoc::TestCase
|
|
77
79
|
with_site do |site|
|
78
80
|
# Create check
|
79
81
|
check = Nanoc::Checking::Checks::ExternalLinks.create(site)
|
80
|
-
site.config.update(
|
82
|
+
site.config.update(checks: { external_links: { exclude: ['^http://excluded.com$'] } })
|
81
83
|
|
82
84
|
# Test
|
83
85
|
assert check.send(:excluded?, 'http://excluded.com')
|
@@ -90,7 +92,7 @@ class Nanoc::Checking::Checks::ExternalLinksTest < Nanoc::TestCase
|
|
90
92
|
with_site do |site|
|
91
93
|
# Create check
|
92
94
|
check = Nanoc::Checking::Checks::ExternalLinks.create(site)
|
93
|
-
site.config.update(
|
95
|
+
site.config.update(checks: { external_links: { exclude_files: ['blog/page'] } })
|
94
96
|
|
95
97
|
# Test
|
96
98
|
assert check.send(:excluded_file?, 'output/blog/page1/index.html')
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
1
3
|
class Nanoc::Checking::Checks::InternalLinksTest < Nanoc::TestCase
|
2
4
|
def test_run
|
3
5
|
with_site do |site|
|
@@ -69,7 +71,7 @@ class Nanoc::Checking::Checks::InternalLinksTest < Nanoc::TestCase
|
|
69
71
|
with_site do |site|
|
70
72
|
# Create check
|
71
73
|
check = Nanoc::Checking::Checks::InternalLinks.create(site)
|
72
|
-
site.config.update(
|
74
|
+
site.config.update(checks: { internal_links: { exclude: ['^/excluded\d+'] } })
|
73
75
|
|
74
76
|
# Test
|
75
77
|
assert check.send(:valid?, '/excluded1', 'output/origin')
|
@@ -82,7 +84,7 @@ class Nanoc::Checking::Checks::InternalLinksTest < Nanoc::TestCase
|
|
82
84
|
with_site do |site|
|
83
85
|
# Create check
|
84
86
|
check = Nanoc::Checking::Checks::InternalLinks.create(site)
|
85
|
-
site.config.update(
|
87
|
+
site.config.update(checks: { internal_links: { exclude_targets: ['^/excluded\d+'] } })
|
86
88
|
|
87
89
|
# Test
|
88
90
|
assert check.send(:valid?, '/excluded1', 'output/origin')
|
@@ -95,7 +97,7 @@ class Nanoc::Checking::Checks::InternalLinksTest < Nanoc::TestCase
|
|
95
97
|
with_site do |site|
|
96
98
|
# Create check
|
97
99
|
check = Nanoc::Checking::Checks::InternalLinks.create(site)
|
98
|
-
site.config.update(
|
100
|
+
site.config.update(checks: { internal_links: { exclude_origins: ['^/excluded'] } })
|
99
101
|
|
100
102
|
# Test
|
101
103
|
assert check.send(:valid?, '/foo', 'output/excluded')
|
data/test/checking/test_check.rb
CHANGED
data/test/checking/test_dsl.rb
CHANGED
data/test/cli/test_cli.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
1
3
|
class Nanoc::CLITest < Nanoc::TestCase
|
2
4
|
COMMAND_CODE = <<EOS.freeze
|
3
5
|
usage '_test [options]'
|
@@ -176,17 +178,17 @@ EOS
|
|
176
178
|
with_env_vars(new_env_diff) do
|
177
179
|
refute Nanoc::CLI.enable_utf8?(io)
|
178
180
|
|
179
|
-
with_env_vars(
|
180
|
-
with_env_vars(
|
181
|
-
with_env_vars(
|
181
|
+
with_env_vars('LC_ALL' => 'en_US.UTF-8') { assert Nanoc::CLI.enable_utf8?(io) }
|
182
|
+
with_env_vars('LC_CTYPE' => 'en_US.UTF-8') { assert Nanoc::CLI.enable_utf8?(io) }
|
183
|
+
with_env_vars('LANG' => 'en_US.UTF-8') { assert Nanoc::CLI.enable_utf8?(io) }
|
182
184
|
|
183
|
-
with_env_vars(
|
184
|
-
with_env_vars(
|
185
|
-
with_env_vars(
|
185
|
+
with_env_vars('LC_ALL' => 'en_US.utf-8') { assert Nanoc::CLI.enable_utf8?(io) }
|
186
|
+
with_env_vars('LC_CTYPE' => 'en_US.utf-8') { assert Nanoc::CLI.enable_utf8?(io) }
|
187
|
+
with_env_vars('LANG' => 'en_US.utf-8') { assert Nanoc::CLI.enable_utf8?(io) }
|
186
188
|
|
187
|
-
with_env_vars(
|
188
|
-
with_env_vars(
|
189
|
-
with_env_vars(
|
189
|
+
with_env_vars('LC_ALL' => 'en_US.utf8') { assert Nanoc::CLI.enable_utf8?(io) }
|
190
|
+
with_env_vars('LC_CTYPE' => 'en_US.utf8') { assert Nanoc::CLI.enable_utf8?(io) }
|
191
|
+
with_env_vars('LANG' => 'en_US.utf8') { assert Nanoc::CLI.enable_utf8?(io) }
|
190
192
|
end
|
191
193
|
end
|
192
194
|
end
|
data/test/cli/test_logger.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
1
3
|
class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
2
4
|
def new_data_source(params = nil)
|
3
5
|
# Mock site
|
@@ -69,7 +71,7 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
|
69
71
|
|
70
72
|
def test_load_objects_with_same_extensions
|
71
73
|
# Create data source
|
72
|
-
data_source = new_data_source(
|
74
|
+
data_source = new_data_source(identifier_type: 'full')
|
73
75
|
|
74
76
|
# Create a fake class
|
75
77
|
klass = Class.new do
|
@@ -142,7 +144,7 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
|
142
144
|
|
143
145
|
def test_identifier_for_filename_with_full_style_identifier
|
144
146
|
# Create data source
|
145
|
-
data_source = new_data_source(
|
147
|
+
data_source = new_data_source(identifier_type: 'full')
|
146
148
|
|
147
149
|
# Get input and expected output
|
148
150
|
expected = {
|
@@ -463,7 +465,7 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
|
463
465
|
end
|
464
466
|
|
465
467
|
def test_load_objects_correct_identifier_with_separate_yaml_file
|
466
|
-
data_source = new_data_source(
|
468
|
+
data_source = new_data_source(identifier_type: 'full')
|
467
469
|
|
468
470
|
FileUtils.mkdir_p('foo')
|
469
471
|
File.write('foo/donkey.jpeg', 'data')
|
@@ -541,7 +543,7 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
|
541
543
|
|
542
544
|
def test_all_split_files_in_allowing_periods_in_identifiers
|
543
545
|
# Create data source
|
544
|
-
data_source = Nanoc::DataSources::Filesystem.new(nil, nil, nil,
|
546
|
+
data_source = Nanoc::DataSources::Filesystem.new(nil, nil, nil, allow_periods_in_identifiers: true)
|
545
547
|
|
546
548
|
# Write sample files
|
547
549
|
FileUtils.mkdir_p('foo')
|
@@ -649,7 +651,7 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
|
649
651
|
|
650
652
|
def test_basename_of_allowing_periods_in_identifiers
|
651
653
|
# Create data source
|
652
|
-
data_source = Nanoc::DataSources::Filesystem.new(nil, nil, nil,
|
654
|
+
data_source = Nanoc::DataSources::Filesystem.new(nil, nil, nil, allow_periods_in_identifiers: true)
|
653
655
|
|
654
656
|
# Get input and expected output
|
655
657
|
expected = {
|
@@ -709,7 +711,7 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
|
709
711
|
|
710
712
|
def test_ext_of_allowing_periods_in_identifiers
|
711
713
|
# Create data source
|
712
|
-
data_source = Nanoc::DataSources::Filesystem.new(nil, nil, nil,
|
714
|
+
data_source = Nanoc::DataSources::Filesystem.new(nil, nil, nil, allow_periods_in_identifiers: true)
|
713
715
|
|
714
716
|
# Get input and expected output
|
715
717
|
expected = {
|