nanoc 4.4.5 → 4.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +6 -2
  3. data/Gemfile.lock +37 -18
  4. data/NEWS.md +6 -0
  5. data/Rakefile +8 -20
  6. data/lib/nanoc/base/entities/code_snippet.rb +0 -2
  7. data/lib/nanoc/base/entities/item_rep.rb +4 -22
  8. data/lib/nanoc/base/entities/processing_actions/snapshot.rb +9 -7
  9. data/lib/nanoc/base/entities/rule_memory.rb +15 -7
  10. data/lib/nanoc/base/entities/snapshot_def.rb +2 -8
  11. data/lib/nanoc/base/repos/store.rb +2 -28
  12. data/lib/nanoc/base/services/checksummer.rb +9 -10
  13. data/lib/nanoc/base/services/compiler.rb +14 -16
  14. data/lib/nanoc/base/services/executor.rb +2 -13
  15. data/lib/nanoc/base/views/mixins/with_reps_view_mixin.rb +1 -1
  16. data/lib/nanoc/checking/checks/external_links.rb +2 -1
  17. data/lib/nanoc/cli/commands/compile.rb +8 -14
  18. data/lib/nanoc/extra/parallel_collection.rb +57 -0
  19. data/lib/nanoc/extra.rb +1 -0
  20. data/lib/nanoc/filters/mustache.rb +1 -1
  21. data/lib/nanoc/rule_dsl/recording_executor.rb +6 -34
  22. data/lib/nanoc/rule_dsl/rule_memory_calculator.rb +42 -12
  23. data/lib/nanoc/spec.rb +1 -1
  24. data/lib/nanoc/version.rb +1 -1
  25. data/nanoc.gemspec +1 -2
  26. data/spec/contributors_spec.rb +18 -0
  27. data/spec/nanoc/base/checksummer_spec.rb +381 -0
  28. data/spec/nanoc/base/compiler_spec.rb +181 -0
  29. data/spec/nanoc/base/entities/configuration_spec.rb +49 -0
  30. data/spec/nanoc/base/entities/content_spec.rb +193 -0
  31. data/spec/nanoc/base/entities/document_spec.rb +206 -0
  32. data/spec/nanoc/base/entities/identifier_spec.rb +460 -0
  33. data/spec/nanoc/base/entities/item_rep_spec.rb +226 -0
  34. data/spec/nanoc/base/entities/item_spec.rb +3 -0
  35. data/spec/nanoc/base/entities/layout_spec.rb +3 -0
  36. data/spec/nanoc/base/entities/lazy_value_spec.rb +106 -0
  37. data/spec/nanoc/base/entities/outdatedness_status_spec.rb +113 -0
  38. data/spec/nanoc/base/entities/pattern_spec.rb +125 -0
  39. data/spec/nanoc/base/entities/processing_action_spec.rb +9 -0
  40. data/spec/nanoc/base/entities/processing_actions/filter_spec.rb +18 -0
  41. data/spec/nanoc/base/entities/processing_actions/layout_spec.rb +18 -0
  42. data/spec/nanoc/base/entities/processing_actions/snapshot_spec.rb +32 -0
  43. data/spec/nanoc/base/entities/props_spec.rb +195 -0
  44. data/spec/nanoc/base/entities/rule_memory_spec.rb +131 -0
  45. data/spec/nanoc/base/entities/site_spec.rb +73 -0
  46. data/spec/nanoc/base/feature_spec.rb +107 -0
  47. data/spec/nanoc/base/filter_spec.rb +99 -0
  48. data/spec/nanoc/base/item_rep_writer_spec.rb +131 -0
  49. data/spec/nanoc/base/plugin_registry_spec.rb +29 -0
  50. data/spec/nanoc/base/repos/checksum_store_spec.rb +133 -0
  51. data/spec/nanoc/base/repos/compiled_content_cache_spec.rb +55 -0
  52. data/spec/nanoc/base/repos/config_loader_spec.rb +243 -0
  53. data/spec/nanoc/base/repos/dependency_store_spec.rb +195 -0
  54. data/spec/nanoc/base/repos/site_loader_spec.rb +214 -0
  55. data/spec/nanoc/base/services/dependency_tracker_spec.rb +238 -0
  56. data/spec/nanoc/base/services/executor_spec.rb +495 -0
  57. data/spec/nanoc/base/services/item_rep_router_spec.rb +134 -0
  58. data/spec/nanoc/base/services/item_rep_selector_spec.rb +169 -0
  59. data/spec/nanoc/base/services/outdatedness_checker_spec.rb +370 -0
  60. data/spec/nanoc/base/services/outdatedness_rules_spec.rb +432 -0
  61. data/spec/nanoc/base/services/pruner_spec.rb +105 -0
  62. data/spec/nanoc/base/services/temp_filename_factory_spec.rb +87 -0
  63. data/spec/nanoc/base/views/config_view_spec.rb +96 -0
  64. data/spec/nanoc/base/views/document_view_spec.rb +332 -0
  65. data/spec/nanoc/base/views/identifiable_collection_view_spec.rb +190 -0
  66. data/spec/nanoc/base/views/item_collection_with_reps_view_spec.rb +18 -0
  67. data/spec/nanoc/base/views/item_collection_without_reps_view_spec.rb +18 -0
  68. data/spec/nanoc/base/views/item_rep_collection_view_spec.rb +143 -0
  69. data/spec/nanoc/base/views/item_rep_view_spec.rb +265 -0
  70. data/spec/nanoc/base/views/item_view_spec.rb +341 -0
  71. data/spec/nanoc/base/views/layout_collection_view_spec.rb +18 -0
  72. data/spec/nanoc/base/views/layout_view_spec.rb +14 -0
  73. data/spec/nanoc/base/views/mutable_config_view_spec.rb +16 -0
  74. data/spec/nanoc/base/views/mutable_document_view_spec.rb +92 -0
  75. data/spec/nanoc/base/views/mutable_identifiable_collection_view_spec.rb +36 -0
  76. data/spec/nanoc/base/views/mutable_item_collection_view_spec.rb +49 -0
  77. data/spec/nanoc/base/views/mutable_item_view_spec.rb +22 -0
  78. data/spec/nanoc/base/views/mutable_layout_collection_view_spec.rb +49 -0
  79. data/spec/nanoc/base/views/mutable_layout_view_spec.rb +13 -0
  80. data/spec/nanoc/base/views/post_compile_item_rep_collection_view_spec.rb +4 -0
  81. data/spec/nanoc/base/views/post_compile_item_rep_view_spec.rb +137 -0
  82. data/spec/nanoc/base/views/post_compile_item_view_spec.rb +56 -0
  83. data/spec/nanoc/cli/commands/compile/file_action_printer_spec.rb +76 -0
  84. data/spec/nanoc/cli/commands/compile/timing_recorder_spec.rb +66 -0
  85. data/spec/nanoc/cli/commands/compile_spec.rb +64 -0
  86. data/spec/nanoc/cli/commands/deploy_spec.rb +327 -0
  87. data/spec/nanoc/cli/commands/shell_spec.rb +54 -0
  88. data/spec/nanoc/cli/commands/show_data_spec.rb +126 -0
  89. data/spec/nanoc/cli/commands/show_rules_spec.rb +112 -0
  90. data/spec/nanoc/cli/commands/view_spec.rb +58 -0
  91. data/spec/nanoc/data_sources/filesystem_spec.rb +56 -0
  92. data/spec/nanoc/deploying/fog_spec.rb +193 -0
  93. data/spec/nanoc/extra/parallel_collection_spec.rb +108 -0
  94. data/spec/nanoc/filters/colorize_syntax/rouge_spec.rb +195 -0
  95. data/spec/nanoc/filters/less_spec.rb +120 -0
  96. data/spec/nanoc/helpers/blogging_spec.rb +216 -0
  97. data/spec/nanoc/helpers/breadcrumbs_spec.rb +133 -0
  98. data/spec/nanoc/helpers/capturing_spec.rb +181 -0
  99. data/spec/nanoc/helpers/child_parent_spec.rb +105 -0
  100. data/spec/nanoc/helpers/filtering_spec.rb +72 -0
  101. data/spec/nanoc/helpers/html_escape_spec.rb +35 -0
  102. data/spec/nanoc/helpers/link_to_spec.rb +275 -0
  103. data/spec/nanoc/helpers/rendering_spec.rb +141 -0
  104. data/spec/nanoc/helpers/tagging_spec.rb +104 -0
  105. data/spec/nanoc/helpers/text_spec.rb +58 -0
  106. data/spec/nanoc/integration/outdatedness_integration_spec.rb +208 -0
  107. data/spec/nanoc/regressions/gh_1015_spec.rb +17 -0
  108. data/spec/nanoc/regressions/gh_1031_spec.rb +54 -0
  109. data/spec/nanoc/regressions/gh_1035_spec.rb +33 -0
  110. data/spec/nanoc/regressions/gh_1040_spec.rb +22 -0
  111. data/spec/nanoc/regressions/gh_761_spec.rb +23 -0
  112. data/spec/nanoc/regressions/gh_767_spec.rb +19 -0
  113. data/spec/nanoc/regressions/gh_769_spec.rb +30 -0
  114. data/spec/nanoc/regressions/gh_776_spec.rb +43 -0
  115. data/spec/nanoc/regressions/gh_787_spec.rb +19 -0
  116. data/spec/nanoc/regressions/gh_795_spec.rb +19 -0
  117. data/spec/nanoc/regressions/gh_804_spec.rb +26 -0
  118. data/spec/nanoc/regressions/gh_807_spec.rb +17 -0
  119. data/spec/nanoc/regressions/gh_809_spec.rb +17 -0
  120. data/spec/nanoc/regressions/gh_813_spec.rb +22 -0
  121. data/spec/nanoc/regressions/gh_815_spec.rb +18 -0
  122. data/spec/nanoc/regressions/gh_828_spec.rb +23 -0
  123. data/spec/nanoc/regressions/gh_833_spec.rb +14 -0
  124. data/spec/nanoc/regressions/gh_841_spec.rb +15 -0
  125. data/spec/nanoc/regressions/gh_867_spec.rb +15 -0
  126. data/spec/nanoc/regressions/gh_882_spec.rb +29 -0
  127. data/spec/nanoc/regressions/gh_885_spec.rb +30 -0
  128. data/spec/nanoc/regressions/gh_891_spec.rb +26 -0
  129. data/spec/nanoc/regressions/gh_913_spec.rb +24 -0
  130. data/spec/nanoc/regressions/gh_928_spec.rb +5 -0
  131. data/spec/nanoc/regressions/gh_937_spec.rb +25 -0
  132. data/spec/nanoc/regressions/gh_942_spec.rb +21 -0
  133. data/spec/nanoc/regressions/gh_947_spec.rb +21 -0
  134. data/spec/nanoc/regressions/gh_948_spec.rb +16 -0
  135. data/spec/nanoc/regressions/gh_951_spec.rb +19 -0
  136. data/spec/nanoc/regressions/gh_954_spec.rb +33 -0
  137. data/spec/nanoc/regressions/gh_970a_spec.rb +17 -0
  138. data/spec/nanoc/regressions/gh_970b_spec.rb +50 -0
  139. data/spec/nanoc/regressions/gh_974_spec.rb +17 -0
  140. data/spec/nanoc/regressions/gh_981_spec.rb +21 -0
  141. data/spec/nanoc/rule_dsl/recording_executor_spec.rb +142 -0
  142. data/spec/nanoc/rule_dsl/rule_context_spec.rb +177 -0
  143. data/spec/nanoc/rule_dsl/rule_memory_calculator_spec.rb +233 -0
  144. data/spec/nanoc/rule_dsl/rules_collection_spec.rb +299 -0
  145. data/spec/regression_filenames_spec.rb +16 -0
  146. data/spec/spec_helper.rb +173 -0
  147. data/test/base/core_ext/array_spec.rb +2 -0
  148. data/test/base/core_ext/hash_spec.rb +2 -0
  149. data/test/base/core_ext/string_spec.rb +2 -0
  150. data/test/base/test_code_snippet.rb +2 -0
  151. data/test/base/test_compiler.rb +2 -0
  152. data/test/base/test_context.rb +4 -2
  153. data/test/base/test_data_source.rb +2 -0
  154. data/test/base/test_dependency_tracker.rb +2 -0
  155. data/test/base/test_directed_graph.rb +2 -0
  156. data/test/base/test_filter.rb +7 -5
  157. data/test/base/test_item.rb +2 -0
  158. data/test/base/test_item_array.rb +3 -1
  159. data/test/base/test_layout.rb +2 -0
  160. data/test/base/test_memoization.rb +2 -0
  161. data/test/base/test_notification_center.rb +2 -0
  162. data/test/base/test_outdatedness_checker.rb +2 -0
  163. data/test/base/test_plugin.rb +2 -0
  164. data/test/base/test_site.rb +2 -0
  165. data/test/base/test_store.rb +2 -0
  166. data/test/checking/checks/test_css.rb +2 -0
  167. data/test/checking/checks/test_external_links.rb +4 -2
  168. data/test/checking/checks/test_html.rb +2 -0
  169. data/test/checking/checks/test_internal_links.rb +5 -3
  170. data/test/checking/checks/test_mixed_content.rb +2 -0
  171. data/test/checking/checks/test_stale.rb +2 -0
  172. data/test/checking/test_check.rb +2 -0
  173. data/test/checking/test_dsl.rb +2 -0
  174. data/test/checking/test_runner.rb +2 -0
  175. data/test/cli/commands/test_check.rb +2 -0
  176. data/test/cli/commands/test_compile.rb +2 -0
  177. data/test/cli/commands/test_create_site.rb +2 -0
  178. data/test/cli/commands/test_help.rb +2 -0
  179. data/test/cli/commands/test_info.rb +2 -0
  180. data/test/cli/commands/test_prune.rb +2 -0
  181. data/test/cli/test_cleaning_stream.rb +2 -0
  182. data/test/cli/test_cli.rb +11 -9
  183. data/test/cli/test_error_handler.rb +2 -0
  184. data/test/cli/test_logger.rb +2 -0
  185. data/test/data_sources/test_filesystem.rb +8 -6
  186. data/test/data_sources/test_filesystem_tools.rb +2 -0
  187. data/test/deploying/test_fog.rb +2 -0
  188. data/test/deploying/test_rsync.rb +4 -2
  189. data/test/extra/core_ext/test_pathname.rb +2 -0
  190. data/test/extra/core_ext/test_time.rb +2 -0
  191. data/test/extra/test_link_collector.rb +2 -0
  192. data/test/extra/test_piper.rb +2 -0
  193. data/test/filters/colorize_syntax/test_coderay.rb +2 -0
  194. data/test/filters/colorize_syntax/test_common.rb +2 -0
  195. data/test/filters/colorize_syntax/test_pygmentize.rb +2 -0
  196. data/test/filters/colorize_syntax/test_pygments.rb +2 -0
  197. data/test/filters/colorize_syntax/test_simon.rb +2 -0
  198. data/test/filters/test_asciidoc.rb +2 -0
  199. data/test/filters/test_bluecloth.rb +2 -0
  200. data/test/filters/test_coffeescript.rb +2 -0
  201. data/test/filters/test_erb.rb +7 -5
  202. data/test/filters/test_erubis.rb +6 -4
  203. data/test/filters/test_haml.rb +7 -5
  204. data/test/filters/test_handlebars.rb +2 -0
  205. data/test/filters/test_kramdown.rb +2 -0
  206. data/test/filters/test_markaby.rb +2 -0
  207. data/test/filters/test_maruku.rb +2 -0
  208. data/test/filters/test_mustache.rb +4 -2
  209. data/test/filters/test_pandoc.rb +2 -0
  210. data/test/filters/test_rainpress.rb +2 -0
  211. data/test/filters/test_rdiscount.rb +2 -0
  212. data/test/filters/test_rdoc.rb +2 -0
  213. data/test/filters/test_redcarpet.rb +2 -0
  214. data/test/filters/test_redcloth.rb +2 -0
  215. data/test/filters/test_relativize_paths.rb +2 -0
  216. data/test/filters/test_rubypants.rb +2 -0
  217. data/test/filters/test_sass.rb +4 -2
  218. data/test/filters/test_slim.rb +4 -2
  219. data/test/filters/test_typogruby.rb +2 -0
  220. data/test/filters/test_uglify_js.rb +2 -0
  221. data/test/filters/test_xsl.rb +2 -0
  222. data/test/filters/test_yui_compressor.rb +5 -3
  223. data/test/helpers/test_blogging.rb +2 -0
  224. data/test/helpers/test_capturing.rb +2 -0
  225. data/test/helpers/test_link_to.rb +2 -0
  226. data/test/helpers/test_xml_sitemap.rb +2 -0
  227. data/test/rule_dsl/test_action_provider.rb +2 -0
  228. data/test/rule_dsl/test_compiler_dsl.rb +6 -4
  229. data/test/rule_dsl/test_rule.rb +2 -0
  230. data/test/rule_dsl/test_rules_collection.rb +2 -0
  231. data/test/test_gem.rb +2 -0
  232. metadata +124 -17
  233. 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
