2011-02-03 01:48:27 -05:00
|
|
|
# Copyright (c) 2010-2011 Michael Dvorkin
|
2010-10-31 22:21:26 -04:00
|
|
|
#
|
|
|
|
# Awesome Print is freely distributable under the terms of MIT license.
|
|
|
|
# See LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
#
|
2011-05-06 18:20:52 -04:00
|
|
|
# Running specs from the command line:
|
2011-05-06 20:35:49 -04:00
|
|
|
# $ rake spec # Entire spec suite.
|
|
|
|
# $ rspec spec/logger_spec.rb # Individual spec file.
|
2010-10-31 22:21:26 -04:00
|
|
|
#
|
2010-03-25 00:31:59 -04:00
|
|
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
|
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
|
|
require 'ap'
|
|
|
|
|
2010-04-08 22:57:58 -04:00
|
|
|
def stub_dotfile!
|
|
|
|
dotfile = File.join(ENV["HOME"], ".aprc")
|
|
|
|
File.should_receive(:readable?).at_least(:once).with(dotfile).and_return(false)
|
2010-03-25 00:31:59 -04:00
|
|
|
end
|
2011-05-04 20:20:07 -04:00
|
|
|
|
2011-05-13 16:22:01 -04:00
|
|
|
# The following is needed for the Infinity Test. It runs tests as subprocesses,
|
|
|
|
# which sets STDOUT.tty? to false and would otherwise prematurely disallow colors.
|
2011-05-04 20:20:07 -04:00
|
|
|
AwesomePrint.force_colors!
|
2011-05-13 16:22:01 -04:00
|
|
|
|
|
|
|
# Ruby 1.8.6 only: define missing String methods that are needed for the specs to pass.
|
|
|
|
if RUBY_VERSION < '1.8.7'
|
|
|
|
class String
|
|
|
|
def shellescape # Taken from Ruby 1.9.2 standard library, see lib/shellwords.rb.
|
|
|
|
return "''" if self.empty?
|
|
|
|
str = self.dup
|
|
|
|
str.gsub!(/([^A-Za-z0-9_\-.,:\/@\n])/n, "\\\\\\1")
|
|
|
|
str.gsub!(/\n/, "'\n'")
|
|
|
|
str
|
|
|
|
end
|
|
|
|
|
|
|
|
def start_with?(*prefixes)
|
|
|
|
prefixes.each do |prefix|
|
|
|
|
prefix = prefix.to_s
|
|
|
|
return true if prefix == self[0, prefix.size]
|
|
|
|
end
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
def end_with?(*suffixes)
|
|
|
|
suffixes.each do |suffix|
|
|
|
|
suffix = suffix.to_s
|
|
|
|
return true if suffix == self[-suffix.size, suffix.size]
|
|
|
|
end
|
|
|
|
false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|