nanoc 3.6.6 → 3.6.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +15 -0
  2. data/Gemfile +4 -3
  3. data/Gemfile.lock +48 -40
  4. data/NEWS.md +20 -2
  5. data/lib/nanoc/cli/cleaning_stream.rb +21 -6
  6. data/lib/nanoc/cli/commands/autocompile.rb +1 -0
  7. data/lib/nanoc/cli/commands/compile.rb +57 -25
  8. data/lib/nanoc/cli/commands/create-site.rb +1 -1
  9. data/lib/nanoc/cli/commands/watch.rb +3 -2
  10. data/lib/nanoc/cli.rb +9 -4
  11. data/lib/nanoc/extra/deployers/fog.rb +5 -5
  12. data/lib/nanoc/filters/handlebars.rb +3 -1
  13. data/lib/nanoc/filters/sass/sass_filesystem_importer.rb +13 -20
  14. data/lib/nanoc/filters/sass.rb +5 -20
  15. data/lib/nanoc/version.rb +1 -1
  16. data/lib/nanoc.rb +5 -0
  17. data/tasks/test.rake +16 -25
  18. data/test/base/test_context.rb +1 -1
  19. data/test/base/test_directed_graph.rb +1 -1
  20. data/test/cli/commands/test_compile.rb +61 -0
  21. data/test/cli/commands/test_deploy.rb +3 -0
  22. data/test/cli/commands/test_prune.rb +1 -0
  23. data/test/cli/commands/test_watch.rb +2 -0
  24. data/test/cli/test_cleaning_stream.rb +9 -1
  25. data/test/data_sources/test_filesystem.rb +1 -1
  26. data/test/data_sources/test_static.rb +2 -0
  27. data/test/extra/test_filesystem_tools.rb +4 -0
  28. data/test/filters/test_asciidoc.rb +1 -3
  29. data/test/filters/test_colorize_syntax.rb +4 -10
  30. data/test/filters/test_handlebars.rb +21 -0
  31. data/test/filters/test_less.rb +1 -1
  32. data/test/filters/test_maruku.rb +1 -1
  33. data/test/filters/test_pandoc.rb +1 -3
  34. data/test/filters/test_sass.rb +65 -0
  35. data/test/helper.rb +36 -5
  36. data/test/helpers/test_link_to.rb +3 -3
  37. data/test/helpers/test_rendering.rb +2 -2
  38. data/test/test_gem.rb +1 -1
  39. metadata +5 -19
@@ -12,34 +12,19 @@ module Nanoc::Filters
12
12
  #
13
13
  # @return [String] The filtered content
14
14
  def run(content, params={})
15
- # Build options
16
- options = params.dup
17
- sass_filename = options[:filename] ||
18
- (@item && @item[:content_filename])
19
- options[:filename] ||= sass_filename
20
- options[:filesystem_importer] ||=
21
- Nanoc::Filters::Sass::SassFilesystemImporter
22
-
23
- # Find items
24
- item_dirglob = Pathname.new(sass_filename).dirname.realpath.to_s + '**'
25
- clean_items = @items.reject { |i| i.raw_filename.nil? }
26
- @scoped_items, @rest_items = clean_items.partition do |i|
27
- i.raw_filename &&
28
- Pathname.new(i.raw_filename).realpath.fnmatch(item_dirglob)
29
- end
30
-
31
- # Render
32
- options[:nanoc_current_filter] = self
15
+ options = params.merge({
16
+ :nanoc_current_filter => self,
17
+ :filename => @item && @item.raw_filename,
18
+ })
33
19
  engine = ::Sass::Engine.new(content, options)
34
20
  engine.render
35
21
  end
36
22
 
37
23
  def imported_filename_to_item(filename)
38
- filematch = lambda do |i|
24
+ @items.find do |i|
39
25
  i.raw_filename &&
40
26
  Pathname.new(i.raw_filename).realpath == Pathname.new(filename).realpath
41
27
  end
42
- @scoped_items.find(&filematch) || @rest_items.find(&filematch)
43
28
  end
44
29
 
45
30
  end