@@ -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
@@ -1,3 +1,5 @@
1
+ require 'helper'
2
+
1
3
  describe 'Array#__nanoc_symbolize_keys_recursively' do
2
4
  it 'should convert keys to symbols' do
3
5
  array_old = [:abc, 'xyz', { 'foo' => 'bar', :baz => :qux }]
@@ -1,3 +1,5 @@
1
+ require 'helper'
2
+
1
3
  describe 'Hash#__nanoc_symbolize_keys_recursively' do
2
4
  it 'should convert keys to symbols' do
3
5
  hash_old = { 'foo' => 'bar' }
@@ -1,3 +1,5 @@
1
+ require 'helper'
2
+
1
3
  describe 'String#__nanoc_cleaned_identifier' do
2
4
  it 'should not convert already clean paths' do
3
5
  '/foo/bar/'.__nanoc_cleaned_identifier.must_equal '/foo/bar/'
@@ -1,3 +1,5 @@
1
+ require 'helper'
2
+
1
3
  class Nanoc::Int::CodeSnippetTest < Nanoc::TestCase
2
4
  def test_load
3
5
  # Initialize
@@ -1,3 +1,5 @@
1
+ require 'helper'
2
+
1
3
  class Nanoc::Int::CompilerTest < Nanoc::TestCase
