test/helper.rb in nanoc-3.7.3 vs test/helper.rb in nanoc-3.7.4
- old
+ new
@@ -38,11 +38,11 @@
end
def if_have(*libs)
libs.each do |lib|
if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby' && lib == 'nokogiri' && disable_nokogiri?
- skip "Pure Java Nokogiri has issues that cause problems with nanoc (see https://github.com/nanoc/nanoc/pull/422) -- run without DISABLE_NOKOGIRI to enable Nokogiri tests"
+ skip 'Pure Java Nokogiri has issues that cause problems with nanoc (see https://github.com/nanoc/nanoc/pull/422) -- run without DISABLE_NOKOGIRI to enable Nokogiri tests'
return
end
begin
require lib
@@ -54,19 +54,17 @@
yield
end
def if_implemented
- begin
- yield
- rescue NotImplementedError, NameError
- skip $!
- return
- end
+ yield
+ rescue NotImplementedError, NameError
+ skip $!
+ return
end
- def with_site(params={})
+ def with_site(params = {})
# Build site name
site_name = params[:name]
if site_name.nil?
@site_num ||= 0
site_name = "site-#{@site_num}"
@@ -180,11 +178,11 @@
# Adapted from http://github.com/lsegal/yard-examples/tree/master/doctest
def assert_examples_correct(object)
P(object).tags(:example).each do |example|
# Classify
lines = example.text.lines.map do |line|
- [ line =~ /^\s*# ?=>/ ? :result : :code, line ]
+ [line =~ /^\s*# ?=>/ ? :result : :code, line]
end
# Join
pieces = []
lines.each do |line|
@@ -235,29 +233,29 @@
def on_windows?
Nanoc.on_windows?
end
- def have_command?(cmd)
- which, null = on_windows? ? ["where", "NUL"] : ["which", "/dev/null"]
+ def command?(cmd)
+ which, null = on_windows? ? ['where', 'NUL'] : ['which', '/dev/null']
system("#{which} #{cmd} > #{null} 2>&1")
end
- def have_symlink?
+ def symlinks_supported?
File.symlink nil, nil
rescue NotImplementedError
return false
rescue
return true
end
def skip_unless_have_command(cmd)
- skip "Could not find external command \"#{cmd}\"" unless have_command?(cmd)
+ skip "Could not find external command \"#{cmd}\"" unless command?(cmd)
end
- def skip_unless_have_symlink
- skip "Symlinks are not supported by Ruby on Windows" unless have_symlink?
+ def skip_unless_symlinks_supported
+ skip 'Symlinks are not supported by Ruby on Windows' unless symlinks_supported?
end
end
class Nanoc::TestCase < MiniTest::Unit::TestCase
@@ -271,8 +269,8 @@
# A more precise inspect method for Time improves assert failure messages.
#
class Time
def inspect
- strftime("%a %b %d %H:%M:%S.#{"%06d" % usec} %Z %Y")
+ strftime("%a %b %d %H:%M:%S.#{'%06d' % usec} %Z %Y")
end
end