data/lib/nanoc/version.rb CHANGED
@@ -3,6 +3,6 @@
3
3
  module Nanoc
4
4
 
5
5
  # The current nanoc version.
6
- VERSION = '3.6.6'
6
+ VERSION = '3.6.7'
7
7
 
8
8
  end
data/lib/nanoc.rb CHANGED
@@ -13,6 +13,11 @@ module Nanoc
13
13
  res
14
14
  end
15
15
 
16
+ # @return [Boolean] True if the current platform is Windows,
17
+ def self.on_windows?
18
+ !!(RUBY_PLATFORM =~ /windows|bccwin|cygwin|djgpp|mingw|mswin|wince/i)
19
+ end
20
+
16
21
  end
17
22
 
18
23
  Nanoc3 = Nanoc
data/tasks/test.rake CHANGED
@@ -1,42 +1,33 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'minitest/unit'
3
+ def run_tests(dir_glob)
4
+ ENV['ARGS'] ||= ''
5
+ ENV['QUIET'] ||= 'true'
4
6
 
5
- test = namespace :test do
7
+ $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '/..'))
6
8
 
7
- # test:all
8
- desc 'Run all tests'
9
- task :all do
10
- ENV['QUIET'] ||= 'true'
11
- $VERBOSE = (ENV['VERBOSE'] == 'true')
9
+ # require our test helper so we don't have to in each individual test
10
+ require 'test/helper'
12
11
 
13
- $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '/..'))
12
+ test_files = Dir["#{dir_glob}*_spec.rb"] + Dir["#{dir_glob}test_*.rb"]
13
+ test_files.each { |f| require f }
14
14
 
15
- # require our test helper so we don't have to in each individual test
16
- require 'test/helper'
15
+ exit MiniTest::Unit.new.run(ENV['ARGS'].split)
16
+ end
17
17
 
18
- test_files = Dir['test/**/*_spec.rb'] + Dir['test/**/test_*.rb']
19
- test_files.each { |f| require f }
18
+ namespace :test do
20
19
 
21
- exit MiniTest::Unit.new.run($VERBOSE ? %w( --verbose ) : %w())
20
+ # test:all
21
+ desc 'Run all tests'
22
+ task :all do
23
+ run_tests "test/**/"
22
24
  end
23
25
 
24
26
  # test:...
25
27
  %w( base cli data_sources extra filters helpers tasks ).each do |dir|
26
28
  desc "Run all #{dir} tests"
27
29
  task dir.to_sym do |task|
28
- ENV['QUIET'] ||= 'true'
29
- $VERBOSE = (ENV['VERBOSE'] == 'true')
30
-
31
- $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '/..'))
32
-
33
- # require our test helper so we don't have to in each individual test
34
- require 'test/helper'
35
-
36
- test_files = Dir["test/#{dir}/**/*_spec.rb"] + Dir["test/#{dir}/**/test_*.rb"]
37
- test_files.each { |f| require f }
38
-
39
- exit MiniTest::Unit.new.run($VERBOSE ? %w( --verbose ) : %w())
30
+ run_tests "test/#{dir}/**/"
40
31
  end
41
32
  end
42
33
 
@@ -20,7 +20,7 @@ class Nanoc::ContextTest < Nanoc::TestCase
20
20
 
21
21
  def test_example
22
22
  # Parse
23
- YARD.parse('../lib/nanoc/base/context.rb')
23
+ YARD.parse(LIB_DIR + '/nanoc/base/context.rb')
24
24
 
25
25
  # Run
26
26
  assert_examples_correct 'Nanoc::Context#initialize'
@@ -282,7 +282,7 @@ class Nanoc::DirectedGraphTest < Nanoc::TestCase
282
282
  end
283
283
 
284
284
  def test_example
285
- YARD.parse('../lib/nanoc/base/directed_graph.rb')
285
+ YARD.parse(LIB_DIR + '/nanoc/base/directed_graph.rb')
286
286
  assert_examples_correct 'Nanoc::DirectedGraph'
287
287
  end
288
288
 
@@ -140,4 +140,65 @@ class Nanoc::CLI::Commands::CompileTest < Nanoc::TestCase
140
140
  end