2
4
  def new_compiler(site = nil)
3
5
  site ||= Nanoc::Int::Site.new(
@@ -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({ foo: 'bar', baz: 'quux' })
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({ foo: 'bar', baz: 'quux' })
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))
@@ -1,3 +1,5 @@
1
+ require 'helper'
2
+
1
3
  class Nanoc::DataSourceTest < Nanoc::TestCase
2
4
  def test_loading
3
5
  # Create data source
@@ -1,3 +1,5 @@
1
+ require 'helper'
2
+
1
3
  class Nanoc::Int::DependencyTrackerTest < Nanoc::TestCase
2
4
  def test_initialize
3
5
  # Mock items
@@ -1,3 +1,5 @@
1
+ require 'helper'
2
+
1
3
  class Nanoc::Int::DirectedGraphTest < Nanoc::TestCase
2
4
  def test_direct_predecessors
3
5
  graph = Nanoc::Int::DirectedGraph.new([1, 2, 3])
@@ -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({ foo: 'bar' })
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({ foo: 'bar' })
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({ foo: 'bar' })
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({ item: item, item_rep: item_rep })
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({ item: mock, item_rep: mock, layout: layout })
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)
@@ -1,3 +1,5 @@
1
+ require 'helper'
2
+
1
3
  class Nanoc::Int::ItemTest < Nanoc::TestCase
2
4
  def test_initialize_with_attributes_with_string_keys
3
5
  item = Nanoc::Int::Item.new('foo', { 'abc' => 'xyz' }, '/foo/')
@@ -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({ string_pattern_type: 'glob' })
30
+ @items = Nanoc::Int::IdentifiableCollection.new(string_pattern_type: 'glob')
29
31
  @items << @one
30
32
  @items << @two
31
33
 
@@ -1,3 +1,5 @@
1
+ require 'helper'
2
+
1
3
  class Nanoc::Int::LayoutTest < Nanoc::TestCase
2
4
  def test_initialize
3
5
  # Make sure attributes are cleaned
@@ -1,3 +1,5 @@
1
+ require 'helper'
2
+
1
3
  class Nanoc::Int::MemoizationTest < Nanoc::TestCase
2
4
  class Sample1
3
5
  extend Nanoc::Int::Memoization
@@ -1,3 +1,5 @@
1
+ require 'helper'
2
+
1
3
  class Nanoc::Int::NotificationCenterTest < Nanoc::TestCase
2
4
  def test_post
3
5
  # Set up notification
@@ -1,3 +1,5 @@
1
+ require 'helper'
2
+
1
3
  class Nanoc::Int::OutdatednessCheckerTest < Nanoc::TestCase