141
141
  end
142
142
 
143
+ def test_file_action_printer_normal
144
+ # Create data
145
+ item = Nanoc::Item.new('content', {}, '/')
146
+ rep = Nanoc::ItemRep.new(item, :default)
147
+ rep.raw_path = 'output/foo.txt'
148
+
149
+ # Listen
150
+ listener = new_file_action_printer([ rep ])
151
+ listener.start
152
+ Nanoc::NotificationCenter.post(:compilation_started, rep)
153
+ Nanoc::NotificationCenter.post(:compilation_ended, rep)
154
+ listener.stop
155
+
156
+ # Check
157
+ assert_equal 1, listener.events.size
158
+ assert_equal :low, listener.events[0][:level]
159
+ assert_equal :skip, listener.events[0][:action]
160
+ assert_equal 'output/foo.txt', listener.events[0][:path]
161
+ assert_in_delta 0.0, listener.events[0][:duration], 1.0
162
+ end
163
+
164
+ def test_file_action_printer_skip
165
+ # Create data
166
+ item = Nanoc::Item.new('content', {}, '/')
167
+ rep = Nanoc::ItemRep.new(item, :default)
168
+ rep.raw_path = 'output/foo.txt'
169
+
170
+ # Listen
171
+ listener = new_file_action_printer([ rep ])
172
+ listener.start
173
+ Nanoc::NotificationCenter.post(:compilation_started, rep)
174
+ listener.stop
175
+
176
+ # Check
177
+ assert_equal 1, listener.events.size
178
+ assert_equal :low, listener.events[0][:level]
179
+ assert_equal :skip, listener.events[0][:action]
180
+ assert_equal 'output/foo.txt', listener.events[0][:path]
181
+ assert_nil listener.events[0][:duration]
182
+ end
183
+
184
+ def new_file_action_printer(reps)
185
+ listener = Nanoc::CLI::Commands::Compile::FileActionPrinter.new(:reps => reps)
186
+
187
+ def listener.log(level, action, path, duration)
188
+ @events ||= []
189
+ @events << {
190
+ :level => level,
191
+ :action => action,
192
+ :path => path,
193
+ :duration => duration
194
+ }
195
+ end
196
+
197
+ def listener.events
198
+ @events
199
+ end
200
+
201
+ listener
202
+ end
203
+
143
204
  end
@@ -3,6 +3,7 @@
3
3
  class Nanoc::CLI::Commands::DeployTest < Nanoc::TestCase
4
4
 
5
5
  def test_deploy
6
+ skip_unless_have_command "rsync"
6
7
  if_have 'systemu' do
7
8
  with_site do |site|
8
9
  File.open('nanoc.yaml', 'w') do |io|
@@ -113,6 +114,7 @@ class Nanoc::CLI::Commands::DeployTest < Nanoc::TestCase
113
114
  end
114
115
 
115
116
  def test_deploy_without_kind
117
+ skip_unless_have_command "rsync"
116
118
  if_have 'systemu' do
117
119
  with_site do |site|
118
120
  File.open('nanoc.yaml', 'w') do |io|
@@ -159,6 +161,7 @@ class Nanoc::CLI::Commands::DeployTest < Nanoc::TestCase
159
161
  end
160
162
 
161
163
  def test_deploy_without_target_with_default
164
+ skip_unless_have_command "rsync"
162
165
  if_have 'systemu' do
163
166
  with_site do |site|
164
167
  File.open('nanoc.yaml', 'w') do |io|
@@ -93,6 +93,7 @@ class Nanoc::CLI::Commands::PruneTest < Nanoc::TestCase
93
93
  end
94
94
 
95
95
  def test_run_with_symlink_to_output_dir
96
+ skip_unless_have_symlink
96
97
  with_site do |site|
97
98
  # Set output dir
98
99
  FileUtils.rm_rf('output')
@@ -33,11 +33,13 @@ class Nanoc::CLI::Commands::WatchTest < Nanoc::TestCase
33
33
  end
34
34
 
35
35
  def test_growlnotify_cmd