2
4
  def test_not_outdated
3
5
  # Compile once
@@ -1,3 +1,5 @@
1
+ require 'helper'
2
+
1
3
  class Nanoc::PluginTest < Nanoc::TestCase
2
4
  class SampleFilter < Nanoc::Filter
3
5
  identifier :_plugin_test_sample_filter
@@ -1,3 +1,5 @@
1
+ require 'helper'
2
+
1
3
  class Nanoc::Int::SiteTest < Nanoc::TestCase
2
4
  def test_initialize_with_dir_without_config_yaml
3
5
  assert_raises(Nanoc::Int::ConfigLoader::NoConfigFileFoundError) do
@@ -1,3 +1,5 @@
1
+ require 'helper'
2
+
1
3
  class Nanoc::Int::StoreTest < Nanoc::TestCase
2
4
  class TestStore < Nanoc::Int::Store
3
5
  def data
@@ -1,3 +1,5 @@
1
+ require 'helper'
2
+
1
3
  class Nanoc::Checking::Checks::CSSTest < Nanoc::TestCase
2
4
  def test_run_ok
3
5
  VCR.use_cassette('css_run_ok') do
@@ -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({ checks: { external_links: { exclude: ['^http://excluded.com$'] } } })
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({ checks: { external_links: { exclude_files: ['blog/page'] } } })
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::HTMLTest < Nanoc::TestCase
2
4
  def test_run_ok
3
5
  require 'w3c_validators'
@@ -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({ checks: { internal_links: { exclude: ['^/excluded\d+'] } } })
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({ checks: { internal_links: { exclude_targets: ['^/excluded\d+'] } } })
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({ checks: { internal_links: { exclude_origins: ['^/excluded'] } } })
100
+ site.config.update(checks: { internal_links: { exclude_origins: ['^/excluded'] } })
99
101
 
100
102
  # Test
101
103
  assert check.send(:valid?, '/foo', 'output/excluded')
@@ -1,3 +1,5 @@
1
+ require 'helper'
2
+
1
3
  class Nanoc::Checking::Checks::MixedContentTest < Nanoc::TestCase
2
4
  def create_output_file(name, lines)
3
5
  FileUtils.mkdir_p('output')
@@ -1,3 +1,5 @@
1
+ require 'helper'
2
+
1
3
  class Nanoc::Checking::Checks::StaleTest < Nanoc::TestCase
2
4
  def check_class
3
5
  Nanoc::Checking::Checks::Stale
@@ -1,3 +1,5 @@
1
+ require 'helper'
2
+
1
3
  class Nanoc::Checking::CheckTest < Nanoc::TestCase
2
4
  def test_output_filenames
3
5
  with_site do |site|
@@ -1,3 +1,5 @@
1
+ require 'helper'
2
+
1
3
  class Nanoc::Checking::DSLTest < Nanoc::TestCase
2
4
  def test_from_file
3
5
  with_site do |_site|
@@ -1,3 +1,5 @@
1
+ require 'helper'
2
+
1
3
  class Nanoc::Checking::RunnerTest < Nanoc::TestCase