36
+ Nanoc::CLI.setup
36
37
  notifier = Nanoc::CLI::Commands::Watch::Notifier.new
37
38
  assert_equal [ 'growlnotify', '-m', 'foo' ], notifier.send(:growlnotify_cmd_for, 'foo')
38
39
  end
39
40
 
40
41
  def test_growlnotify_windows_cmd
42
+ Nanoc::CLI.setup
41
43
  notifier = Nanoc::CLI::Commands::Watch::Notifier.new
42
44
  assert_equal [ 'growlnotify', '/t:nanoc', 'foo' ], notifier.send(:growlnotify_windows_cmd_for, 'foo')
43
45
  end
@@ -9,7 +9,7 @@ class Nanoc::CLI::CleaningStreamTest < Nanoc::TestCase
9
9
  def initialize
10
10
  @called_methods = Set.new
11
11
  end
12
-
12
+
13
13
  def method_missing(symbol, *args)
14
14
  @called_methods << symbol
15
15
  end
@@ -49,4 +49,12 @@ class Nanoc::CLI::CleaningStreamTest < Nanoc::TestCase
49
49
  logger.warn("Something could start going wrong!")
50
50
  end
51
51
 
52
+ def test_broken_pipe
53
+ stream = StringIO.new
54
+ def stream.write(s) ; raise Errno::EPIPE.new ; end
55
+
56
+ cleaning_stream = Nanoc::CLI::CleaningStream.new(stream)
57
+ cleaning_stream.write('lol')
58
+ end
59
+
52
60
  end
@@ -372,7 +372,7 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
372
372
  io.write "content goes here\n"
373
373
  end
374
374
 
375
- data_source = Nanoc::DataSources::FilesystemCombined.new(nil, nil, nil, nil)
375
+ data_source = Nanoc::DataSources::FilesystemCombined.new(nil, nil, nil, :encoding => 'utf-8')
376
376
 
377
377
  result = data_source.instance_eval { parse('test.html', nil, 'foobar') }
378
378
  assert_equal({ 'utf8bomawareness' => 'high' }, result[0])
@@ -14,6 +14,8 @@ class Nanoc::DataSources::StaticTest < Nanoc::TestCase
14
14
  end
15
15
 
16
16
  def test_items_with_symlinks
17
+ skip_unless_have_symlink
18
+
17
19
  # Create data source
18
20
  data_source = new_data_source(:prefix => 'foo')
19
21
 
@@ -1,6 +1,10 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  class Nanoc::Extra::FilesystemToolsTest < Nanoc::TestCase
4
+ def setup
5
+ super
6
+ skip_unless_have_symlink
7
+ end
4
8
 
5
9
  def test_all_files_in_follows_symlinks_to_dirs
6
10
  # Write sample files
@@ -4,9 +4,7 @@ class Nanoc::Filters::AsciiDocTest < Nanoc::TestCase
4
4
 
5
5
  def test_filter
6
6
  if_have 'systemu' do
7
- if `which asciidoc`.strip.empty?
8
- skip "could not find asciidoc"
9
- end
7
+ skip_unless_have_command "asciidoc"
10
8
 
11
9
  # Create filter
12
10
  filter = ::Nanoc::Filters::AsciiDoc.new
@@ -122,9 +122,7 @@ EOS
122
122
 
123
123
  def test_pygmentize
124
124
  if_have 'nokogiri', 'systemu' do
125
- if `which pygmentize`.strip.empty?
126
- skip "could not find pygmentize"
127
- end
125
+ skip_unless_have_command "pygmentize"
128
126
 
129
127
  # Create filter
130
128
  filter = ::Nanoc::Filters::ColorizeSyntax.new
@@ -140,6 +138,7 @@ EOS
140
138
  end
141
139
 
142
140
  def test_pygmentsrb
141
+ skip "pygments.rb does not support Windows" if on_windows?
143
142
  if_have 'pygments', 'nokogiri' do
144
143
  # Create filter
145
144
  filter = ::Nanoc::Filters::ColorizeSyntax.new
@@ -156,9 +155,7 @@ EOS
156
155
 
157
156
  def test_simon_highlight
158
157
  if_have 'nokogiri', 'systemu' do
159
- if `which highlight`.strip.empty?
160
- skip "could not find `highlight`"
161
- end
158
+ skip_unless_have_command "highlight"
162
159
 
163
160
  # Create filter
164
161
  filter = ::Nanoc::Filters::ColorizeSyntax.new
@@ -216,10 +213,7 @@ EOS
216
213
  end
217
214
 
218
215
  def test_colorize_syntax_with_default_colorizer
219
- if `which pygmentize`.strip.empty?
220
- skip 'no pygmentize found, which is required for this test'
221
- return
222
- end
216
+ skip_unless_have_command "pygmentize"
223
217
 
224
218
  if_have 'nokogiri', 'systemu' do
225
219
  # Create filter
@@ -34,4 +34,25 @@ class Nanoc::Filters::HandlebarsTest < Nanoc::TestCase
34
34
  end
35
35
  end
36
36
 
37
+ def test_filter_without_layout
38
+ if_have 'handlebars' do
39
+ # Create data
40
+ item = Nanoc::Item.new(
41
+ 'content',
42
+ { :title => 'Max Payne', :protagonist => 'Max Payne', :location => 'here' },
43
+ '/games/max-payne/')
44
+
45
+ # Create filter
46
+ assigns = {
47
+ :item => item,
48
+ :content => 'No Payne No Gayne'
49
+ }
50
+ filter = ::Nanoc::Filters::Handlebars.new(assigns)
51
+
52
+ # Run filter
53
+ result = filter.setup_and_run('{{protagonist}} says: {{yield}}.')
54
+ assert_equal('Max Payne says: No Payne No Gayne.', result)
55
+ end
56
+ end
57
+
37
58
  end
@@ -118,7 +118,7 @@ class Nanoc::Filters::LessTest < Nanoc::TestCase
118
118
 
119
119
  # Run filter with compress option
120
120
  result = filter.setup_and_run('.foo { bar: a; } .bar { foo: b; }', :compress => true)
121
- assert_match(/^\.foo\{bar:a;\}\n\.bar\{foo:b;\}/, result)
121
+ assert_match(/^\.foo\{bar:a\}\n\.bar\{foo:b\}/, result)
122
122
  end
123
123
  end
124
124
 
@@ -9,7 +9,7 @@ class Nanoc::Filters::MarukuTest < Nanoc::TestCase
9
9
 
10
10
  # Run filter
11
11
  result = filter.setup_and_run("This is _so_ *cool*!")
12
- assert_equal("<p>This is <em>so</em> <em>cool</em>!</p>", result)
12
+ assert_equal("<p>This is <em>so</em> <em>cool</em>!</p>", result.strip)
13
13
  end
14
14
  end
15
15
 
@@ -4,9 +4,7 @@ class Nanoc::Filters::PandocTest < Nanoc::TestCase
4
4
 
5
5
  def test_filter
6
6
  if_have 'pandoc-ruby' do
7
- if `which pandoc`.strip.empty?
8
- skip "could not find pandoc"
9
- end
7
+ skip_unless_have_command "pandoc"
10
8
 
11
9
  # Create filter
12
10
  filter = ::Nanoc::Filters::Pandoc.new
@@ -206,6 +206,71 @@ class Nanoc::Filters::SassTest < Nanoc::TestCase
206
206
  end
207
207
  end
208
208
 