2
4
  def test_run_specific
3
5
  with_site do |site|
@@ -1,3 +1,5 @@
1
+ require 'helper'
2
+
1
3
  class Nanoc::CLI::Commands::CheckTest < Nanoc::TestCase
2
4
  def test_check_stale
3
5
  with_site do |_site|
@@ -1,3 +1,5 @@
1
+ require 'helper'
2
+
1
3
  class Nanoc::CLI::Commands::CompileTest < Nanoc::TestCase
2
4
  def test_profiling_information
3
5
  with_site do |_site|
@@ -1,3 +1,5 @@
1
+ require 'helper'
2
+
1
3
  class Nanoc::CLI::Commands::CreateSiteTest < Nanoc::TestCase
2
4
  def test_create_site_with_existing_name
3
5
  Nanoc::CLI.run %w(create_site foo)
@@ -1,3 +1,5 @@
1
+ require 'helper'
2
+
1
3
  class Nanoc::CLI::Commands::HelpTest < Nanoc::TestCase
2
4
  def test_run
3
5
  Nanoc::CLI.run %w(help)
@@ -1,3 +1,5 @@
1
+ require 'helper'
2
+
1
3
  class Nanoc::CLI::Commands::InfoTest < Nanoc::TestCase
2
4
  def test_run
3
5
  Nanoc::CLI.run %w(info)
@@ -1,3 +1,5 @@
1
+ require 'helper'
2
+
1
3
  class Nanoc::CLI::Commands::PruneTest < Nanoc::TestCase
2
4
  def test_run_without_yes
3
5
  with_site do |_site|
@@ -1,3 +1,5 @@
1
+ require 'helper'
2
+
1
3
  class Nanoc::CLI::CleaningStreamTest < Nanoc::TestCase
2
4
  class Stream
3
5
  attr_accessor :called_methods
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({ 'LC_ALL' => 'en_US.UTF-8' }) { assert Nanoc::CLI.enable_utf8?(io) }
180
- with_env_vars({ 'LC_CTYPE' => 'en_US.UTF-8' }) { assert Nanoc::CLI.enable_utf8?(io) }
181
- with_env_vars({ 'LANG' => 'en_US.UTF-8' }) { assert Nanoc::CLI.enable_utf8?(io) }
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({ 'LC_ALL' => 'en_US.utf-8' }) { assert Nanoc::CLI.enable_utf8?(io) }
184
- with_env_vars({ 'LC_CTYPE' => 'en_US.utf-8' }) { assert Nanoc::CLI.enable_utf8?(io) }
185
- with_env_vars({ 'LANG' => 'en_US.utf-8' }) { assert Nanoc::CLI.enable_utf8?(io) }
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({ 'LC_ALL' => 'en_US.utf8' }) { assert Nanoc::CLI.enable_utf8?(io) }
188
- with_env_vars({ 'LC_CTYPE' => 'en_US.utf8' }) { assert Nanoc::CLI.enable_utf8?(io) }
189
- with_env_vars({ 'LANG' => 'en_US.utf8' }) { assert Nanoc::CLI.enable_utf8?(io) }
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
@@ -1,3 +1,5 @@
1
+ require 'helper'
2
+
1
3
  class Nanoc::CLI::ErrorHandlerTest < Nanoc::TestCase
2
4
  def setup
3
5
  super
@@ -1,3 +1,5 @@
1
+ require 'helper'
2
+
1
3
  class Nanoc::CLI::LoggerTest < Nanoc::TestCase
2
4
  def test_stub; end
3
5
  end
@@ -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({ identifier_type: 'full' })
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({ identifier_type: 'full' })
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({ identifier_type: 'full' })
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, { allow_periods_in_identifiers: true })
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, { allow_periods_in_identifiers: true })
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, { allow_periods_in_identifiers: true })
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 = {
@@ -1,3 +1,5 @@
1
+ require 'helper'
2
+
1
3
  class Nanoc::DataSources::FilesystemToolsTest < Nanoc::TestCase
2
4
  def setup
3
5
  super