209
+ def test_recompile_includes_with_relative_path
210
+ if_have 'sass', 'compass' do
211
+ with_site do |site|
212
+ # Write compass config
213
+ FileUtils.mkdir_p('compass')
214
+ File.open('compass/config.rb', 'w') do |io|
215
+ io << "project_path = \".\"\n"
216
+ io << "sass_path = \"content/style\"\n"
217
+ end
218
+
219
+ # Create two Sass files
220
+ Dir['content/*'].each { |i| FileUtils.rm(i) }
221
+ FileUtils.mkdir_p('content/style/super')
222
+ FileUtils.mkdir_p('content/style/sub')
223
+ File.open('content/style/super/main.sass', 'w') do |io|
224
+ io.write('@import sub/include.sass')
225
+ end
226
+ File.open('content/style/sub/include.sass', 'w') do |io|
227
+ io.write("p\n color: red")
228
+ end
229
+
230
+ # Update rules
231
+ File.open('Rules', 'w') do |io|
232
+ io.write "require 'compass'\n"
233
+ io.write "Compass.add_project_configuration 'compass/config.rb'\n"
234
+ io.write "\n"
235
+ io.write "compile '*' do\n"
236
+ io.write " filter :sass, Compass.sass_engine_options\n"
237
+ io.write "end\n"
238
+ io.write "\n"
239
+ io.write "route '/style/super/main/' do\n"
240
+ io.write " item.identifier.chop + '.css'\n"
241
+ io.write "end\n"
242
+ io.write "\n"
243
+ io.write "route '/style/sub/include/' do\n"
244
+ io.write " nil\n"
245
+ io.write "end\n"
246
+ end
247
+
248
+ # Compile
249
+ site = Nanoc::Site.new('.')
250
+ site.compile
251
+
252
+ # Check
253
+ output_files = Dir['output/**/*'].select { |f| File.file?(f) }
254
+ assert_equal [ 'output/style/super/main.css' ], output_files
255
+ assert_match(/^p\s*\{\s*color:\s*red;?\s*\}/, File.read('output/style/super/main.css'))
256
+
257
+ # Update included file
258
+ File.open('content/style/sub/include.sass', 'w') do |io|
259
+ io.write("p\n color: blue")
260
+ end
261
+
262
+ # Recompile
263
+ site = Nanoc::Site.new('.')
264
+ site.compile
265
+
266
+ # Recheck
267
+ output_files = Dir['output/**/*'].select { |f| File.file?(f) }
268
+ assert_equal [ 'output/style/super/main.css' ], output_files
269
+ assert_match(/^p\s*\{\s*color:\s*blue;?\s*\}/, File.read('output/style/super/main.css'))
270
+ end
271
+ end
272
+ end
273
+
209
274
  private
210
275
 
211
276
  def create_filter(params={})
data/test/helper.rb CHANGED
@@ -21,10 +21,13 @@ require 'nanoc/cli'
21
21
  require 'nanoc/tasks'
22
22
 
23
23
  # Load miscellaneous requirements
24
+ require 'tmpdir'
24
25
  require 'stringio'
25
26
 
26
27
  module Nanoc::TestHelpers
27
28
 
29
+ LIB_DIR = File.expand_path(File.dirname(__FILE__) + '/../lib')
30
+
28
31
  def if_have(*libs)
29
32
  libs.each do |lib|
30
33
  begin
@@ -113,14 +116,17 @@ EOS
113
116
 
114
117
  # Go quiet
115
118
  unless ENV['QUIET'] == 'false'
119
+ @orig_stdout = $stdout
120
+ @orig_stderr = $stderr
121
+
116
122
  $stdout = StringIO.new
117
123
  $stderr = StringIO.new
118
124
  end
119
125
 
120
126
  # Enter tmp
121
- FileUtils.mkdir_p('tmp')
127
+ @tmp_dir = Dir.mktmpdir('nanoc-test')
122
128
  @orig_wd = FileUtils.pwd
123
- FileUtils.cd('tmp')
129
+ FileUtils.cd(@tmp_dir)
124
130
 
125
131
  # Let us get to the raw errors
126
132
  Nanoc::CLI::ErrorHandler.disable
@@ -132,12 +138,12 @@ EOS
132
138
 
133
139
  # Exit tmp
134
140
  FileUtils.cd(@orig_wd)
135
- FileUtils.rm_rf('tmp')
141
+ FileUtils.rm_rf(@tmp_dir)
136
142
 
137
143
  # Go unquiet
138
144
  unless ENV['QUIET'] == 'false'
139
- $stdout = STDOUT
140
- $stderr = STDERR
145
+ $stdout = @orig_stdout
146
+ $stderr = @orig_stderr
141
147
  end
142
148
  end
143
149
 
@@ -213,6 +219,31 @@ EOS
213
219
  orig_env_hash.each_pair { |k,v| ENV[k] = v }
214
220
  end
215
221
 
222
+ def on_windows?
223
+ Nanoc.on_windows?
224
+ end
225
+
226
+ def have_command?(cmd)
227
+ which, null = on_windows? ? ["where", "NUL"] : ["which", "/dev/null"]
228
+ system("#{which} #{cmd} > #{null} 2>&1")
229
+ end
230
+
231
+ def have_symlink?
232
+ File.symlink nil, nil
233
+ rescue NotImplementedError
234
+ return false
235
+ rescue
236
+ return true
237
+ end
238
+
239
+ def skip_unless_have_command(cmd)
240
+ skip "Could not find external command \"#{cmd}\"" unless have_command?(cmd)
241
+ end
242
+
243
+ def skip_unless_have_symlink
244
+ skip "Symlinks are not supported by Ruby on Windows" unless have_symlink?
245
+ end
246
+
216
247
  end
217
248
 
218
249
  class Nanoc::TestCase < MiniTest::Unit::TestCase
@@ -207,7 +207,7 @@ class Nanoc::Helpers::LinkToTest < Nanoc::TestCase
207
207
 
208
208
  def test_examples_link_to
209
209
  # Parse
210
- YARD.parse('../lib/nanoc/helpers/link_to.rb')
210
+ YARD.parse(LIB_DIR + '/nanoc/helpers/link_to.rb')
211
211
 
212
212
  # Mock
213
213
  @items = [ mock, mock, mock ]
@@ -227,7 +227,7 @@ class Nanoc::Helpers::LinkToTest < Nanoc::TestCase
227
227
 
228
228
  def test_examples_link_to_unless_current
229
229
  # Parse
230
- YARD.parse('../lib/nanoc/helpers/link_to.rb')
230
+ YARD.parse(LIB_DIR + '/nanoc/helpers/link_to.rb')
231
231
 
232
232
  # Mock
233
233
  @item_rep = mock
@@ -241,7 +241,7 @@ class Nanoc::Helpers::LinkToTest < Nanoc::TestCase
241
241
 
242
242
  def test_examples_relative_path_to
243
243
  # Parse
244
- YARD.parse('../lib/nanoc/helpers/link_to.rb')
244
+ YARD.parse(LIB_DIR + '/nanoc/helpers/link_to.rb')
245
245
 
246
246
  # Mock
247
247
  @item_rep = mock
@@ -38,7 +38,7 @@ class Nanoc::Helpers::RenderingTest < Nanoc::TestCase
38
38
  io.write("layout '/foo/', nil\n")
39
39
  end
40
40
 
41
- File.open('layouts/foo.xyz', 'w')
41
+ File.open('layouts/foo.xyz', 'w').close()
42
42
 
43
43
  assert_raises(Nanoc::Errors::CannotDetermineFilter) do
44
44
  render '/foo/'
@@ -54,7 +54,7 @@ class Nanoc::Helpers::RenderingTest < Nanoc::TestCase
54
54
  io.write("layout '/foo/', :asdf\n")
55
55
  end
56
56
 
57
- File.open('layouts/foo.xyz', 'w')
57
+ File.open('layouts/foo.xyz', 'w').close()
58
58
 
59
59
  assert_raises(Nanoc::Errors::UnknownFilter) do
60
60
  render '/foo/'
data/test/test_gem.rb CHANGED
@@ -31,7 +31,7 @@ class Nanoc::GemTest < Nanoc::TestCase
31
31
  assert_match(/^nanoc-.*\.gem$/, diff.to_a[0])
32
32
 
33
33
  # Check output
34
- assert_match(/Successfully built RubyGem\n Name: nanoc\n Version: .*\n File: nanoc-.*\.gem\n/, stdout)
34
+ assert_match(/Successfully built RubyGem\s+Name: nanoc\s+Version: .*\s+File: nanoc-.*\.gem\s+/, stdout)
35
35
  assert_equal '', stderr
36
36
  ensure
37
37
  Dir['nanoc-*.gem'].each { |f| FileUtils.rm(f) }